removed the try catch again #15
1 changed files with 41 additions and 41 deletions
|
@ -155,38 +155,41 @@ class _ServerListState extends State<ServerList> {
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Text('Adding a server'),
|
title: Text('Adding a server'),
|
||||||
content: SingleChildScrollView(child: Form(
|
content: SingleChildScrollView(
|
||||||
key: _formKey,
|
child: Form(
|
||||||
child: Column(
|
key: _formKey,
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Column(
|
||||||
children: <Widget>[
|
mainAxisSize: MainAxisSize.min,
|
||||||
TextFormField(
|
children: <Widget>[
|
||||||
controller: uri,
|
TextFormField(
|
||||||
),
|
controller: uri,
|
||||||
TextFormField(
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: 'Custom Name', hintText: 'Optional'),
|
|
||||||
controller: servername,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: RaisedButton(
|
|
||||||
child: Text("Add"),
|
|
||||||
onPressed: () {
|
|
||||||
if (_formKey.currentState.validate()&&uri.text.isNotEmpty) {
|
|
||||||
_formKey.currentState.save();
|
|
||||||
Server server = Server(uri.text, uri.text);
|
|
||||||
servers.add(server);
|
|
||||||
_updateServerStatus(server);
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
)
|
TextFormField(
|
||||||
],
|
decoration: InputDecoration(
|
||||||
|
labelText: 'Custom Name', hintText: 'Optional'),
|
||||||
|
controller: servername,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: RaisedButton(
|
||||||
|
child: Text("Add"),
|
||||||
|
onPressed: () {
|
||||||
|
if (_formKey.currentState.validate() &&
|
||||||
|
uri.text.isNotEmpty) {
|
||||||
|
_formKey.currentState.save();
|
||||||
|
Server server = Server(uri.text, uri.text);
|
||||||
|
servers.add(server);
|
||||||
|
_updateServerStatus(server);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -220,7 +223,10 @@ class _ServerListState extends State<ServerList> {
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(top: BorderSide(color: Colors.grey))),
|
border: Border(top: BorderSide(color: Colors.grey))),
|
||||||
),
|
),
|
||||||
Text(servers[index].uri,textAlign: TextAlign.left,),
|
Text(
|
||||||
|
servers[index].uri,
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -375,17 +381,11 @@ class _ServerListState extends State<ServerList> {
|
||||||
var location = uri.path;
|
var location = uri.path;
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
Response response;
|
Response response = await HttpUtils.getForFullResponse(
|
||||||
try {
|
scheme + "://" + host,
|
||||||
response = await HttpUtils.getForFullResponse(
|
headers: <String, String>{"Location": location})
|
||||||
scheme + "://" + host,
|
.timeout(new Duration(seconds: 3));
|
||||||
headers: <String, String>{"Location": location})
|
|
||||||
.timeout(new Duration(seconds: 3));
|
|
||||||
} catch (error){
|
|
||||||
if (error == TimeoutException)
|
|
||||||
return ServerStatus.timeout;
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
if (response.statusCode > 199 && response.statusCode < 300) {
|
if (response.statusCode > 199 && response.statusCode < 300) {
|
||||||
return ServerStatus.ok;
|
return ServerStatus.ok;
|
||||||
} else if (response.statusCode == HttpStatus.movedPermanently ||
|
} else if (response.statusCode == HttpStatus.movedPermanently ||
|
||||||
|
|
Loading…
Reference in a new issue