diff --git a/cyberwow/lib/controller/helper.dart b/cyberwow/lib/controller/helper.dart index e817faa..9513d25 100644 --- a/cyberwow/lib/controller/helper.dart +++ b/cyberwow/lib/controller/helper.dart @@ -25,12 +25,12 @@ import 'dart:io'; import 'package:path_provider/path_provider.dart'; import 'package:flutter/foundation.dart'; -Future getBinaryPath(String name) async { +Future getBinaryPath(final String name) async { final tmpDir = await getTemporaryDirectory(); return tmpDir.path + '/' + name; } -Future binaryExists(String name) async { +Future binaryExists(final String name) async { final binPath = await getBinaryPath(name); return new File(binPath).exists(); } diff --git a/cyberwow/lib/controller/process/deploy.dart b/cyberwow/lib/controller/process/deploy.dart index e5b84ac..180d421 100644 --- a/cyberwow/lib/controller/process/deploy.dart +++ b/cyberwow/lib/controller/process/deploy.dart @@ -27,7 +27,12 @@ import 'package:flutter/services.dart'; import '../helper.dart'; -Stream deployBinary (AssetBundle bundle, String path, String name) async* { +Stream deployBinary +( + final AssetBundle bundle, + final String path, + final String name +) async* { final binData = await bundle.load(path); final newPath = await getBinaryPath(name); diff --git a/cyberwow/lib/controller/process/run.dart b/cyberwow/lib/controller/process/run.dart index 68a9a53..651de52 100644 --- a/cyberwow/lib/controller/process/run.dart +++ b/cyberwow/lib/controller/process/run.dart @@ -30,7 +30,7 @@ import '../helper.dart'; import '../../config.dart' as config; import '../../logging.dart'; -Stream runBinary (String name, {Stream input}) async* { +Stream runBinary (final String name, {final Stream input}) async* { final newPath = await getBinaryPath(name); final appDocDir = await getApplicationDocumentsDirectory(); diff --git a/cyberwow/lib/controller/refresh.dart b/cyberwow/lib/controller/refresh.dart index 967ebba..9b9ed5f 100644 --- a/cyberwow/lib/controller/refresh.dart +++ b/cyberwow/lib/controller/refresh.dart @@ -30,7 +30,7 @@ import '../logging.dart'; typedef GetNotificationFunc = AppLifecycleState Function(); -Stream pull(GetNotificationFunc getNotification, String puller) async* { +Stream pull(GetNotificationFunc getNotification, final String puller) async* { while (true) { final _appState = getNotification(); log.finer('refresh pull by ${puller}: app state: ${_appState}'); diff --git a/cyberwow/lib/controller/rpc/rpc.dart b/cyberwow/lib/controller/rpc/rpc.dart index 5b4479a..9d0aa02 100644 --- a/cyberwow/lib/controller/rpc/rpc.dart +++ b/cyberwow/lib/controller/rpc/rpc.dart @@ -31,7 +31,7 @@ import '../../logging.dart'; int rpcID = 0; -Future rpcHTTP(String method) async { +Future rpcHTTP(final String method) async { final url = 'http://${config.host}:${config.c.port}/json_rpc'; rpcID += 1; @@ -58,9 +58,9 @@ Future rpcHTTP(String method) async { } } -dynamic jsonDecode(String responseBody) => json.decode(responseBody); +dynamic jsonDecode(final String responseBody) => json.decode(responseBody); -Future rpc(String method, {String field}) async { +Future rpc(final String method, {final String field}) async { final response = await rpcHTTP(method); if (response == null) return null; @@ -76,7 +76,7 @@ Future rpc(String method, {String field}) async { } } -Future rpcString(String method, {String field}) async { +Future rpcString(final String method, {final String field}) async { final _field = await rpc(method, field: field); return pretty(_field); } diff --git a/cyberwow/lib/controller/rpc/rpc2.dart b/cyberwow/lib/controller/rpc/rpc2.dart index 19d178a..bda786d 100644 --- a/cyberwow/lib/controller/rpc/rpc2.dart +++ b/cyberwow/lib/controller/rpc/rpc2.dart @@ -29,7 +29,7 @@ import '../../config.dart' as config; import '../../helper.dart'; import '../../logging.dart'; -Future rpc2(String method) async { +Future rpc2(final String method) async { final url = 'http://${config.host}:${config.c.port}/${method}'; try { @@ -44,9 +44,9 @@ Future rpc2(String method) async { } } -dynamic jsonDecode(String responseBody) => json.decode(responseBody); +dynamic jsonDecode(final String responseBody) => json.decode(responseBody); -Future rpc2String(String method, {String field}) async { +Future rpc2String(final String method, {final String field}) async { final response = await rpc2(method); if (response == null) return ''; diff --git a/cyberwow/lib/main.dart b/cyberwow/lib/main.dart index c621f6b..d4a5087 100644 --- a/cyberwow/lib/main.dart +++ b/cyberwow/lib/main.dart @@ -110,11 +110,11 @@ class _CyberWOW_PageState extends State with WidgetsBindingObserv } - void _updateLoading(LoadingState state, String msg) { + void _updateLoading(LoadingState state, final String msg) { log.fine('updateLoading: ' + msg); } - Future buildStateMachine(BlankState _blankState) async { + Future buildStateMachine(final BlankState _blankState) async { final loadingText = config.c.splash; LoadingState _loadingState = await _blankState.next(loadingText); @@ -180,7 +180,7 @@ class _CyberWOW_PageState extends State with WidgetsBindingObserv SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]); - BlankState _blankState = BlankState(_setState, _getNotification, _isExiting); + final BlankState _blankState = BlankState(_setState, _getNotification, _isExiting); _state = _blankState; buildStateMachine(_blankState); @@ -202,7 +202,7 @@ class _CyberWOW_PageState extends State with WidgetsBindingObserv @override Widget build(BuildContext context) { - return new WillPopScope + return WillPopScope ( onWillPop: () => _exitApp(context), child: _state.use diff --git a/cyberwow/lib/state.dart b/cyberwow/lib/state.dart index 1c65775..b6e2dc3 100644 --- a/cyberwow/lib/state.dart +++ b/cyberwow/lib/state.dart @@ -100,12 +100,12 @@ class BlankState extends HookedState { } class LoadingState extends HookedState { - String banner; + final String banner; String status = ''; LoadingState(f1, f2, f3, this.banner) : super (f1, f2, f3); - void append(String msg) { + void append(final String msg) { this.status += msg; syncState(); } @@ -149,12 +149,13 @@ class LoadingState extends HookedState { } class SyncingState extends HookedState { - Queue stdout = Queue(); + final Queue stdout = Queue(); + bool synced = false; SyncingState(f1, f2, f3) : super (f1, f2, f3); - void append(String msg) { + void append(final String msg) { stdout.addLast(msg); while (stdout.length > config.stdoutLineBufferSize) { stdout.removeFirst(); @@ -225,20 +226,19 @@ class SyncingState extends HookedState { } class SyncedState extends HookedState { - Queue stdout; + final Queue stdout; + final StreamSink processInput; + final Stream processOutput; + final TextEditingController textController = TextEditingController(); + int height; - StreamSink processInput; - Stream processOutput; bool synced = true; bool connected = true; Map getInfo = {}; - String syncInfo = 'syncInfo'; List getConnections = []; List getTransactionPool = []; int pageIndex; - - final FocusNode focusNode = FocusNode(); - final TextEditingController textController = TextEditingController(); + String syncInfo = 'syncInfo'; PageController pageController; SyncedState(f1, f2, f3, this.stdout, this.processInput, this.processOutput, this.pageIndex) @@ -246,12 +246,12 @@ class SyncedState extends HookedState { pageController = PageController( initialPage: pageIndex ); } - void appendInput(String line) { + void appendInput(final String line) { stdout.addLast('> ' + line + '\n'); processInput.add(line); } - void append(String msg) { + void append(final String msg) { stdout.addLast(msg); while (stdout.length > config.stdoutLineBufferSize) { stdout.removeFirst(); @@ -293,7 +293,6 @@ class SyncedState extends HookedState { height = await rpc.height(); connected = await daemon.isConnected(); getInfo = await rpc.getInfoSimple(); - // syncInfo = await rpc.syncInfoString(); getConnections = await rpc.getConnectionsSimple(); // getTransactionPool = await rpc.getTransactionPoolString(); @@ -328,16 +327,17 @@ class SyncedState extends HookedState { class ReSyncingState extends HookedState { - Queue stdout; - StreamSink processInput; - Stream processOutput; - bool synced = false; + final Queue stdout; + final StreamSink processInput; + final Stream processOutput; final int pageIndex; + bool synced = false; + ReSyncingState(f1, f2, f3, this.stdout, this.processInput, this.processOutput, this.pageIndex) : super (f1, f2, f3); - void append(String msg) { + void append(final String msg) { stdout.addLast(msg); while (stdout.length > config.stdoutLineBufferSize) { stdout.removeFirst(); @@ -394,12 +394,12 @@ class ReSyncingState extends HookedState { } class ExitingState extends HookedState { - Queue stdout; - Stream processOutput; + final Queue stdout; + final Stream processOutput; ExitingState(f1, f2, f3, this.stdout, this.processOutput) : super (f1, f2, f3); - void append(String msg) { + void append(final String msg) { stdout.addLast(msg); while (stdout.length > config.stdoutLineBufferSize) { stdout.removeFirst(); diff --git a/cyberwow/lib/widget/synced.dart b/cyberwow/lib/widget/synced.dart index 701c7e1..b0ba79b 100644 --- a/cyberwow/lib/widget/synced.dart +++ b/cyberwow/lib/widget/synced.dart @@ -170,7 +170,7 @@ Widget terminalView(BuildContext context, String title, SyncedState state) { border: InputBorder.none, ), onFieldSubmitted: (v) { - String autoReplace(String x) { + String autoReplace(final String x) { final words = x.split(' '); if (words.length == 0) {