Hibok
您不能選擇超過 %s 個話題 話題必須以字母或數字為開頭,可包含連接號 ('-') 且最長為 35 個字
 
 
 
 
 
 

68 行
2.4 KiB

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