From 86f838b18bcc45a811d91f739375e1d07fc61e13 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Tue, 20 Dec 2022 11:50:21 +0800 Subject: [PATCH] Fix linter rules --- example/lib/download_with_trunks.dart | 6 ++--- example/lib/formdata.dart | 2 +- example/lib/queued_interceptor_crsftoken.dart | 8 +++--- example/lib/response_interceptor.dart | 6 ++--- example_flutter_app/lib/main.dart | 2 +- example_flutter_app/lib/routes/request.dart | 2 +- example_flutter_app/pubspec.yaml | 2 +- .../lib/src/connection_manager_imp.dart | 26 +++++++++---------- .../http2_adapter/lib/src/http2_adapter.dart | 4 +-- 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/example/lib/download_with_trunks.dart b/example/lib/download_with_trunks.dart index 16681b518..8ef0f4d28 100644 --- a/example/lib/download_with_trunks.dart +++ b/example/lib/download_with_trunks.dart @@ -56,9 +56,9 @@ Future downloadWithChunks( final f = File(savePath + 'temp0'); final ioSink = f.openWrite(mode: FileMode.writeOnlyAppend); for (int i = 1; i < chunk; ++i) { - final _f = File(savePath + 'temp$i'); - await ioSink.addStream(_f.openRead()); - await _f.delete(); + final file = File(savePath + 'temp$i'); + await ioSink.addStream(file.openRead()); + await file.delete(); } await ioSink.close(); await f.rename(savePath); diff --git a/example/lib/formdata.dart b/example/lib/formdata.dart index 3c55eaacb..31cda131b 100644 --- a/example/lib/formdata.dart +++ b/example/lib/formdata.dart @@ -112,7 +112,7 @@ void main() async { data: data3, onSendProgress: (received, total) { if (total != -1) { - print((received / total * 100).toStringAsFixed(0) + '%'); + print('${(received / total * 100).toStringAsFixed(0)}%'); } }, ); diff --git a/example/lib/queued_interceptor_crsftoken.dart b/example/lib/queued_interceptor_crsftoken.dart index 7f51bb579..7ec5c25f9 100644 --- a/example/lib/queued_interceptor_crsftoken.dart +++ b/example/lib/queued_interceptor_crsftoken.dart @@ -78,13 +78,13 @@ void main() async { }, )); - FutureOr _onResult(d) { + FutureOr onResult(d) { print('request ok!'); } /// assume `/test?tag=2` path occurs the authorization error (401) /// and token to be updated - await dio.get('/test?tag=1').then(_onResult); - await dio.get('/test?tag=2').then(_onResult); - await dio.get('/test?tag=3').then(_onResult); + await dio.get('/test?tag=1').then(onResult); + await dio.get('/test?tag=2').then(onResult); + await dio.get('/test?tag=3').then(onResult); } diff --git a/example/lib/response_interceptor.dart b/example/lib/response_interceptor.dart index 471f4dbdd..657312305 100644 --- a/example/lib/response_interceptor.dart +++ b/example/lib/response_interceptor.dart @@ -58,12 +58,12 @@ void main() async { } on DioError catch (e) { assert(e.response!.statusCode == 404); } - response = await dio.get(urlNotFound + '1'); + response = await dio.get('${urlNotFound}1'); assert(response.data == 'fake data'); - response = await dio.get(urlNotFound + '2'); + response = await dio.get('${urlNotFound}2'); assert(response.data == 'fake data'); try { - await dio.get(urlNotFound + '3'); + await dio.get('${urlNotFound}3'); } on DioError catch (e) { assert(e.message == 'custom error info [404]'); } diff --git a/example_flutter_app/lib/main.dart b/example_flutter_app/lib/main.dart index 8fee3afab..1dfbc88fd 100644 --- a/example_flutter_app/lib/main.dart +++ b/example_flutter_app/lib/main.dart @@ -41,7 +41,7 @@ class MyHomePage extends StatefulWidget { final String title; @override - _MyHomePageState createState() => _MyHomePageState(); + State createState() => _MyHomePageState(); } class _MyHomePageState extends State { diff --git a/example_flutter_app/lib/routes/request.dart b/example_flutter_app/lib/routes/request.dart index 8779e22ea..c5f8b5fd6 100644 --- a/example_flutter_app/lib/routes/request.dart +++ b/example_flutter_app/lib/routes/request.dart @@ -5,7 +5,7 @@ import '../http.dart'; class RequestRoute extends StatefulWidget { @override - _RequestRouteState createState() => _RequestRouteState(); + State createState() => _RequestRouteState(); } class _RequestRouteState extends State { diff --git a/example_flutter_app/pubspec.yaml b/example_flutter_app/pubspec.yaml index 4e968db05..4280ecf1d 100644 --- a/example_flutter_app/pubspec.yaml +++ b/example_flutter_app/pubspec.yaml @@ -34,7 +34,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - lints: ^1.0.1 + lints: any # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/plugins/http2_adapter/lib/src/connection_manager_imp.dart b/plugins/http2_adapter/lib/src/connection_manager_imp.dart index 12ed1aee9..78b9fe8ee 100644 --- a/plugins/http2_adapter/lib/src/connection_manager_imp.dart +++ b/plugins/http2_adapter/lib/src/connection_manager_imp.dart @@ -39,12 +39,12 @@ class _ConnectionManager implements ConnectionManager { final domain = '${uri.host}:${uri.port}'; _ClientTransportConnectionState? transportState = _transportsMap[domain]; if (transportState == null) { - Future<_ClientTransportConnectionState>? _initFuture = + Future<_ClientTransportConnectionState>? initFuture = _connectFutures[domain]; - if (_initFuture == null) { - _connectFutures[domain] = _initFuture = _connect(options); + if (initFuture == null) { + _connectFutures[domain] = initFuture = _connect(options); } - transportState = await _initFuture; + transportState = await initFuture; if (_forceClosed) { transportState.dispose(); } else { @@ -108,35 +108,35 @@ class _ConnectionManager implements ConnectionManager { // Config a ClientTransportConnection and save it final transport = ClientTransportConnection.viaSocket(socket); - final _transportState = _ClientTransportConnectionState(transport); + final transportState = _ClientTransportConnectionState(transport); transport.onActiveStateChanged = (bool isActive) { - _transportState.isActive = isActive; + transportState.isActive = isActive; if (!isActive) { - _transportState.latestIdleTimeStamp = DateTime.now(); + transportState.latestIdleTimeStamp = DateTime.now(); } }; // - _transportState.delayClose( + transportState.delayClose( _closed ? Duration(milliseconds: 50) : _idleTimeout, () { _transportsMap.remove(domain); - _transportState.transport.finish(); + transportState.transport.finish(); }, ); - return _transportState; + return transportState; } @override void removeConnection(ClientTransportConnection transport) { - _ClientTransportConnectionState? _transportState; + _ClientTransportConnectionState? transportState; _transportsMap.removeWhere((_, state) { if (state.transport == transport) { - _transportState = state; + transportState = state; return true; } return false; }); - _transportState?.dispose(); + transportState?.dispose(); } @override diff --git a/plugins/http2_adapter/lib/src/http2_adapter.dart b/plugins/http2_adapter/lib/src/http2_adapter.dart index ef8ea1a2c..46025a0f4 100644 --- a/plugins/http2_adapter/lib/src/http2_adapter.dart +++ b/plugins/http2_adapter/lib/src/http2_adapter.dart @@ -47,10 +47,10 @@ class Http2Adapter implements HttpClientAdapter { const excludeMethods = ['PUT', 'POST', 'PATCH']; if (path.isEmpty || !path.startsWith('/')) { - path = '/' + path; + path = '/$path'; } if (uri.query.trim().isNotEmpty) { - path += '?' + uri.query; + path += '?${uri.query}'; } final headers = [ Header.ascii(':method', options.method),