Complete the code to import the SharedPreferences package.
import 'package:[1]/shared_preferences.dart';
The correct package name to import SharedPreferences is shared_preferences.
Complete the code to get an instance of SharedPreferences asynchronously.
final prefs = await SharedPreferences.[1]();The method to get SharedPreferences instance is getInstance().
Fix the error in saving a string value with key 'username'.
await prefs.[1]('username', 'Alice');
The correct method to save a string is setString.
Fill both blanks to read a string value for key 'username' with a default fallback.
String username = prefs.[1]('username') ?? [2];
Use getString to read the string and provide a default like 'Guest' if null.
Fill all three blanks to remove a key and check if it was removed successfully.
bool removed = await prefs.[1]('username'); if (removed) { print('[2] was removed'); } else { print('[3] not found'); }
The method to remove a key is remove. The key name is username. The message uses 'Key' to indicate the key was not found.
