Initial Commit
This commit is contained in:
63
lib/main.dart
Normal file
63
lib/main.dart
Normal file
@@ -0,0 +1,63 @@
|
||||
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:proto_portal/pages/audit.dart';
|
||||
import 'package:proto_portal/pages/home.dart';
|
||||
import 'package:proto_portal/pages/login.dart';
|
||||
import 'package:proto_portal/scraper.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
|
||||
GtiAuth _auth = GtiAuth();
|
||||
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
await _auth.init();
|
||||
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider<GtiAuth>.value(
|
||||
value: _auth,
|
||||
),
|
||||
],
|
||||
child: ShadcnApp.router(
|
||||
title: 'Flutter Demo',
|
||||
theme: ThemeData(
|
||||
colorScheme: ColorSchemes.darkViolet,
|
||||
surfaceOpacity: 1
|
||||
),
|
||||
routerConfig: _router,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
GoRouter _router = GoRouter(
|
||||
initialLocation: "/station",
|
||||
redirect: (context, state) {
|
||||
|
||||
if (!_auth.isAuthenticated) {
|
||||
return LoginPage.route.path;
|
||||
}
|
||||
|
||||
if (state.uri.path == "/") {
|
||||
return StationPage.route.path;
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
routes: [
|
||||
LoginPage.route,
|
||||
StationPage.route,
|
||||
AuditPage.route,
|
||||
],
|
||||
);
|
||||
Reference in New Issue
Block a user