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(someRandomName); runApp(MyApp()); }