Created
July 31, 2024 09:43
-
-
Save iapicca/bf57078f045882a6c8088f3ae4f50b4c to your computer and use it in GitHub Desktop.
issue_152607
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:shared_preferences/shared_preferences.dart'; | |
final class SharedPreferencesKeys { | |
static const action = 'action'; | |
} | |
void main() async { | |
final prefsWithCache = await SharedPreferencesWithCache.create( | |
cacheOptions: const SharedPreferencesWithCacheOptions( | |
allowList: {SharedPreferencesKeys.action}, | |
), | |
); | |
await prefsWithCache.setStringList( | |
SharedPreferencesKeys.action, | |
const ['Earth', 'Moon', 'Sun'], | |
); | |
final actions = | |
prefsWithCache.getStringList(SharedPreferencesKeys.action) ?? []; | |
runApp( | |
MaterialApp( | |
home: Material( | |
child: Column( | |
children: [ | |
for (final action in actions) Text(action), | |
], | |
), | |
), | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment