2024-09-22 06:41:32 +00:00
|
|
|
// import 'package:alice/alice.dart';
|
2020-07-28 18:11:47 +00:00
|
|
|
import 'package:dio/dio.dart';
|
2019-10-27 10:18:28 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2020-07-28 18:11:47 +00:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
import 'package:geosmart/config.dart';
|
|
|
|
import 'package:geosmart/page/map_page.dart';
|
|
|
|
import 'package:geosmart/page/setting_page.dart';
|
|
|
|
import 'package:geosmart/page/startup_page.dart';
|
2019-10-27 10:18:28 +00:00
|
|
|
|
2020-07-28 18:11:47 +00:00
|
|
|
import 'bloc/bloc.dart';
|
|
|
|
|
|
|
|
void main() async {
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
2024-09-22 06:41:32 +00:00
|
|
|
// final Alice alice = Alice(showNotification: Config.showInterceptor);
|
2020-07-28 18:11:47 +00:00
|
|
|
final Dio dio = Dio();
|
2024-09-22 06:41:32 +00:00
|
|
|
// dio.interceptors.add(alice.getDioInterceptor());
|
2020-07-28 18:11:47 +00:00
|
|
|
|
|
|
|
runApp(
|
|
|
|
MultiBlocProvider(
|
|
|
|
providers: [
|
|
|
|
BlocProvider<AuthenticationBloc>(
|
|
|
|
create: (context) => AuthenticationBloc(
|
2024-09-22 06:41:32 +00:00
|
|
|
// alice: alice,
|
2020-07-28 18:11:47 +00:00
|
|
|
dio: dio,
|
|
|
|
)..add(AuthenticationStarted()),
|
|
|
|
),
|
|
|
|
BlocProvider<SettingBloc>(
|
|
|
|
create: (context) => SettingBloc(
|
|
|
|
authenticationBloc: BlocProvider.of<AuthenticationBloc>(
|
|
|
|
context,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
BlocProvider<PositionBloc>(
|
|
|
|
create: (context) => PositionBloc(
|
|
|
|
authenticationBloc: BlocProvider.of<AuthenticationBloc>(
|
|
|
|
context,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
child: MyApp(),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2019-10-27 10:18:28 +00:00
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MaterialApp(
|
2019-10-27 10:19:53 +00:00
|
|
|
title: 'Geo Smart App',
|
2024-09-22 06:41:32 +00:00
|
|
|
// navigatorKey: BlocProvider.of<AuthenticationBloc>(
|
|
|
|
// context,
|
|
|
|
// ).alice.getNavigatorKey(),
|
2019-10-27 10:18:28 +00:00
|
|
|
theme: ThemeData(
|
|
|
|
primarySwatch: Colors.blue,
|
|
|
|
),
|
2020-07-28 18:11:47 +00:00
|
|
|
home: BlocBuilder<AuthenticationBloc, AuthenticationState>(
|
|
|
|
builder: (ctx, state) {
|
|
|
|
if (state is AuthenticationSuccess) {
|
|
|
|
return MapPage();
|
|
|
|
}
|
|
|
|
if (state is AuthenticationFailed) {
|
|
|
|
return SettingPage();
|
|
|
|
}
|
|
|
|
return StartupPage();
|
|
|
|
},
|
|
|
|
),
|
2019-10-27 10:18:28 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|