I have a native Android app. I imported a Flutter module. Now, I can successfully navigate to the selected route from my Android app. I know passing data between native and flutter side is by method channels. But I did not understand how to implement it when starting the Activity.
Here is my GitHub repo.
startActivity(
new FlutterActivity.NewEngineIntentBuilder(MyFlutterActivity.class)
.initialRoute("/secondScreen")
.build(getApplicationContext())
.putExtra("title", "Hello")); // Here, title is passed!
How can I handle this title on my initState
of secondScreen
?
class SecondScreen extends StatefulWidget {
SecondScreen({Key key, this.title}) : super(key: key);
final String title;
@override
_SecondScreenState createState() => _SecondScreenState();
}
class _SecondScreenState extends State<SecondScreen> {
@override
void initState() {
super.initState();
print("title");
print(widget.title); // Ofc, it is null. I want it as 'Hello'!
}