From 56f12e0730786c84d3f750976ce6548241820150 Mon Sep 17 00:00:00 2001 From: Jeremy Kescher Date: Wed, 29 Jan 2020 16:03:04 +0100 Subject: [PATCH 1/2] cleanup --- lib/serverlist.dart | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/lib/serverlist.dart b/lib/serverlist.dart index 7ed7570..bfc1f41 100644 --- a/lib/serverlist.dart +++ b/lib/serverlist.dart @@ -104,9 +104,7 @@ class _ServerListState extends State { if (_formKey.currentState.validate() && uri.text.isNotEmpty) { _formKey.currentState.save(); - _addServer( - serverName.text, - uri.text); + _addServer(serverName.text, uri.text); } }, ), @@ -209,7 +207,9 @@ class _ServerListState extends State { child: Align( alignment: Alignment.centerLeft, child: Text( - servers[index].displayName.isEmpty?servers[index].uri:servers[index].displayName, + servers[index].displayName.isEmpty + ? servers[index].uri + : servers[index].displayName, style: TextStyle(fontSize: 24), ), ), @@ -461,23 +461,27 @@ class _ServerListState extends State { servers = []; SharedPreferences.getInstance().then((prefs) { List serverStrings = prefs.getStringList('servers'); + Function(List strs) finalize = (List serverStrings) { + serverStrings.forEach((str) { + Server server = Server.fromPrefs( + PrefsServer.fromJson( + json.decode(str), + ), + ); + _updateServerStatus(server); + servers.add(server); + }); + setState(() { + serversInitialised = true; + }); + }; if (serverStrings == null) { prefs.setStringList('servers', []).then((_) { - serverStrings = prefs.getStringList('servers'); + finalize(prefs.getStringList('servers')); }); + } else { + finalize(serverStrings); } - serverStrings.forEach((str) { - Server server = Server.fromPrefs( - PrefsServer.fromJson( - json.decode(str), - ), - ); - _updateServerStatus(server); - servers.add(server); - }); - setState(() { - serversInitialised = true; - }); }); } -- 2.47.0 From 7e0f5fbe1a510b04349de4a89d08d96dadf320ee Mon Sep 17 00:00:00 2001 From: Jeremy Kescher Date: Wed, 29 Jan 2020 16:03:21 +0100 Subject: [PATCH 2/2] add permission for internet connectivity for release builds --- android/app/src/main/AndroidManifest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index c867e9a..62d0e9f 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -5,6 +5,7 @@ In most cases you can leave this as-is, but you if you want to provide additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> +