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 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"

View file

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