Hibok
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

69 行
2.4 KiB

  1. import 'dart:typed_data';
  2. import 'dart:io';
  3. import 'package:chat/map/location_result.dart';
  4. import 'package:chat/utils/screen.dart';
  5. import 'package:flutter/services.dart';
  6. import 'package:flutter_native_image/flutter_native_image.dart';
  7. //import 'package:flutter_image_compress/flutter_image_compress.dart';
  8. import 'MessageMgr.dart';
  9. import 'file_cache_mgr.dart';
  10. class ScreenShot {
  11. static const MethodChannel _channel =
  12. const MethodChannel('make.photo.screen.hibok');
  13. static const EventChannel eventChannel =
  14. const EventChannel('com.file.hibok');
  15. static Future<List<int>> takeScreenshotImage() async {
  16. Map<String, dynamic> args = <String, dynamic>{};
  17. Uint8List bytes = await _channel.invokeMethod('makePhotoScreen', args);
  18. File file =await FileCacheMgr().writeFile(DateTime.now().millisecondsSinceEpoch.toString(),bytes);
  19. File compressedFile = await FlutterNativeImage.compressImage(file.path,
  20. quality: 20, percentage: 80);
  21. var compressImg =compressedFile.readAsBytesSync().toList();
  22. // var compressImg = await FlutterImageCompress.compressWithList(bytes,
  23. // quality: 20, minWidth: (Screen.width).toInt());
  24. print('地图大小${bytes.length} 压缩后${compressImg.length} ');
  25. return compressImg;
  26. }
  27. static Future<List> getOtherMapAppList() async {
  28. Map<String, dynamic> args = <String, dynamic>{};
  29. return _channel.invokeMethod('getListForMap', args);
  30. }
  31. static void openMapForOth(String mapType, LocationResult result) async {
  32. Map<String, dynamic> args = <String, dynamic>{
  33. 'mapType': mapType,
  34. 'address': result.address,
  35. 'latLng': [result.latLng.latitude, result.latLng.longitude]
  36. };
  37. _channel.invokeMethod('openMapForOth', args);
  38. }
  39. static Future<bool> isSupportGoogle() async {
  40. Map<String, dynamic> args = <String, dynamic>{};
  41. return _channel.invokeMethod('isSupportGoogle', args);
  42. }
  43. static getFileStream() {
  44. eventChannel.receiveBroadcastStream().listen((Object agrs){
  45. print('######## receiveBroadcastStream $agrs');
  46. File file = new File(agrs.toString());
  47. if(file.existsSync()){
  48. print('接收到的文件--存在');
  49. MessageMgr().emit(MessageMgr.RECEIVE_THIRD_SHARE, agrs);
  50. }else{
  51. print('接收到的文件--不存在');
  52. }
  53. }, onError: (Object error){
  54. print('######## error $error');
  55. });
  56. }
  57. }