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

66 行
2.0 KiB

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