Last active
December 25, 2021 20:40
-
-
Save reasje/b5919d2476e1778a2bc208338b8d9f16 to your computer and use it in GitHub Desktop.
hive_tut main function
This file contains 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/foundation.dart' show kIsWeb; | |
import 'package:flutter/material.dart'; | |
import 'package:hive/hive.dart'; | |
import 'package:hive_flutter/hive_flutter.dart'; | |
import 'package:path_provider/path_provider.dart'; | |
String someRandomName = "someRandomName"; | |
void main() async { | |
WidgetsFlutterBinding.ensureInitialized(); | |
if (kIsWeb) { | |
Hive.initFlutter(); | |
} else { | |
// getting the path of the document in the device for accesing the database | |
final document = await getApplicationDocumentsDirectory(); | |
Hive.init(document.path); | |
} | |
await Hive.openBox<String>(someRandomName); | |
runApp(MyApp()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment