Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

flutter how to load a future function in main function

Add this:

WidgetsFlutterBinding.ensureInitialized();
Before every single future functions in your main function

Example:
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await FutureFunction();

  runApp(
    MaterialApp(
      home: MyApp(),
    ),
  );
}
 
PREVIOUS NEXT
Tagged: #flutter #load #future #function #main #function
ADD COMMENT
Topic
Name
9+8 =