Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the Firebase core package in Flutter.
Flutter
import '[1]';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong Firebase package like firebase_auth instead of firebase_core.
Importing only Flutter material package without Firebase.
✗ Incorrect
You need to import 'package:firebase_core/firebase_core.dart' to initialize Firebase in Flutter.
2fill in blank
mediumComplete the code to initialize Firebase asynchronously in the main function.
Flutter
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await [1]();
runApp(MyApp());
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Calling runApp() before Firebase initialization.
Forgetting to mark main() as async.
✗ Incorrect
Firebase.initializeApp() initializes Firebase asynchronously before running the app.
3fill in blank
hardFix the error in the code to ensure Firebase initializes before the app runs.
Flutter
void main() async {
WidgetsFlutterBinding.ensureInitialized();
[1];
runApp(MyApp());
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not marking main() as async when awaiting.
Calling initializeApp without parentheses.
✗ Incorrect
You must await Firebase.initializeApp() inside an async main function to initialize Firebase properly.
4fill in blank
hardFill both blanks to import Firebase Auth and create an instance.
Flutter
import '[1]'; final auth = [2];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing firebase_core instead of firebase_auth for authentication.
Using Firebase.instance which does not exist.
✗ Incorrect
You import firebase_auth package and create an instance using FirebaseAuth.instance.
5fill in blank
hardFill all three blanks to add Firebase initialization in a Flutter widget.
Flutter
class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return FutureBuilder( future: [1](), builder: (context, snapshot) { if (snapshot.connectionState == [2]) { return [3]; } return CircularProgressIndicator(); }, ); } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using FutureBuilder to wait for Firebase initialization.
Checking wrong connection state.
Returning widget before Firebase is ready.
✗ Incorrect
Use Firebase.initializeApp() as future, check for ConnectionState.done, then show MaterialApp with home screen.