Home > Net >  Null check operator used on a null value creating path in flutter
Null check operator used on a null value creating path in flutter

Time:02-28

When i am creating a path for hive database it's showing an error. "Null check operator used on a null value"

void main() async{
  Directory appDocDir = await getApplicationDocumentsDirectory();


  runApp(const EntryWidget());
}

CodePudding user response:

You should wait for the widget to initialize as it must be searching before that and getting null value somewhere in the library. Try using below line of code before the await command.

   WidgetsFlutterBinding.ensureInitialized();
   Directory appDir = await getApplicationDocumentsDirectory();
  • Related