I am stuck in my project where I have two stateful widgets created in flutter as two different dart files. Now, I have to access the instance of an object created in first w
You can pass the model when you construct SecondScreen widget.
Add model to SecondScreen constructor:
class SecondScreen extends StatefulWidget {
final MyModel myModel;
SecondScreen(MyModel myModel, {Key key}):
super(key: key);
...
}
Pass model when you construct SecondScreen in main.dart
Navigator.push(context, new MaterialPageRoute(builder: (_) =>
new SecondScreen(model)));
Now you can access model in _SecondScreenState via widget.myModel