Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the Firebase Storage package in Flutter.
Flutter
import 'package:firebase_[1]/firebase_storage.dart';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'firebase_auth' instead of 'firebase_storage'.
Using 'firebase_core' which is for core Firebase features.
✗ Incorrect
The Firebase Storage package is imported with 'firebase_storage'.
2fill in blank
mediumComplete the code to create a reference to the root of Firebase Storage.
Flutter
final storageRef = FirebaseStorage.instance.[1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'reference' instead of 'ref'.
Using 'getReference' which is not a valid method.
✗ Incorrect
The method to get a reference is 'ref()'.
3fill in blank
hardFix the error in the code to upload a file to Firebase Storage.
Flutter
await storageRef.child('uploads/file.txt').[1](file);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'uploadFile' which does not exist.
Using 'storeFile' which is not a valid method.
✗ Incorrect
The correct method to upload a file is 'putFile'.
4fill in blank
hardFill in the blank to get the download URL of an uploaded file.
Flutter
String url = await storageRef.child('uploads/file.txt').[1]();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'downloadURL()' which is not a method.
Using 'getUrl()' which does not exist.
✗ Incorrect
The method to get the download URL is 'getDownloadURL()'.
5fill in blank
hardFill all three blanks to delete a file from Firebase Storage and handle errors.
Flutter
try { await storageRef.child('uploads/file.txt').[1](); } catch (e) { print('Error: ' + e.[2]); } finally { print('File [3] deleted'); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'remove()' instead of 'delete()'.
Accessing error with 'toString()' instead of 'message'.
Missing the word 'successfully' in the print statement.
✗ Incorrect
The method to delete is 'delete()'. The error message is accessed by 'message'. The print statement confirms the file was 'successfully' deleted.