flutter how to get data from another class code example
Example 1: pass string to a provider flutter
_secondPage(BuildContext context, Widget page) async { final dataFromSecondPage = await Navigator.push( context, MaterialPageRoute(builder: (context) => page), ) as Data; // Here we have the data from the second screen data.counter = dataFromSecondPage.counter; data.dateTime = dataFromSecondPage.dateTime; data.text = dataFromSecondPage.text;}
Example 2: pass data from one provider model to anothe
GetIt locator = GetIt();locator.registerLazySingleton(() => Api());locator.registerLazySingleton(() => AuthenticationService());locator.registerLazySingleton(() => LoginModel());// Usagevar api = locator()