You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
new_reccok/lib/utils/android_back_desktop.dart

21 lines
662 B

2 years ago
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class AndroidBackTop {
//初始化通信管道-设置退出到手机桌面
static const String CHANNEL = "android/back/desktop";
//设置回退到手机桌面
static Future<bool> backDeskTop() async {
final platform = MethodChannel(CHANNEL);
//通知安卓返回,到手机桌面
try {
final bool out = await platform.invokeMethod('backDesktop');
if (out) debugPrint('返回到桌面');
} on PlatformException catch (e) {
debugPrint("通信失败(设置回退到安卓手机桌面:设置失败)");
print(e.toString());
}
return Future.value(false);
}
}