Comments (3)
Hi @RoxDevvv,
updateCollectionByIndex
now available in nylo_framework v5.20.9 🔥
Here's an example of how to use it.
await NyStorage.updateCollectionByIndex(2, (item) {
return 'New value';
}, key: 'my_storage_key');
// Example on a Model
await NyStorage.updateCollectionByIndex<User>(5, (User item) {
item.name = "User Updated";
item.email = "[email protected]";
return item;
}, key: 'my_storage_key');
You can run this example to demo it working too:
await NyStorage.delete('coins');
await NyStorage.addToCollection('coins', item: 0);
await NyStorage.addToCollection('coins', item: 1);
await NyStorage.addToCollection('coins', item: 2); // update this
await NyStorage.addToCollection('coins', item: 3);
List<dynamic> coins = await NyStorage.readCollection('coins');
print('before');
for (var coin in coins) {
print(coin);
}
// update
await NyStorage.updateCollectionByIndex(2, (item) {
return 200;
}, key: 'coins');
print('\n');
print('after');
coins = await NyStorage.readCollection('coins');
// before
for (var coin in coins) {
print(coin);
}
from nylo.
Hi @RoxDevvv,
This is a cool idea!
I'll work on it later today and hopefully push it up for tomorrow 🚀
from nylo.
maybe something builtin like that will be good
static Future updateInCollection<T>(int index, T newItem,
{required String key}) async {
List<T> collection = await readCollection<T>(key);
if (collection.isEmpty || index < 0 || index >= collection.length) return;
collection[index] = newItem;
await saveCollection<T>(key, collection);
}
from nylo.
Related Issues (20)
- widget.data() still have data HOT 8
- Checking auth token externally before visiting initial route HOT 1
- BaseOptions override does not work for request timeout HOT 2
- refreshToken function isn't invoked HOT 5
- Back gesture not working in nylo HOT 2
- new hidden bug HOT 1
- Docs missing HOT 1
- AuthRouteGuard not working when restart application HOT 1
- Hero image animations are not working HOT 2
- smooth page transition HOT 1
- Issue in Nystate or may be in nypage HOT 1
- validation not working when extends NyPage HOT 1
- build fails in nylo 5.11.0 HOT 2
- Not able to use nylo or not able to flutter pub get
- Build failed TextScaler not found error HOT 1
- LocalDataException when building new Nylo project HOT 15
- A guide for i implementing websocket on the framework HOT 1
- Auth Guard not working HOT 3
- how to enable other devices in the project
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nylo.