dynamic_shared_preferences 0.0.1 copy "dynamic_shared_preferences: ^0.0.1" to clipboard
dynamic_shared_preferences: ^0.0.1 copied to clipboard

A new Flutter package to save and retrieve model objects using shared_preferences plugin

example/example.md

import 'package:dynamic_shared_preferences/dynamic_shared_preferences.dart';
void main(){
// Assign model to the instance
  DynamicSharedPreferences gen = DynamicSharedPreferences();
// `response` is from Rest Api parsing
  final parsed = jsonDecode(response.body);

  fetchedDataModel = parsed
            .map<DataModel>((dynamic json) => DataModel.fromJson(json))
            .toList() as List<DataModel>;

  gen.save(key: 'keyName', value: 'fetchedDataModel', isModel: true);
}
void main(){
// Get values from model
  DynamicSharedPreferences gen = DynamicSharedPreferences();
  gen.get(key: 'keyName', isModel: true).then((onValue) {
    fetchedData = onValue
          .map<DataModel>((dynamic json) => DataModel.fromJson(json))
          .toList() as List<DataModel>;
      
    print("Saved data: " + fetchedData[0].keyName.toString());
    });
}
void main(){
  //Normal shared preference operations with String, Integer, Double, Boolean, List<String> types
  DynamicSharedPreferences gen = DynamicSharedPreferences();
  gen.save(key: 'keyName', value: 'keyValue', isModel: false);
  gen.get(key: 'keyName', isModel: false);
  gen.clear();
  gen.remove(key: 'keyName');
}
1
likes
140
points
24
downloads

Publisher

verified publisherkoushiksaha.in

Weekly Downloads

A new Flutter package to save and retrieve model objects using shared_preferences plugin

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, shared_preferences

More

Packages that depend on dynamic_shared_preferences