How can I send "records" variable to another screen?
CodePudding user response:
if you have a SecondScreen()
you can pass data to it when you navigate to it from it's constructor like this
class SecondScreen extendsS StatelessWidget {
SecondScreen(this.gotRecords);
final Box? gotRecords;
/* more code*/
}
and now when you try to navigate pass that records
in that constructor like this :
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const SecondScreen(gotRecords:records)),
);
and from that screen you can use it.
CodePudding user response:
another solution is to just call the box wherever you want by its name
I see that your Hive box is called Details, so wherever you want to use that same box, just call simply from any screen in your app:
Box? records = Hive.box("Details");