When encapsulating a module on flutter in an existing application in java and using FlutterActivity, I had the problem of passing of string. If using variant:
Button mInvokeFlutterActivity = findViewById(R.id.invoke_flutter_activity);
mInvokeFlutterActivity.setOnClickListener(v -> startActivity(
FlutterActivity.withNewEngine().initialRoute(link).build(context)
.putExtra("background_mode", "opaque")
.putExtra("destroy_engine_with_activity", true)
));
then in main.dart, can catch the link variable as window.defaultRouteName. But if use another intent:
Button mInvokeFlutterActivity = findViewById(R.id.invoke_flutter_activity);
mInvokeFlutterActivity.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(FlutterActivity.withCachedEngine("my_engine_id").build(context)
);
}
});
then using window.defaultRouteName will become impossible. Can anyone tell me how to solve the problem?