runApp function
To change the URL strategy from hash to path and remove that annoying # sign from the website's url. Add an Error Handler right at the start.
Implementation
// todo: flutterium
// import 'package:flutter_web_plugins/url_strategy.dart';
/// Add an Error Handler right at the start.
void runApp(
m.Widget app, {
FlutterExceptionHandler? onError,
bool? runZoneGuard,
}) {
// Ignore runZoneGuard gp
// Instantiate the app's error handler.
final handler = c.AppErrorHandler();
// Assign an error handler (Will be replaced after)
c.AppErrorHandler.set(handler: _RunWebAppErrorHandler(onError).handler);
// Here we set the URL strategy for our web app.
// It is safe to call this function when running on mobile or desktop as well.
// todo: flutterium
// if (urlStrategy is! PathUrlStrategy) {
// usePathUrlStrategy();
// }
// Run in a new zone with an error handler
if (runZoneGuard ?? false) {
// Catch any errors attempting to execute runApp();
runZonedGuarded(() {
m.runApp(app);
}, handler.runZonedError);
} else {
// Since Flutter 3.10, must now run in the 'root' zone
m.runApp(app);
}
}