use final when possible

pull/2/head
fuwa 5 years ago
parent a6e7271117
commit 2891890ff5

@ -45,18 +45,17 @@ Future<http.Response> rpcHTTP(String method) async {
} }
); );
var response;
try { try {
response = await http.post final response = await http.post
( url, ( url,
body: body body: body
); );
return response;
} }
catch (e) { catch (e) {
// print(e); log.warning(e);
return null;
} }
return response;
} }
Future<dynamic> rpc(String method, {String field}) async { Future<dynamic> rpc(String method, {String field}) async {

@ -32,17 +32,16 @@ import '../../logging.dart';
Future<http.Response> rpc2(String method) async { Future<http.Response> rpc2(String method) async {
final url = 'http://${config.host}:${config.c.port}/${method}'; final url = 'http://${config.host}:${config.c.port}/${method}';
var response;
try { try {
response = await http.post final response = await http.post
( url, ( url,
); );
return response;
} }
catch (e) { catch (e) {
log.warning(e); log.warning(e);
return null;
} }
return response;
} }
Future<String> rpc2String(String method, {String field}) async { Future<String> rpc2String(String method, {String field}) async {

@ -60,7 +60,7 @@ Stream<String> runBinary (String name) async* {
log.info('args: ' + args.toString()); log.info('args: ' + args.toString());
final outputProcess = await Process.start(newPath, args); final outputProcess = await Process.start(newPath, args);
await for (var line in outputProcess.stdout.transform(utf8.decoder)) { await for (final line in outputProcess.stdout.transform(utf8.decoder)) {
yield line; yield line;
} }

@ -122,7 +122,7 @@ class LoadingState extends HookedState {
Future<void> load() async { Future<void> load() async {
log.fine("Loading next"); log.fine("Loading next");
await for (var line in loadingProgress) { await for (final line in loadingProgress) {
// append(line); // append(line);
log.info(line); log.info(line);
} }
@ -156,7 +156,7 @@ class SyncingState extends HookedState {
log.fine("Syncing next"); log.fine("Syncing next");
Future<void> printStdout() async { Future<void> printStdout() async {
await for (var line in processOutput) { await for (final line in processOutput) {
if (synced) break; if (synced) break;
log.finest('syncing: print stdout loop'); log.finest('syncing: print stdout loop');
@ -166,7 +166,7 @@ class SyncingState extends HookedState {
} }
Future<void> checkSync() async { Future<void> checkSync() async {
await for (var _null in refresh.pull(getNotification, 'syncingState')) { await for (final _null in refresh.pull(getNotification, 'syncingState')) {
log.finer('SyncingState: checkSync loop'); log.finer('SyncingState: checkSync loop');
// here doc is wrong, targetHeight could match height when synced // here doc is wrong, targetHeight could match height when synced
@ -210,7 +210,7 @@ class SyncedState extends HookedState {
log.fine("Synced next"); log.fine("Synced next");
Future<void> logStdout() async { Future<void> logStdout() async {
await for (var line in processOutput) { await for (final line in processOutput) {
if (!synced) break; if (!synced) break;
// print('synced: print stdout loop'); // print('synced: print stdout loop');
stdout += line; stdout += line;
@ -221,7 +221,7 @@ class SyncedState extends HookedState {
logStdout(); logStdout();
Future<void> checkSync() async { Future<void> checkSync() async {
await for (var _null in refresh.pull(getNotification, 'syncedState')) { await for (final _null in refresh.pull(getNotification, 'syncedState')) {
if (await daemon.isNotSynced()) { if (await daemon.isNotSynced()) {
synced = false; synced = false;
break; break;
@ -267,7 +267,7 @@ class ReSyncingState extends HookedState {
log.fine("ReSyncing next"); log.fine("ReSyncing next");
Future<void> printStdout() async { Future<void> printStdout() async {
await for (var line in processOutput) { await for (final line in processOutput) {
if (synced) break; if (synced) break;
// print('re-syncing: print stdout loop'); // print('re-syncing: print stdout loop');
append(line); append(line);
@ -276,7 +276,7 @@ class ReSyncingState extends HookedState {
} }
Future<void> checkSync() async { Future<void> checkSync() async {
await for (var _null in refresh.pull(getNotification, 'ReSyncingState')) { await for (final _null in refresh.pull(getNotification, 'ReSyncingState')) {
if (await daemon.isSynced()) { if (await daemon.isSynced()) {
synced = true; synced = true;