go_router_guards 2.0.0+2
go_router_guards: ^2.0.0+2 copied to clipboard
A flexible and extensible guard system for Go Router that allows you to chain multiple guards together for route protection.
// Copyright 2025 Tomás Sasovsky
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:simple_example/app_router.dart';
import 'package:simple_example/cubit/auth_cubit.dart';
import 'package:simple_example/cubit/user_cubit.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [
BlocProvider(create: (context) => AuthCubit()),
BlocProvider(create: (context) => UserCubit()),
],
child: MaterialApp.router(
title: 'Go Router Guards - Simple Example',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
routerConfig: router,
debugShowCheckedModeBanner: false,
),
);
}
}