2026-01-11 19:42:22 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
|
import 'package:go_router/go_router.dart';
|
2026-01-18 20:21:14 +08:00
|
|
|
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
|
|
|
|
|
import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
2026-01-11 19:42:22 +08:00
|
|
|
import 'package:maibu_satabot_v2/features/auth/presentation/bloc/auth_cubit.dart';
|
2026-01-18 20:21:14 +08:00
|
|
|
import 'package:maibu_satabot_v2/features/devices/presentation/bloc/devices_cubit.dart';
|
2026-01-11 19:42:22 +08:00
|
|
|
|
|
|
|
|
import 'core/di/injection.dart';
|
|
|
|
|
import 'features/auth/presentation/bloc/login_cubit.dart';
|
|
|
|
|
|
|
|
|
|
void main() async {
|
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
await init();
|
|
|
|
|
runApp(const MyApp());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
sl<AuthCubit>().appStarted();
|
|
|
|
|
return MultiBlocProvider(
|
|
|
|
|
providers: [
|
2026-01-18 20:21:14 +08:00
|
|
|
//BlocProvider<LoginBloc>(create: (_) => sl<LoginBloc>()),
|
|
|
|
|
BlocProvider<AppUserCubit>(create: (_) => sl<AppUserCubit>()),
|
2026-01-11 19:42:22 +08:00
|
|
|
BlocProvider<LoginCubit>(create: (_) => sl<LoginCubit>()),
|
2026-01-18 20:21:14 +08:00
|
|
|
BlocProvider<DevicesCubit>(
|
|
|
|
|
create: (_) =>
|
|
|
|
|
sl<DevicesCubit>()
|
|
|
|
|
..fetchAllDevices(sl<AppUserCubit>().state.user!.username),
|
|
|
|
|
),
|
2026-01-11 19:42:22 +08:00
|
|
|
],
|
2026-01-18 20:21:14 +08:00
|
|
|
child: MaterialApp.router(
|
|
|
|
|
title: 'Maibu Satabot',
|
|
|
|
|
theme: AppTheme.lightTheme,
|
|
|
|
|
routerConfig: sl<GoRouter>(),
|
|
|
|
|
),
|
2026-01-11 19:42:22 +08:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|