Many work in navegation, map, drawer, about, slider
This commit is contained in:
parent
662deb3086
commit
574c1afc33
15 changed files with 446 additions and 168 deletions
|
|
@ -1,24 +1,36 @@
|
|||
import 'dart:convert';
|
||||
import 'basicLocation.dart';
|
||||
import 'globals.dart' as globals;
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
final String locationKey = 'yourlocations';
|
||||
|
||||
void loadYourLocations(prefs) {
|
||||
List<String> yourLocations = prefs.getStringList(locationKey);
|
||||
if (yourLocations == null) {
|
||||
yourLocations = [];
|
||||
persistYourLocations(prefs);
|
||||
}
|
||||
yourLocations.forEach((locationString) {
|
||||
Map locationMap = json.decode(locationString);
|
||||
globals.yourLocations.add(BasicLocation.fromJson(locationMap));
|
||||
void loadYourLocations() {
|
||||
globals.prefs.then((prefs) {
|
||||
loadYourLocationsWithPrefs(prefs);
|
||||
});
|
||||
}
|
||||
|
||||
persistYourLocations(prefs) {
|
||||
List<String> yourLocationsAsString = [];
|
||||
globals.yourLocations.forEach((location) {
|
||||
yourLocationsAsString.add(json.encode(location.toJson()));
|
||||
persistYourLocations() {
|
||||
globals.prefs.then((prefs) {
|
||||
List<String> yourLocationsAsString = [];
|
||||
globals.yourLocations.forEach((location) {
|
||||
yourLocationsAsString.add(json.encode(location.toJson()));
|
||||
});
|
||||
prefs.setStringList(locationKey, yourLocationsAsString);
|
||||
});
|
||||
prefs.setStringList(locationKey, yourLocationsAsString);
|
||||
}
|
||||
}
|
||||
|
||||
void loadYourLocationsWithPrefs(SharedPreferences prefs) {
|
||||
globals.prefs.then((prefs) {
|
||||
List<String> yourLocations = prefs.getStringList(locationKey);
|
||||
if (yourLocations == null) {
|
||||
yourLocations = [];
|
||||
persistYourLocations();
|
||||
}
|
||||
yourLocations.forEach((locationString) {
|
||||
Map locationMap = json.decode(locationString);
|
||||
globals.yourLocations.add(BasicLocation.fromJson(locationMap));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue