useless clean up using switch

master
fuwa 4 years ago
parent c6d6f2984f
commit b02b5f8bb3

@ -58,10 +58,16 @@ Map<String, dynamic> getConnectionView(Map<String, dynamic> x) {
final _formattedConn = _filteredConn.map
(
(k, v) {
if (k == 'connection_id') {
switch (k) {
case 'connection_id': {
return MapEntry(k, trimHash(v));
}
case 'live_time': {
final _duration = Duration(seconds: v);
format(Duration d) => d.toString().split('.').first.padLeft(8, "0");
return MapEntry(k, format(_duration));
}
default: {
const speedField =
[
'avg_download',
@ -72,17 +78,12 @@ Map<String, dynamic> getConnectionView(Map<String, dynamic> x) {
if (speedField.contains(k)) {
return MapEntry(k, '${v} kB/s');
}
else if (k == 'live_time') {
final _duration = Duration(seconds: v);
format(Duration d) => d.toString().split('.').first.padLeft(8, "0");
return MapEntry(k, format(_duration));
}
else {
return MapEntry(k, v);
}
}
}
}
);
final List<String> keys =
@ -171,10 +172,18 @@ Map<String, dynamic> getInfoView(Map<String, dynamic> x) {
final _formattedInfo = _ammendedInfo.map
(
(k, v) {
if (k == 'top_block_hash') {
switch (k) {
case 'top_block_hash': {
return MapEntry(k, trimHash(v));
}
case 'start_time': {
final _receive_time = DateTime.fromMillisecondsSinceEpoch(v * 1000);
final _diff = DateTime.now().difference(_receive_time);
format(Duration d) => d.toString().split('.').first.padLeft(8, "0");
return MapEntry('uptime', format(_diff));
}
default: {
const sizeField =
[
'block_size_limit',
@ -192,19 +201,12 @@ Map<String, dynamic> getInfoView(Map<String, dynamic> x) {
final formatter = NumberFormat.compact();
return MapEntry(k, formatter.format(v));
}
else if (k == 'start_time') {
final _receive_time = DateTime.fromMillisecondsSinceEpoch(v * 1000);
final _diff = DateTime.now().difference(_receive_time);
format(Duration d) => d.toString().split('.').first.padLeft(8, "0");
return MapEntry('uptime', format(_diff));
}
else {
return MapEntry(k, v);
}
}
}
}
);
final _cleanedUpInfo = _formattedInfo.map

Loading…
Cancel
Save