Database calls are made in the following files:
And soon we will need to make calls for the messaging functionality of the app when we build that. I think it would be beneficial to move all our database access to a separate file.
Another somewhat related issue: the map page is wrapped in a StreamBuilder2
widget listening to the Lost and Found streams. Then when the user switches to the list page, the current data is passed into that page from the map page. This seems like a bad way to do it since one page is in charge of doing the updates. Why don't we wrap the current page in main.dart MaterialApp widget in the StreamBuilder widget instead? Then we can pass the data to whatever page wants it.
To illustrate my point -
child: MaterialApp(
debugShowCheckedModeBanner: false,
routes: {
'loginPage': (context) => const LoginPage(),
'mapPage': (context) => const MapPage(), // this page has a parent StreamBuilder in the build method
'/': (context) => const Wrapper()
},
initialRoute: '/',
theme: AppTheme.getTheme(),
themeMode: themeManager.themeMode));
Instead I suggest we do this -
child: MaterialApp(
debugShowCheckedModeBanner: false,
routes: {
'loginPage': (context) => StreamBuilderWrapper('loginPage'),
'mapPage': (context) => StreamBuilderWrapper('mapPage'),
'/': (context) => const Wrapper()
},
initialRoute: '/',
theme: AppTheme.getTheme(),
themeMode: themeManager.themeMode));
Where StreamBuilderWrapper
is defined in the database operations file and we simply pass the current data into the correct page based on the parameter, 'loginPage' or 'mapPage' (and in the future chat pages)