call_platform.dart 663 B

123456789101112131415161718192021
  1. import 'package:flutter/services.dart';
  2. import 'package:flutter/services.dart';
  3. class NativeMethods {
  4. Future<void> launchAndroid() async {
  5. const platform = MethodChannel('com.example.xcx_dashan_app/channel');
  6. try {
  7. var result = await platform.invokeMethod('launchApp');
  8. // var result = await platform.invokeMethod('launchAppOne',{'param1': "这是一个参数"});
  9. // var result = await platform.invokeMethod('launchAppOne',{'param1': "这是一个参数",'param2': "这是一个参数"});
  10. print("结果$result");
  11. } on PlatformException catch (e) {
  12. print("Failed to invoke method: '${e.message}'.");
  13. }
  14. }
  15. }