Files
Tanami_App/lib/main.dart

99 lines
2.9 KiB
Dart
Raw Normal View History

2024-05-24 12:32:19 +05:30
import 'package:flutter/material.dart';
2024-05-24 19:32:53 +05:30
import 'package:flutter/services.dart';
2024-05-29 13:21:55 +05:30
import 'package:flutter_bloc/flutter_bloc.dart';
2024-05-24 19:32:53 +05:30
import 'package:flutter_screenutil/flutter_screenutil.dart';
2024-07-03 18:46:18 +05:30
import 'package:local_auth/local_auth.dart';
import 'package:statsfl/statsfl.dart';
2024-05-24 19:32:53 +05:30
import 'core/routes/routes.dart';
2024-07-03 18:46:18 +05:30
import 'core/utils/biometric/biometric_bloc.dart';
import 'core/utils/biometric/biometric_event.dart';
2024-05-24 19:32:53 +05:30
import 'core/utils/connectivity/network_connectivity.dart';
2024-05-29 13:21:55 +05:30
import 'features/countrySelection/presentation/bloc/choose_country_bloc.dart';
import 'shared/components/bloc/bottom_nav_bar/bottom_navigation_bloc.dart';
2024-05-24 19:32:53 +05:30
/* CREATED BY - JAYESH JAIN
DATE - 24-05-2024
*/
/// The main function that runs the application.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
2024-06-12 12:38:31 +05:30
// FlutterError.onError = (FlutterErrorDetails details) {
// FlutterError.dumpErrorToConsole(details);
// runApp(CustomErrorWidget(
// errorMessage: details.toString(),
// ));
// };
2024-05-24 19:32:53 +05:30
// Set the preferred orientations of the device.
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
2024-07-03 18:46:18 +05:30
]).then((value) => runApp(StatsFl(
isEnabled: true, //Toggle on/off
width: 200, //Set size
height: 50, //
maxFps: 60, // Support custom FPS target (default is 60)
showText: true, // Hide text label
sampleTime: .5, //Interval between fps calculations, in seconds.
totalTime: 15, //Total length of timeline, in seconds.
align: Alignment.center, //Alignment of statsbox
child: const MyApp())));
2024-05-24 12:32:19 +05:30
}
2024-05-24 19:32:53 +05:30
class MyApp extends StatefulWidget {
2024-05-24 12:32:19 +05:30
const MyApp({super.key});
@override
2024-05-24 19:32:53 +05:30
State<MyApp> createState() => _MyAppState();
2024-05-24 12:32:19 +05:30
}
2024-05-24 19:32:53 +05:30
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
final NetworkConnectivity _networkConnectivity =
2024-05-28 16:35:33 +05:30
NetworkConnectivity(onStatusChange: (_) {});
2024-05-24 12:32:19 +05:30
@override
2024-05-24 19:32:53 +05:30
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
2024-05-24 12:32:19 +05:30
2024-05-24 19:32:53 +05:30
// Initialize the NetworkConnectivity instance.
_networkConnectivity.initialize();
}
2024-05-24 12:32:19 +05:30
2024-05-24 19:32:53 +05:30
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
_networkConnectivity.dispose();
super.dispose();
2024-05-24 12:32:19 +05:30
}
@override
Widget build(BuildContext context) {
2024-05-29 13:21:55 +05:30
return MultiBlocProvider(
providers: [
BlocProvider(
create: (context) => RadioBloc(),
),
BlocProvider(
create: (_) => BottomNavigationBloc(),
2024-07-03 18:46:18 +05:30
),
BlocProvider(
create: (_) =>
BiometricBloc(LocalAuthentication())..add(CheckBiometricEvent()),
)
2024-05-29 13:21:55 +05:30
],
child: ScreenUtilInit(
builder: (BuildContext context, Widget? child) => MaterialApp.router(
title: 'Tanami Capital',
theme: ThemeData(
2024-06-12 12:02:46 +05:30
useMaterial3: true,
),
2024-05-29 13:21:55 +05:30
debugShowCheckedModeBanner: false,
routerConfig: goRouter,
2024-05-24 12:32:19 +05:30
),
2024-05-29 13:21:55 +05:30
designSize: const Size(390, 844),
2024-05-24 12:32:19 +05:30
),
);
}
}