Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Flatter打开Android活动和iOS ViewController_Android_Ios_Flutter - Fatal编程技术网

从Flatter打开Android活动和iOS ViewController

从Flatter打开Android活动和iOS ViewController,android,ios,flutter,Android,Ios,Flutter,我有一个flatter项目,需要在原生Android活动或iOS ViewController中实现某些特定功能。有没有一种方法可以导航到android活动并向其传递数据,还可以在Flatter中从中检索数据 如果不可能,是否可以将来自Android的活动或片段以及来自iOS的ViewController显示为Flitter中的小部件?用于Android和iOS的use intent或Android\u intent软件包use link不确定这是否是最好的方式,我只为Android创建了它,但

我有一个flatter项目,需要在原生Android活动或iOS ViewController中实现某些特定功能。有没有一种方法可以导航到android活动并向其传递数据,还可以在Flatter中从中检索数据


如果不可能,是否可以将来自Android的活动或片段以及来自iOS的ViewController显示为Flitter中的小部件?

用于Android和iOS的use intent或Android\u intent软件包use link

不确定这是否是最好的方式,我只为Android创建了它,但我就是这么做的

简单颤振方法通道调用本机:

static const platform = const MethodChannel(MY_CHANNEL);
string result await platform.invokeMethod("mycall");
从mainActivity中的本机Android部分:

//Class attribute
private Result myresult;

  //Method chanel
  new MethodChannel(getFlutterView(), MY_CHANNEL).setMethodCallHandler(
            (call, result) -> {
                // Note: this method is invoked on the main thread.
                if (call.method.equals("mycall")) {
                    myresult = result; //Store the flutter result
                    Intent intent1 = new Intent(MyClass.class);//Start your special native stuff
                    startActivityForResult(intent1, RQ_CODE);
                } else {
                    result.notImplemented();
                }
            });


@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // Check which request we're responding to
    if (requestCode == RQ_CODE) {
        myresult.success("this will be your result"); //Probably do something with the data instead of a static string.
    }
}
iOS基本上也可以这样做

如果有帮助,请检查此软件包