jeremy/0129/fix-release-builds #32
2 changed files with 22 additions and 17 deletions
|
@ -5,6 +5,7 @@
|
||||||
In most cases you can leave this as-is, but you if you want to provide
|
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
|
additional functionality it is fine to subclass or reimplement
|
||||||
FlutterApplication and put your custom class here. -->
|
FlutterApplication and put your custom class here. -->
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<application
|
<application
|
||||||
android:name="io.flutter.app.FlutterApplication"
|
android:name="io.flutter.app.FlutterApplication"
|
||||||
android:label="Server pinger"
|
android:label="Server pinger"
|
||||||
|
|
|
@ -104,9 +104,7 @@ class _ServerListState extends State<ServerList> {
|
||||||
if (_formKey.currentState.validate() &&
|
if (_formKey.currentState.validate() &&
|
||||||
uri.text.isNotEmpty) {
|
uri.text.isNotEmpty) {
|
||||||
_formKey.currentState.save();
|
_formKey.currentState.save();
|
||||||
_addServer(
|
_addServer(serverName.text, uri.text);
|
||||||
serverName.text,
|
|
||||||
uri.text);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -209,7 +207,9 @@ class _ServerListState extends State<ServerList> {
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: Text(
|
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),
|
style: TextStyle(fontSize: 24),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -461,23 +461,27 @@ class _ServerListState extends State<ServerList> {
|
||||||
servers = [];
|
servers = [];
|
||||||
SharedPreferences.getInstance().then((prefs) {
|
SharedPreferences.getInstance().then((prefs) {
|
||||||
List<String> serverStrings = prefs.getStringList('servers');
|
List<String> serverStrings = prefs.getStringList('servers');
|
||||||
|
Function(List<String> strs) finalize = (List<String> serverStrings) {
|
||||||
|
serverStrings.forEach((str) {
|
||||||
|
Server server = Server.fromPrefs(
|
||||||
|
PrefsServer.fromJson(
|
||||||
|
json.decode(str),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
_updateServerStatus(server);
|
||||||
|
servers.add(server);
|
||||||
|
});
|
||||||
|
setState(() {
|
||||||
|
serversInitialised = true;
|
||||||
|
});
|
||||||
|
};
|
||||||
if (serverStrings == null) {
|
if (serverStrings == null) {
|
||||||
prefs.setStringList('servers', []).then((_) {
|
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;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue