2024-10-22 20:42:08 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
2024-10-29 17:37:12 +01:00
|
|
|
import 'package:hive_flutter/hive_flutter.dart';
|
2024-10-22 20:42:08 +02:00
|
|
|
import 'providers/todo_provider.dart';
|
|
|
|
import 'screens/todo_list_screen.dart';
|
2024-10-29 17:37:12 +01:00
|
|
|
import 'storage/hive_todo_storage.dart';
|
|
|
|
import 'storage/todo_storage.dart';
|
2024-10-22 20:42:08 +02:00
|
|
|
|
2024-10-29 17:37:12 +01:00
|
|
|
void main() async {
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
await Hive.initFlutter();
|
|
|
|
await Hive.openBox('todoBox');
|
|
|
|
|
|
|
|
//choose preferred storage type here
|
|
|
|
final storage = HiveToDoStorage();
|
|
|
|
|
|
|
|
runApp(ToDoApp(storage: storage));
|
2024-10-22 20:42:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class ToDoApp extends StatelessWidget {
|
2024-10-29 17:37:12 +01:00
|
|
|
final ToDoStorage storage;
|
|
|
|
|
|
|
|
const ToDoApp({required this.storage});
|
|
|
|
|
2024-10-22 20:42:08 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ChangeNotifierProvider(
|
2024-10-29 17:37:12 +01:00
|
|
|
create: (_) => ToDoProvider(storage),
|
2024-10-22 20:42:08 +02:00
|
|
|
child: MaterialApp(
|
2024-10-29 17:37:12 +01:00
|
|
|
title: 'To-Do List',
|
2024-10-22 20:42:08 +02:00
|
|
|
theme: ThemeData(
|
|
|
|
primarySwatch: Colors.green,
|
|
|
|
),
|
|
|
|
home: ToDoListScreen(),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|