setNewRoutePath method Null safety
- FactBrowserRoutePath configuration
override
Called by the Router when the Router.routeInformationProvider reports that a new route has been pushed to the application by the operating system.
Consider using a SynchronousFuture if the result can be computed synchronously, so that the Router does not need to wait for the next microtask to schedule a build.
Implementation
@override
Future<void> setNewRoutePath(FactBrowserRoutePath configuration) async {
var db = DatabaseUtils();
if (configuration.isUnknown) {
_statement = null;
_show404 = true;
return;
}
// Download the statement before opening the detail page.
Statement? statement = await db.getStatement(configuration.statementID);
if (configuration.isDetailsPage) {
// check if statement exists here
if (statement == null) {
_show404 = true;
return;
}
// fetch statement from DB here
_statement = statement;
} else {
_statement = null;
}
_show404 = false;
}