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