Last active
March 29, 2020 10:14
-
-
Save paulallies/b9d482077a671e9a07189ce6ac22317e to your computer and use it in GitHub Desktop.
New Main.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:hive/hive.dart'; | |
import 'package:path_provider/path_provider.dart'; | |
import 'package:todo/models/Contact.dart'; | |
import 'package:todo/views/HiveDemo.dart'; | |
void main() async { | |
WidgetsFlutterBinding.ensureInitialized(); | |
final appDocumentDirectory = await getApplicationDocumentsDirectory(); | |
Hive.init(appDocumentDirectory.path); | |
Hive.openBox("CONTACTS"); | |
Hive.registerAdapter(ContactAdapter(), 0); | |
runApp(MyApp()); | |
} | |
class MyApp extends StatefulWidget { | |
@override | |
_MyAppState createState() => _MyAppState(); | |
} | |
class _MyAppState extends State<MyApp> { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: HiveDemo(), | |
); | |
} | |
@override | |
void dispose() { | |
Hive.close(); | |
super.dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment