pharmacy_mobile/lib/main.dart
2025-01-22 16:23:32 +08:00

77 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:pharmacy_mobile/auth/auth_gate.dart';
// import 'package:pharmacy_mobile/pages/index_page.dart';
import 'package:pharmacy_mobile/pages/login_page.dart';
import 'package:go_router/go_router.dart';
import 'package:pharmacy_mobile/pages/main_page.dart';
import 'package:pharmacy_mobile/pages/register_page.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
// void main() {
// runApp(const MyApp());
// }
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
final supUrl = "https://lijihnvjlucyvxfhghqd.supabase.co";
final supAnonkey =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImxpamlobnZqbHVjeXZ4ZmhnaHFkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjQ1NjEyODYsImV4cCI6MjA0MDEzNzI4Nn0.N3_FLKm02OdprL9m3P0CzuV8kdbCrrJKaVdtgVR3PSk";
await Supabase.initialize(
url: supUrl,
anonKey: supAnonkey,
);
runApp(MyApp());
}
final supabase = Supabase.instance.client;
final _router = GoRouter(
initialLocation: '/',
routes: [
GoRoute(
name: 'index', // Optional, add name to your routes. Allows you navigate by name instead of path
path: '/',
builder: (context, state) => AuthGate(),
),
GoRoute(
name: 'login',
path: '/login',
builder: (context, state) => LoginPage(),
),
GoRoute(
name: 'register',
path: '/register',
builder: (context, state) => RegisterPage(),
),
GoRoute(
name: 'main',
path: '/main',
builder: (context, state) => MainPage(),
),
],
);
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp.router(
// initialRoute: '/',
// routes: {
// '/': (context) => const IndexPage(),
// '/login': (context) => const LoginPage(),
// },
// debugShowCheckedModeBanner: false,
// theme: ThemeData(
// colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
// useMaterial3: true,
// )
routerConfig: _router,
);
}
}