Issue
Hi guys👋🏻 I have a problem while working with pat_provider.
Error:
Unhandled Exception: Null check operator used on a null value
Code:
void main() async {
final appDocumentDirectory =
await path_provider.getApplicationDocumentsDirectory();
Hive.init(appDocumentDirectory.path);
runApp(MyApp());
}
For more, I am using the non-nullsafety
app, Right now I want to take the path to hive. what would you advise in such a case. or should I downgrade the path_provider version?
Solution
Resolved! I was doing hive the old way. The program worked when I called Hive.initFlutter(), not Hive.init(). By the way,
import 'package: hive_flutter / hive_flutter.dart';
and
import 'package: hive / hive.dart';
Don't forget to import both,
Current code:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Hive.initFlutter();
runApp(CoozinCustomerApp());
}
Answered By - Rustam Usmanov
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.