FFAppState and persistence

Custom Code

I'm using the following (snippet) to remove items from my app state...

FFAppState().waypointCache.removeWhere((item) => item.regionName == regionName);

Which works fine while you're running the app, but does not persist the changes if you restart the app. So I switched to using this...

final cache = FFAppState().waypointCache;

for (int i = cache.length - 1; i >= 0; i--) {

if (cache[i].regionName == regionName) {

FFAppState().removeFromWaypointCache(cache[i]);

}}

Which explicitly calls the removeFromWaypointCache function.

My question really is, is there any way of using removeWhere and having that persist? Just so I don't have to loop through all the waypointCache.

Thanks in advance.

What have you tried so far?

I've attempted to use shared preferences directly to persist my changes like this...

final prefs = await SharedPreferences.getInstance();

final encodedCache = jsonEncode(FFAppState().waypointCache);

await prefs.setString('waypointCache', encodedCache);

with no luck

Did you check FlutterFlow's Documentation for this topic?
Yes
1
5 replies