routing_config_provider 1.0.0 routing_config_provider: ^1.0.0 copied to clipboard
A Flutter package project that gives the option to have a separate home page for web and mobile
import 'package:example/pages/routes_config.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:routing_config_provider/routing_config_provider.dart';
Future<void> main() async {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
final rc = RoutingConfigProvider().getWebOrMobileRoutingConfig(
webRoutingConfig,
mobileRoutingConfig,
);
final routingConfigVN = ValueNotifier<RoutingConfig>(rc);
GoRouter router = GoRouter.routingConfig(
initialLocation: '/home',
routingConfig: routingConfigVN,
errorBuilder: (context, state) {
return Material(
child: Text(
state.error?.message ?? 'Unknown go error',
textScaler: const TextScaler.linear(2.0),
),
);
},
);
return MaterialApp(
title: 'Routing Config Provider package demo',
home: MaterialApp.router(
routerConfig: router,
debugShowCheckedModeBanner: false,
title: 'Routing Config Provider package demo',
),
);
}
}