title: how do I pass data from native app to flutter?
body: <p>I have read this <a href="https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps" rel="noreferrer">https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps</a>.</p>
  <p>My problem is to pass data from existing native android app to flutter module (such as: token, username...etc). So, I want to ask if there is any way to pass data between Native code in existing native app and code in flutter module?</p>
  <p>For example, there are two pages, A and B, A is written in Java code, B embed flutter view, I didn't find any way to pass data from A to the flutter view in B.</p>
  <pre><code>public class TwoActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.two_activity);
          
          //this params passed from HomeActivity 
          String params = getIntent().getStringExtra(&quot;params&quot;);
  
          FrameLayout rootView = findViewById(R.id.container);
  
          View flutterView = Flutter.createView(this, getLifecycle(), &quot;service&quot;);
  
          FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
          rootView.addView(flutterView, layoutParams);
      }
  }
  </code></pre>
  <p>this is <code>main.dart</code></p>
  <pre><code>void main() =&gt; runApp(chooseWidget(window.defaultRouteName));
  
  Widget chooseWidget(String route) {
    switch(route) {
      case 'service':
        return MyFlutterView();
    }
  }
  
  class MyFlutterView extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        debugShowCheckedModeBanner: false,
        home: HomePage(),
      );
    }
  }
  
  class HomePage extends StatelessWidget {
  
    static const platform = const MethodChannel('samples.flutter.dev/start');
  
    @override
    Widget build(BuildContext context) {
      return Container(
        color: Colors.white,
        child: Column(
          children: &lt;Widget&gt;[
  
            Text(
              'this is a flutter page',
              style: TextStyle(
                fontSize: 14,
                color: Colors.blue
              ),
            ),
  
            FlatButton(
              onPressed: () {
                platform.invokeMethod('startActivity');
              },
              child: Text('go native page'),
              color: Colors.purple,
              highlightColor: Colors.deepPurple,
            )
          ],
        ),
      );
    }
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/7IQOD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7IQOD.png" alt="enter image description here" /></a></p>
  <p>--------------------------&gt;edit in 2019.7.18&lt;-----------------------------</p>
  <pre><code>Thank you for your help. I found the answer.
  1、BasicMessageChannel：use this to pass string or other object.
  
  2、MethodChannel：use this to method invocation
  
  3、EventChannel: use this to event streams
  </code></pre>