feat(apps): add router auth protection
This commit is contained in:
+24
-9
@@ -1,21 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'core/theme/app_theme.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'core/di/injection.dart';
|
||||
import 'core/router/app_router.dart';
|
||||
import 'core/theme/app_theme.dart';
|
||||
import 'features/auth/presentation/bloc/auth_bloc.dart';
|
||||
import 'features/auth/presentation/bloc/auth_event.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const LinksyApp());
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await configureDependencies();
|
||||
|
||||
final authBloc = sl<AuthBloc>();
|
||||
authBloc.add(AuthStarted());
|
||||
|
||||
runApp(LinksyApp(authBloc: authBloc));
|
||||
}
|
||||
|
||||
class LinksyApp extends StatelessWidget {
|
||||
const LinksyApp({super.key});
|
||||
final AuthBloc authBloc;
|
||||
|
||||
const LinksyApp({super.key, required this.authBloc});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp.router(
|
||||
title: 'Linksy',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: AppTheme.light,
|
||||
routerConfig: appRouter,
|
||||
return BlocProvider<AuthBloc>.value(
|
||||
value: authBloc,
|
||||
child: MaterialApp.router(
|
||||
title: 'Linksy',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: AppTheme.light,
|
||||
routerConfig: createAppRouter(authBloc),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user