Pass data from mainActivity.java to the specific dart file of the flutter project

Viewed 134

I have a task, where I want to pass the int value from mainActivity.java to the dart file. I have tried to pass the data by using putExtra(key, value) but while receiving the data at the dart file I'm getting the null value.

Here is my code which I tried,

MainActivity.java

private void goToFruit(String fruitName, DeepLink dlData) {
            String fruitClassName = (fruitName.substring(0, 1).toUpperCase() + fruitName.substring(1)).concat("Activity");
            Log.d("DEEPLINKING", "Looking for class " + fruitClassName);
        
              startActivity(FlutterActivity.withNewEngine().initialRoute("/teacherdetail").build(this).putExtra("teacherId", 7324));
        
              Log.d("DEEPLINKING", "Intent run Successfully");    
}

teacher_details_screen_one.dart

 @override
  Widget build(BuildContext context) {

    final args = ModalRoute.of(context).settings.arguments as TeacherDetails;

}
0 Answers
Related