2023-02-14 11:18:53 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2023-02-27 02:27:42 +01:00
|
|
|
import 'package:provider/provider.dart';
|
2023-02-14 14:02:26 +01:00
|
|
|
import 'package:smoke_cess_app/pages/main_page.dart';
|
2023-03-02 19:31:47 +01:00
|
|
|
import 'package:smoke_cess_app/providers/tasks_provider.dart';
|
2023-03-03 15:00:48 +01:00
|
|
|
import 'package:smoke_cess_app/providers/timer_provider.dart';
|
2023-02-26 14:10:06 +01:00
|
|
|
import 'package:smoke_cess_app/services/notification_service.dart';
|
2023-02-25 08:35:46 +01:00
|
|
|
import 'package:timezone/data/latest.dart' as tz;
|
2023-02-26 16:17:57 +01:00
|
|
|
import 'globals.dart' as globals;
|
2023-03-03 13:13:33 +01:00
|
|
|
import 'providers/page_provider.dart';
|
2023-02-27 02:27:42 +01:00
|
|
|
import 'providers/settings_provider.dart';
|
2023-03-03 15:00:48 +01:00
|
|
|
import 'providers/workout_provider.dart';
|
2023-02-14 11:18:53 +01:00
|
|
|
|
2023-02-24 20:30:28 +01:00
|
|
|
void main() {
|
|
|
|
// to ensure all the widgets are initialized.
|
2023-02-22 01:28:01 +01:00
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
2023-02-25 18:55:03 +01:00
|
|
|
//init database
|
2023-02-26 16:17:57 +01:00
|
|
|
globals.databaseService;
|
2023-02-25 08:35:46 +01:00
|
|
|
tz.initializeTimeZones();
|
2023-02-24 20:30:28 +01:00
|
|
|
NotificationService().initNotification();
|
2023-02-22 01:28:01 +01:00
|
|
|
runApp(const MyApp());
|
|
|
|
}
|
2023-02-14 11:18:53 +01:00
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
2023-02-14 12:57:06 +01:00
|
|
|
static const String _title = 'Smoking Cessation App';
|
2023-02-14 11:18:53 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-03-03 15:00:48 +01:00
|
|
|
TimerProvider timerProvider = TimerProvider();
|
2023-03-03 16:37:08 +01:00
|
|
|
return MultiProvider(
|
|
|
|
providers: [
|
|
|
|
ChangeNotifierProvider(create: (context) => SettingsProvider()),
|
|
|
|
ChangeNotifierProxyProvider<SettingsProvider, TasksProvider>(
|
|
|
|
create: (context) => TasksProvider(null),
|
|
|
|
update: (context, value, TasksProvider? previous) =>
|
|
|
|
TasksProvider(value),
|
|
|
|
),
|
|
|
|
ChangeNotifierProvider(
|
|
|
|
create: (context) => PageProvider(),
|
|
|
|
),
|
|
|
|
ChangeNotifierProvider(create: (context) => timerProvider),
|
|
|
|
ChangeNotifierProvider(
|
|
|
|
create: (context) => WorkoutProvider(timerProvider)),
|
|
|
|
],
|
|
|
|
child: const MaterialApp(
|
|
|
|
title: _title,
|
|
|
|
home: MyHomePage(),
|
2023-02-27 02:27:42 +01:00
|
|
|
));
|
2023-02-14 11:18:53 +01:00
|
|
|
}
|
|
|
|
}
|