jeremy/0129/fix-release-builds #32

Merged
Jeremy Kescher merged 2 commits from jeremy/0129/fix-release-builds into master 2020-01-29 15:05:12 +00:00
2 changed files with 22 additions and 17 deletions

View file

@ -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. -->
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Server pinger"

View file

@ -104,9 +104,7 @@ class _ServerListState extends State<ServerList> {
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<ServerList> {
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,11 +461,7 @@ class _ServerListState extends State<ServerList> {
servers = [];
SharedPreferences.getInstance().then((prefs) {
List<String> serverStrings = prefs.getStringList('servers');
if (serverStrings == null) {
prefs.setStringList('servers', []).then((_) {
serverStrings = prefs.getStringList('servers');
});
}
Function(List<String> strs) finalize = (List<String> serverStrings) {
serverStrings.forEach((str) {
Server server = Server.fromPrefs(
PrefsServer.fromJson(
@ -478,6 +474,14 @@ class _ServerListState extends State<ServerList> {
setState(() {
serversInitialised = true;
});
};
if (serverStrings == null) {
prefs.setStringList('servers', []).then((_) {
finalize(prefs.getStringList('servers'));
});
} else {
finalize(serverStrings);
}
});
}