routing_config_provider 1.0.0 copy "routing_config_provider: ^1.0.0" to clipboard
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

example/lib/main.dart

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',
      ),
    );
  }
}
0
likes
130
points
96
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package project that gives the option to have a separate home page for web and mobile

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, go_router

More

Packages that depend on routing_config_provider