|
- import 'dart:io';
- import 'dart:typed_data';
-
- import 'package:chat/map/location_result.dart';
- import 'package:chat/utils/screen.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_image_compress/flutter_image_compress.dart';
-
- import 'MessageMgr.dart';
-
- class ScreenShot {
- static const MethodChannel _channel =
- const MethodChannel('make.photo.screen.hibok');
- static const EventChannel eventChannel =
- const EventChannel('com.file.hibok');
-
-
- static Future<List<int>> takeScreenshotImage() async {
- Map<String, dynamic> args = <String, dynamic>{};
- Uint8List bytes = await _channel.invokeMethod('makePhotoScreen', args);
-
- var compressImg = await FlutterImageCompress.compressWithList(bytes,
- quality: 20, minWidth: (Screen.width).toInt());
-
- print('地图大小${bytes.length}');
- return compressImg;
- }
-
- static Future<List> getOtherMapAppList() async {
- Map<String, dynamic> args = <String, dynamic>{};
- return _channel.invokeMethod('getListForMap', args);
- }
-
- static void openMapForOth(String mapType, LocationResult result) async {
- Map<String, dynamic> args = <String, dynamic>{
- 'mapType': mapType,
- 'address': result.address,
- 'latLng': [result.latLng.latitude, result.latLng.longitude]
- };
- _channel.invokeMethod('openMapForOth', args);
- }
-
- static Future<bool> isSupportGoogle() async {
- Map<String, dynamic> args = <String, dynamic>{};
- return _channel.invokeMethod('isSupportGoogle', args);
- }
-
-
- static getFileStream() {
- eventChannel.receiveBroadcastStream().listen((Object agrs){
- print('######## receiveBroadcastStream $agrs');
-
- File file = new File(agrs.toString());
- if(file.existsSync()){
- print('接收到的文件--存在');
- MessageMgr().emit(MessageMgr.RECEIVE_THIRD_SHARE, agrs);
- }else{
- print('接收到的文件--不存在');
- }
-
- }, onError: (Object error){
- print('######## error $error');
- });
- }
- }
|