cpd_2022_zi/lib/main.dart

48 lines
1.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:provider/provider.dart';
import 'package:smoke_cess_app/pages/main_page.dart';
import 'package:smoke_cess_app/providers/tasks_provider.dart';
import 'package:smoke_cess_app/services/notification_service.dart';
import 'package:timezone/data/latest.dart' as tz;
import 'globals.dart' as globals;
import 'providers/page_provider.dart';
import 'providers/settings_provider.dart';
void main() {
// to ensure all the widgets are initialized.
WidgetsFlutterBinding.ensureInitialized();
//init database
globals.databaseService;
tz.initializeTimeZones();
initializeDateFormatting('de');
NotificationService().initNotification();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
static const String _title = 'Smoking Cessation App';
@override
Widget build(BuildContext context) {
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(),
),
],
child: const MaterialApp(
title: _title,
home: MyHomePage(),
));
}
}