All LocalStorage

This commit is contained in:
Aaron Fischer 2019-07-25 13:37:31 +02:00
parent 5068592189
commit 90587cd30a
5 changed files with 40 additions and 16 deletions

View file

@ -4,10 +4,13 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:preferences/preferences.dart';
import 'package:toolheim/data/warband_roster.dart';
import 'package:localstorage/localstorage.dart';
import 'package:yaml/yaml.dart';
import 'package:toolheim/data/warband_roster.dart';
class GitHubAdapter extends ChangeNotifier {
final LocalStorage storage = new LocalStorage('rosters');
List<String> _syncErrors = new List<String>();
DateTime _lastSync;
@ -165,6 +168,8 @@ class GitHubAdapter extends ChangeNotifier {
roster.lastSyncVersion = roster.currentVersion;
_rosters.add(roster);
//https://github.com/lesnitsky/flutter_localstorage/blob/master/example/lib/main.dart
storage.setItem(player['player'], roster);
notifyListeners();
}
} catch (e) {
@ -183,6 +188,7 @@ class GitHubAdapter extends ChangeNotifier {
_lastSync = DateTime.now();
_syncinProgress = false;
storage.setItem('lastSync', _lastSync);
notifyListeners();
}

View file

@ -1,6 +1,9 @@
import 'package:flutter/material.dart';
import 'package:preferences/preferences.dart';
// TODO: Add the search button here
// TODO: Display possible errors here
class SettingsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {

View file

@ -96,13 +96,13 @@ class WarbandDrawerWidget extends StatelessWidget {
// Show some stats for the own warband
tiles.add(UserAccountsDrawerHeader(
otherAccountsPictures: <Widget>[
IconButton(
icon: Icon(Icons.refresh),
color: Colors.white,
highlightColor: Colors.brown,
tooltip: 'Refresh warbands',
onPressed: github.update,
),
//IconButton(
// icon: Icon(Icons.refresh),
// color: Colors.white,
// highlightColor: Colors.brown,
// tooltip: 'Refresh warbands',
// onPressed: github.update,
//),
IconButton(
icon: Icon(Icons.search),
color: Colors.white,

View file

@ -7,7 +7,7 @@ packages:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "0.36.4"
version: "0.37.0"
args:
dependency: transitive
description:
@ -56,7 +56,7 @@ packages:
name: build_daemon
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "2.0.0"
build_resolvers:
dependency: transitive
description:
@ -70,7 +70,7 @@ packages:
name: build_runner
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.1"
version: "1.6.2"
build_runner_core:
dependency: transitive
description:
@ -178,7 +178,7 @@ packages:
name: front_end
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.19"
version: "0.1.20"
glob:
dependency: transitive
description:
@ -248,14 +248,21 @@ packages:
name: json_serializable
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.1.0"
kernel:
dependency: transitive
description:
name: kernel
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.19"
version: "0.3.20"
localstorage:
dependency: "direct main"
description:
name: localstorage
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
logging:
dependency: transitive
description:
@ -305,6 +312,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
path_provider:
dependency: transitive
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
pedantic:
dependency: transitive
description:
@ -360,7 +374,7 @@ packages:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.3+2"
version: "0.5.3+4"
shelf:
dependency: transitive
description:
@ -386,7 +400,7 @@ packages:
name: source_gen
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.4+2"
version: "0.9.4+3"
source_span:
dependency: transitive
description:

View file

@ -26,6 +26,7 @@ dependencies:
badges:
shared_preferences:
preferences:
localstorage:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.