diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..29eac1a --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,8 @@ +include: package:flutter_lints/flutter.yaml + +linter: + rules: + avoid_print: false + unnecessary_this: false + file_names: false + constant_identifier_names: false diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 42bc2a8..08b3866 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -360,7 +360,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 5BU82VSTV4; + DEVELOPMENT_TEAM = ""; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; @@ -492,7 +492,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 5BU82VSTV4; + DEVELOPMENT_TEAM = ""; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; @@ -516,7 +516,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = 5BU82VSTV4; + DEVELOPMENT_TEAM = ""; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; diff --git a/lib/basic/Channels.dart b/lib/basic/Channels.dart index da81dc6..a092709 100644 --- a/lib/basic/Channels.dart +++ b/lib/basic/Channels.dart @@ -7,7 +7,7 @@ import 'package:flutter/services.dart'; // 由于Flutter的EventChannel只能订阅一次, 且为了和golang的的通信, 这里实现了多次订阅的分发和平铺 // 根据eventName订阅和取消订阅 -var _eventChannel = EventChannel("flatEvent"); +var _eventChannel = const EventChannel("flatEvent"); StreamSubscription? _eventChannelListen; Map _eventMap = {}; @@ -28,7 +28,7 @@ void unregisterEvent(void Function(String args) eventHandler) { throw 'no register'; } _eventMap.remove(eventHandler); - if (_eventMap.length == 0) { + if (_eventMap.isEmpty) { _eventChannelListen?.cancel(); } } diff --git a/lib/basic/Common.dart b/lib/basic/Common.dart index d46c442..ce20405 100644 --- a/lib/basic/Common.dart +++ b/lib/basic/Common.dart @@ -19,8 +19,8 @@ void defaultToast(BuildContext context, String title) { position: StyledToastPosition.center, animation: StyledToastAnimation.scale, reverseAnimation: StyledToastAnimation.fade, - duration: Duration(seconds: 4), - animDuration: Duration(seconds: 1), + duration: const Duration(seconds: 4), + animDuration: const Duration(seconds: 1), curve: Curves.elasticOut, reverseCurve: Curves.linear, ); @@ -33,22 +33,20 @@ Future confirmDialog( context: context, builder: (context) => AlertDialog( title: Text(title), - content: new SingleChildScrollView( - child: new ListBody( - children: [ - new Text(content), - ], + content: SingleChildScrollView( + child: ListBody( + children: [Text(content)], ), ), actions: [ - new MaterialButton( - child: new Text('取消'), + MaterialButton( + child: const Text('取消'), onPressed: () { Navigator.of(context).pop(false); }, ), - new MaterialButton( - child: new Text('确定'), + MaterialButton( + child: const Text('确定'), onPressed: () { Navigator.of(context).pop(true); }, @@ -61,35 +59,36 @@ Future confirmDialog( /// 显示一个消息提示框 Future alertDialog(BuildContext context, String title, String content) { return showDialog( - context: context, - builder: (context) => AlertDialog( - title: Text(title), - content: new SingleChildScrollView( - child: new ListBody( - children: [ - new Text(content), - ], - ), - ), - actions: [ - new MaterialButton( - child: new Text('确定'), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ], - )); + context: context, + builder: (context) => AlertDialog( + title: Text(title), + content: SingleChildScrollView( + child: ListBody( + children: [ + Text(content), + ], + ), + ), + actions: [ + MaterialButton( + child: const Text('确定'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ), + ); } /// stream-filter的替代方法 List filteredList(List list, bool Function(T) filter) { List result = []; - list.forEach((element) { + for (var element in list) { if (filter(element)) { result.add(element); } - }); + } return result; } @@ -197,7 +196,7 @@ Future displayTextInputDialog(BuildContext context, }, ), MaterialButton( - child: Text('确认'), + child: const Text('确认'), onPressed: () { Navigator.of(context).pop(_controller.text); }, @@ -258,12 +257,10 @@ Future inputString(BuildContext context, String title, child: ListBody( children: [ Text(title), - Container( - child: TextField( - controller: _textEditController, - decoration: new InputDecoration( - labelText: "$hint", - ), + TextField( + controller: _textEditController, + decoration: InputDecoration( + labelText: hint, ), ), ], @@ -275,13 +272,13 @@ Future inputString(BuildContext context, String title, onPressed: () { Navigator.pop(context); }, - child: Text('取消'), + child: const Text('取消'), ), MaterialButton( onPressed: () { Navigator.pop(context, _textEditController.text); }, - child: Text('确定'), + child: const Text('确定'), ), ], ); diff --git a/lib/basic/Method.dart b/lib/basic/Method.dart index 9b2b872..2f44300 100644 --- a/lib/basic/Method.dart +++ b/lib/basic/Method.dart @@ -13,7 +13,7 @@ class Method { Method._(); /// channel - MethodChannel _channel = MethodChannel("method"); + final MethodChannel _channel = const MethodChannel("method"); /// 平铺调用, 为了直接与golang进行通信 Future _flatInvoke(String method, dynamic params) { diff --git a/lib/basic/config/AndroidDisplayMode.dart b/lib/basic/config/AndroidDisplayMode.dart index 6dd0743..bccb1eb 100644 --- a/lib/basic/config/AndroidDisplayMode.dart +++ b/lib/basic/config/AndroidDisplayMode.dart @@ -29,7 +29,7 @@ Future _chooseAndroidDisplayMode(BuildContext context) async { list.addAll(_modes); String? result = await chooseListDialog(context, "安卓屏幕刷新率", list); if (result != null) { - await method.saveProperty(_propertyName, "$result"); + await method.saveProperty(_propertyName, result); _androidDisplayMode = result; await _changeMode(); } diff --git a/lib/basic/config/DownloadAndExportPath.dart b/lib/basic/config/DownloadAndExportPath.dart index 1701f90..9310151 100644 --- a/lib/basic/config/DownloadAndExportPath.dart +++ b/lib/basic/config/DownloadAndExportPath.dart @@ -2,7 +2,6 @@ import 'dart:io'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:pikapika/basic/Common.dart'; import 'package:pikapika/basic/Cross.dart'; diff --git a/lib/basic/config/DownloadThreadCount.dart b/lib/basic/config/DownloadThreadCount.dart index 5548d89..823aca7 100644 --- a/lib/basic/config/DownloadThreadCount.dart +++ b/lib/basic/config/DownloadThreadCount.dart @@ -1,6 +1,5 @@ /// 多线程下载并发数 -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:pikapika/basic/Common.dart'; import 'package:pikapika/basic/Method.dart'; diff --git a/lib/basic/config/FullScreenUI.dart b/lib/basic/config/FullScreenUI.dart index 8022728..fe18c82 100644 --- a/lib/basic/config/FullScreenUI.dart +++ b/lib/basic/config/FullScreenUI.dart @@ -67,6 +67,8 @@ void switchFullScreenUI() { case FullScreenUI.ALL: list.clear(); break; + case FullScreenUI.NO: + break; } if (Platform.isAndroid || Platform.isIOS) { SystemChrome.setEnabledSystemUIOverlays(list); @@ -78,7 +80,7 @@ Widget fullScreenUISetting() { return StatefulBuilder( builder: (BuildContext context, void Function(void Function()) setState) { return ListTile( - title: Text("全屏UI"), + title: const Text("全屏UI"), subtitle: Text(currentFullScreenUIName()), onTap: () async { await chooseFullScreenUI(context); diff --git a/lib/basic/config/GalleryPreloadCount.dart b/lib/basic/config/GalleryPreloadCount.dart index 2c77461..c86a70e 100644 --- a/lib/basic/config/GalleryPreloadCount.dart +++ b/lib/basic/config/GalleryPreloadCount.dart @@ -1,12 +1,4 @@ /// 相册模式下预加载图片数量 -import 'dart:convert'; -import 'dart:io'; - -import 'package:flutter/material.dart'; -import 'package:pikapika/basic/Method.dart'; - -import '../Common.dart'; - const galleryPrePreloadCount = 1; const galleryPreloadCount = 2; diff --git a/lib/basic/config/ImageAddress.dart b/lib/basic/config/ImageAddress.dart index e492d24..64ab001 100644 --- a/lib/basic/config/ImageAddress.dart +++ b/lib/basic/config/ImageAddress.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../Method.dart'; diff --git a/lib/basic/config/NoAnimation.dart b/lib/basic/config/NoAnimation.dart index 7732212..5cde441 100644 --- a/lib/basic/config/NoAnimation.dart +++ b/lib/basic/config/NoAnimation.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:flutter/material.dart'; import '../Common.dart'; diff --git a/lib/basic/config/Proxy.dart b/lib/basic/config/Proxy.dart index 89c7549..0c58cdd 100644 --- a/lib/basic/config/Proxy.dart +++ b/lib/basic/config/Proxy.dart @@ -9,6 +9,7 @@ late String _currentProxy; Future initProxy() async { _currentProxy = await method.getProxy(); + return null; } String currentProxyName() { diff --git a/lib/basic/config/ShadowCategories.dart b/lib/basic/config/ShadowCategories.dart index 1b6302d..a05710b 100644 --- a/lib/basic/config/ShadowCategories.dart +++ b/lib/basic/config/ShadowCategories.dart @@ -3,7 +3,6 @@ import 'dart:convert'; import 'package:flutter/material.dart'; -import 'package:multi_select_flutter/dialog/mult_select_dialog.dart'; import 'package:multi_select_flutter/multi_select_flutter.dart'; import '../Method.dart'; @@ -33,11 +32,11 @@ Future _chooseShadowCategories(BuildContext context) async { context: context, builder: (ctx) { var initialValue = []; - shadowCategories.forEach((element) { + for (var element in shadowCategories) { if (shadowCategories.contains(element)) { initialValue.add(element); } - }); + } return MultiSelectDialog( title: Text('封印'), searchHint: '搜索', diff --git a/lib/basic/config/Themes.dart b/lib/basic/config/Themes.dart index 025d8f1..35716bd 100644 --- a/lib/basic/config/Themes.dart +++ b/lib/basic/config/Themes.dart @@ -380,7 +380,7 @@ Future chooseTheme(BuildContext buildContext) async { ) )); return SimpleDialog( - title: Text("选择主题"), + title: const Text("选择主题"), children: list, ); }) diff --git a/lib/basic/config/TimeOffsetHour.dart b/lib/basic/config/TimeOffsetHour.dart index 6ff1579..742f6f1 100644 --- a/lib/basic/config/TimeOffsetHour.dart +++ b/lib/basic/config/TimeOffsetHour.dart @@ -31,7 +31,7 @@ Future _chooseTimeZone(BuildContext context) async { result = result.substring(1); } _timeOffsetHour = int.parse(result); - await method.saveProperty(_propertyName, "$result"); + await method.saveProperty(_propertyName, result); } } diff --git a/lib/screens/AboutScreen.dart b/lib/screens/AboutScreen.dart index e2e67e0..196611f 100644 --- a/lib/screens/AboutScreen.dart +++ b/lib/screens/AboutScreen.dart @@ -9,6 +9,8 @@ const _releasesUrl = "https://github.com/niuhuan/pikapika/releases"; // 关于 class AboutScreen extends StatefulWidget { + const AboutScreen({Key? key}) : super(key: key); + @override State createState() => _AboutScreenState(); } @@ -40,11 +42,11 @@ class _AboutScreenState extends State { var _dirty = dirtyVersion(); return Scaffold( appBar: AppBar( - title: Text('关于'), + title: const Text('关于'), ), body: ListView( children: [ - Container( + SizedBox( width: min / 2, height: min / 2, child: Center( diff --git a/lib/screens/AccountScreen.dart b/lib/screens/AccountScreen.dart index a22dc49..1ece2e4 100644 --- a/lib/screens/AccountScreen.dart +++ b/lib/screens/AccountScreen.dart @@ -13,6 +13,8 @@ import 'components/ContentLoading.dart'; // 账户设置 class AccountScreen extends StatefulWidget { + const AccountScreen({Key? key}) : super(key: key); + @override _AccountScreenState createState() => _AccountScreenState(); } diff --git a/lib/screens/AppScreen.dart b/lib/screens/AppScreen.dart index 43cce7d..9435092 100644 --- a/lib/screens/AppScreen.dart +++ b/lib/screens/AppScreen.dart @@ -31,8 +31,8 @@ class _AppScreenState extends State { } static const List _widgetOptions = [ - const CategoriesScreen(), - const SpaceScreen(), + CategoriesScreen(), + SpaceScreen(), ]; late int _selectedIndex = 0; diff --git a/lib/screens/CategoriesScreen.dart b/lib/screens/CategoriesScreen.dart index ff91521..103ef6b 100644 --- a/lib/screens/CategoriesScreen.dart +++ b/lib/screens/CategoriesScreen.dart @@ -18,7 +18,7 @@ import 'components/Images.dart'; // 分类 class CategoriesScreen extends StatefulWidget { - const CategoriesScreen(); + const CategoriesScreen({Key? key}) : super(key: key); @override State createState() => _CategoriesScreenState(); @@ -41,7 +41,7 @@ class _CategoriesScreenState extends State { }, buildDefaultAppBar: (BuildContext context) { return AppBar( - title: new Text('分类'), + title: Text('分类'), actions: [ shadowCategoriesActionButton(context), _searchBar.getSearchAction(context), @@ -55,11 +55,11 @@ class _CategoriesScreenState extends State { Future> _fetch() async { List categories = await method.categories(); storedCategories = []; - categories.forEach((element) { + for (var element in categories) { if (!element.isWeb) { storedCategories.add(element.title); } - }); + } return categories; } @@ -151,7 +151,7 @@ class _CategoriesScreenState extends State { list.add( GestureDetector( onTap: onTap, - child: Container( + child: SizedBox( width: blockSize, child: Column( children: [ @@ -221,7 +221,7 @@ class _CategoriesScreenState extends State { list.add( GestureDetector( onTap: onTap, - child: Container( + child: SizedBox( width: blockSize, child: Column( children: [ diff --git a/lib/screens/CleanScreen.dart b/lib/screens/CleanScreen.dart index eb27bc7..f460b04 100644 --- a/lib/screens/CleanScreen.dart +++ b/lib/screens/CleanScreen.dart @@ -8,6 +8,8 @@ import 'components/ContentLoading.dart'; // 清理 class CleanScreen extends StatefulWidget { + const CleanScreen({Key? key}) : super(key: key); + @override State createState() => _CleanScreenState(); } @@ -44,15 +46,15 @@ class _CleanScreenState extends State { } return Scaffold( appBar: AppBar( - title: Text('清理'), + title: const Text('清理'), ), body: ListView( children: [ Container( - padding: EdgeInsets.all(8), + padding: const EdgeInsets.all(8), child: _cleanResult != "" ? Text(_cleanResult) : Container(), ), - Container( + SizedBox( height: 50, child: FitButton( text: '清理网络缓存', @@ -61,7 +63,7 @@ class _CleanScreenState extends State { }, ), ), - Container( + SizedBox( height: 50, child: FitButton( text: '清理图片缓存', @@ -70,7 +72,7 @@ class _CleanScreenState extends State { }, ), ), - Container( + SizedBox( height: 50, child: FitButton( text: '清理全部缓存', diff --git a/lib/screens/ComicInfoScreen.dart b/lib/screens/ComicInfoScreen.dart index 63fec4b..b932994 100644 --- a/lib/screens/ComicInfoScreen.dart +++ b/lib/screens/ComicInfoScreen.dart @@ -151,19 +151,19 @@ class _ComicInfoScreenState extends State with RouteAware { onLongPress: () { confirmCopy( context, - "${_comicInfo.creator.name}", + _comicInfo.creator.name, ); }, child: Text( - "${_comicInfo.creator.name}", - style: TextStyle( + _comicInfo.creator.name, + style: const TextStyle( fontSize: 14, color: Colors.grey, ), ), ), ), - TextSpan( + const TextSpan( text: " ", style: TextStyle( fontSize: 14, @@ -195,8 +195,8 @@ class _ComicInfoScreenState extends State with RouteAware { confirmCopy(context, _comicInfo.chineseTeam); }, child: Text( - "${_comicInfo.chineseTeam}", - style: TextStyle( + _comicInfo.chineseTeam, + style: const TextStyle( fontSize: 13, color: Colors.grey, ), @@ -300,15 +300,13 @@ class _ComicInfoScreenState extends State with RouteAware { alignment: WrapAlignment.spaceAround, children: [ ..._epList.map((e) { - return Container( - child: MaterialButton( - onPressed: () { - _push(_comicInfo, _epList, e.order, null); - }, - color: Colors.white, - child: - Text(e.title, style: TextStyle(color: Colors.black)), - ), + return MaterialButton( + onPressed: () { + _push(_comicInfo, _epList, e.order, null); + }, + color: Colors.white, + child: + Text(e.title, style: TextStyle(color: Colors.black)), ); }), ], diff --git a/lib/screens/ComicReaderScreen.dart b/lib/screens/ComicReaderScreen.dart index ffa4381..18e0e81 100644 --- a/lib/screens/ComicReaderScreen.dart +++ b/lib/screens/ComicReaderScreen.dart @@ -3,7 +3,6 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:pikapika/basic/Common.dart'; import 'package:pikapika/basic/Entities.dart'; import 'package:pikapika/basic/Method.dart'; import 'package:pikapika/basic/config/AutoFullScreen.dart'; @@ -76,10 +75,10 @@ class _ComicReaderScreenState extends State { } FutureOr _onChangeEp(int epOrder) { - var orderMap = Map(); - widget.epList.forEach((element) { + var orderMap = {}; + for (var element in widget.epList) { orderMap[element.order] = element; - }); + } if (orderMap.containsKey(epOrder)) { _replacement = true; Navigator.of(context).pushReplacement( @@ -124,11 +123,11 @@ class _ComicReaderScreenState extends State { @override void initState() { // EP - widget.epList.forEach((element) { + for (var element in widget.epList) { if (element.order == widget.currentEpOrder) { _ep = element; } - }); + } // INIT _future = _load(); super.initState(); @@ -177,13 +176,13 @@ class _ComicReaderScreenState extends State { : AppBar( title: Text("${_ep.title} - ${widget.comicInfo.title}"), ), - body: ContentLoading(label: '加载中'), + body: const ContentLoading(label: '加载中'), ); } - var epNameMap = Map(); - widget.epList.forEach((element) { + var epNameMap = {}; + for (var element in widget.epList) { epNameMap[element.order] = element.title; - }); + } return Scaffold( body: ImageReader( ImageReaderStruct( diff --git a/lib/screens/ComicsScreen.dart b/lib/screens/ComicsScreen.dart index 273abdc..ded172c 100644 --- a/lib/screens/ComicsScreen.dart +++ b/lib/screens/ComicsScreen.dart @@ -32,7 +32,7 @@ class ComicsScreen extends StatefulWidget { } class _ComicsScreenState extends State { - late SearchBar _categorySearchBar = SearchBar( + late final SearchBar _categorySearchBar = SearchBar( hintText: '搜索分类 - ${categoryTitle(widget.category)}', inBar: false, setState: setState, @@ -49,7 +49,7 @@ class _ComicsScreenState extends State { }, buildDefaultAppBar: (BuildContext context) { return AppBar( - title: new Text(categoryTitle(widget.category)), + title: Text(categoryTitle(widget.category)), actions: [ shadowCategoriesActionButton(context), chooseLayoutActionButton(context), diff --git a/lib/screens/CommentScreen.dart b/lib/screens/CommentScreen.dart index 6497a02..33937de 100644 --- a/lib/screens/CommentScreen.dart +++ b/lib/screens/CommentScreen.dart @@ -28,7 +28,8 @@ class CommentScreen extends StatefulWidget { final String mainId; final CommentBase comment; - const CommentScreen(this.mainType, this.mainId, this.comment); + const CommentScreen(this.mainType, this.mainId, this.comment, {Key? key}) + : super(key: key); @override State createState() => _CommentScreenState(); diff --git a/lib/screens/DownloadConfirmScreen.dart b/lib/screens/DownloadConfirmScreen.dart index 4e7f0f0..095b499 100644 --- a/lib/screens/DownloadConfirmScreen.dart +++ b/lib/screens/DownloadConfirmScreen.dart @@ -25,8 +25,8 @@ class DownloadConfirmScreen extends StatefulWidget { class _DownloadConfirmScreenState extends State { DownloadComic? _task; // 之前的下载任务 - List _taskedEps = []; // 已经下载的EP - List _selectedEps = []; // 选中的EP + final List _taskedEps = []; // 已经下载的EP + final List _selectedEps = []; // 选中的EP late Future f = _load(); Future _load() async { @@ -41,11 +41,11 @@ class _DownloadConfirmScreenState extends State { void _selectAll() { setState(() { _selectedEps.clear(); - widget.epList.forEach((element) { + for (var element in widget.epList) { if (!_taskedEps.contains(element.order)) { _selectedEps.add(element.order); } - }); + } }); } @@ -75,7 +75,7 @@ class _DownloadConfirmScreenState extends State { }; // 下载EP列表 List> list = []; - widget.epList.forEach((element) { + for (var element in widget.epList) { if (_selectedEps.contains(element.order)) { list.add({ "comicId": widget.comicInfo.id, @@ -85,7 +85,7 @@ class _DownloadConfirmScreenState extends State { "title": element.title, }); } - }); + } // 如果之前下载过就将EP加入下载 // 如果之前没有下载过就创建下载 if (_task != null) { diff --git a/lib/screens/DownloadExportToFileScreen.dart b/lib/screens/DownloadExportToFileScreen.dart index 1e624db..ee26551 100644 --- a/lib/screens/DownloadExportToFileScreen.dart +++ b/lib/screens/DownloadExportToFileScreen.dart @@ -20,10 +20,11 @@ class DownloadExportToFileScreen extends StatefulWidget { final String comicId; final String comicTitle; - DownloadExportToFileScreen({ + const DownloadExportToFileScreen({ required this.comicId, required this.comicTitle, - }); + Key? key, + }) : super(key: key); @override State createState() => _DownloadExportToFileScreenState(); @@ -233,7 +234,7 @@ class _DownloadExportToFileScreenState return; } if (!(await Permission.storage.request()).isGranted) { - return null; + return; } try { setState(() { diff --git a/lib/screens/DownloadExportToSocketScreen.dart b/lib/screens/DownloadExportToSocketScreen.dart index e85cc21..4f78616 100644 --- a/lib/screens/DownloadExportToSocketScreen.dart +++ b/lib/screens/DownloadExportToSocketScreen.dart @@ -15,11 +15,12 @@ class DownloadExportToSocketScreen extends StatefulWidget { final String comicId; final String comicTitle; - DownloadExportToSocketScreen({ + const DownloadExportToSocketScreen({ required this.task, required this.comicId, required this.comicTitle, - }); + Key? key, + }) : super(key: key); @override State createState() => _DownloadExportToSocketScreenState(); @@ -28,7 +29,7 @@ class DownloadExportToSocketScreen extends StatefulWidget { class _DownloadExportToSocketScreenState extends State { late Future _future = method.exportComicUsingSocket(widget.comicId); - late Future _ipFuture = method.clientIpSet(); + late final Future _ipFuture = method.clientIpSet(); late String exportMessage = ""; @@ -89,16 +90,16 @@ class _DownloadExportToSocketScreenState builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasError) { - return Text('获取IP失败'); + return const Text('获取IP失败'); } if (snapshot.connectionState != ConnectionState.done) { - return Text('正在获取IP'); + return const Text('正在获取IP'); } return Text('${snapshot.data}'); }, ), Text('端口号:${snapshot.data}'), - Text('$exportMessage'), + Text(exportMessage), ], ), ), diff --git a/lib/screens/DownloadImportScreen.dart b/lib/screens/DownloadImportScreen.dart index a55304a..2fe6497 100644 --- a/lib/screens/DownloadImportScreen.dart +++ b/lib/screens/DownloadImportScreen.dart @@ -1,9 +1,7 @@ -import 'dart:async'; import 'dart:io'; import 'package:filesystem_picker/filesystem_picker.dart'; import 'package:flutter/material.dart'; -import 'package:permission_handler/permission_handler.dart'; import 'package:pikapika/basic/Channels.dart'; import 'package:pikapika/basic/Common.dart'; import 'package:pikapika/basic/Method.dart'; @@ -13,6 +11,8 @@ import 'components/ContentLoading.dart'; // 导入 class DownloadImportScreen extends StatefulWidget { + const DownloadImportScreen({Key? key}) : super(key: key); + @override State createState() => _DownloadImportScreenState(); } diff --git a/lib/screens/DownloadInfoScreen.dart b/lib/screens/DownloadInfoScreen.dart index 5a06bdd..7da579e 100644 --- a/lib/screens/DownloadInfoScreen.dart +++ b/lib/screens/DownloadInfoScreen.dart @@ -19,10 +19,11 @@ class DownloadInfoScreen extends StatefulWidget { final String comicId; final String comicTitle; - DownloadInfoScreen({ + const DownloadInfoScreen({ required this.comicId, required this.comicTitle, - }); + Key? key, + }) : super(key: key); @override State createState() => _DownloadInfoScreenState(); @@ -143,15 +144,13 @@ class _DownloadInfoScreenState extends State }, ), ..._epList.map((e) { - return Container( - child: MaterialButton( - onPressed: () { - _push(_task, _epList, e.epOrder, null); - }, - color: Colors.white, - child: Text(e.title, - style: TextStyle(color: Colors.black)), - ), + return MaterialButton( + onPressed: () { + _push(_task, _epList, e.epOrder, null); + }, + color: Colors.white, + child: Text(e.title, + style: const TextStyle(color: Colors.black)), ); }), ], diff --git a/lib/screens/DownloadListScreen.dart b/lib/screens/DownloadListScreen.dart index 1fd5c27..3ebef74 100644 --- a/lib/screens/DownloadListScreen.dart +++ b/lib/screens/DownloadListScreen.dart @@ -13,6 +13,8 @@ import 'components/DownloadInfoCard.dart'; // 下载列表 class DownloadListScreen extends StatefulWidget { + const DownloadListScreen({Key? key}) : super(key: key); + @override State createState() => _DownloadListScreenState(); } @@ -25,15 +27,13 @@ class _DownloadListScreenState extends State { void _onMessageChange(String event) { print("EVENT"); print(event); - if (event is String) { - try { - setState(() { - _downloading = DownloadComic.fromJson(json.decode(event)); - }); - } catch (e, s) { - print(e); - print(s); - } + try { + setState(() { + _downloading = DownloadComic.fromJson(json.decode(event)); + }); + } catch (e, s) { + print(e); + print(s); } } diff --git a/lib/screens/DownloadReaderScreen.dart b/lib/screens/DownloadReaderScreen.dart index 80f9fa2..853dab6 100644 --- a/lib/screens/DownloadReaderScreen.dart +++ b/lib/screens/DownloadReaderScreen.dart @@ -76,10 +76,10 @@ class _DownloadReaderScreenState extends State { } FutureOr _onChangeEp(int epOrder) { - var orderMap = Map(); - widget.epList.forEach((element) { + var orderMap = {}; + for (var element in widget.epList) { orderMap[element.epOrder] = element; - }); + } if (orderMap.containsKey(epOrder)) { _replacement = true; Navigator.of(context).pushReplacement( @@ -114,11 +114,11 @@ class _DownloadReaderScreenState extends State { @override void initState() { // EP - widget.epList.forEach((element) { + for (var element in widget.epList) { if (element.epOrder == widget.currentEpOrder) { _ep = element; } - }); + } // INIT _future = _load(); super.initState(); @@ -169,10 +169,10 @@ class _DownloadReaderScreenState extends State { body: ContentLoading(label: '加载中'), ); } - var epNameMap = Map(); - widget.epList.forEach((element) { + var epNameMap = {}; + for (var element in widget.epList) { epNameMap[element.epOrder] = element.title; - }); + } return Scaffold( body: ImageReader( ImageReaderStruct( diff --git a/lib/screens/FavouritePaperScreen.dart b/lib/screens/FavouritePaperScreen.dart index 0fdca89..1113a83 100644 --- a/lib/screens/FavouritePaperScreen.dart +++ b/lib/screens/FavouritePaperScreen.dart @@ -5,6 +5,8 @@ import 'components/ComicPager.dart'; // 收藏的漫画 class FavouritePaperScreen extends StatefulWidget { + const FavouritePaperScreen({Key? key}) : super(key: key); + @override State createState() => _FavouritePaperScreen(); } diff --git a/lib/screens/FilePhotoViewScreen.dart b/lib/screens/FilePhotoViewScreen.dart index 5321ed0..74460a5 100644 --- a/lib/screens/FilePhotoViewScreen.dart +++ b/lib/screens/FilePhotoViewScreen.dart @@ -8,7 +8,7 @@ import 'package:pikapika/screens/components/Images.dart'; class FilePhotoViewScreen extends StatelessWidget { final String filePath; - FilePhotoViewScreen(this.filePath); + const FilePhotoViewScreen(this.filePath, {Key? key}) : super(key: key); @override Widget build(BuildContext context) => Scaffold( diff --git a/lib/screens/GameDownloadScreen.dart b/lib/screens/GameDownloadScreen.dart index dea6779..0621198 100644 --- a/lib/screens/GameDownloadScreen.dart +++ b/lib/screens/GameDownloadScreen.dart @@ -18,7 +18,7 @@ class GameDownloadScreen extends StatefulWidget { class _GameDownloadScreenState extends State { late Future> _future = - method.downloadGame("${widget.info.androidLinks[0]}"); + method.downloadGame(widget.info.androidLinks[0]); @override Widget build(BuildContext context) { @@ -34,21 +34,19 @@ class _GameDownloadScreenState extends State { onRefresh: () async { setState(() { _future = - method.downloadGame("${widget.info.androidLinks[0]}"); + method.downloadGame(widget.info.androidLinks[0]); }); }, successBuilder: (BuildContext context, AsyncSnapshot> snapshot) { - return Container( - child: Column( - children: [ - Container( - padding: EdgeInsets.all(30), - child: Text('获取到下载链接, 您只需要选择其中一个'), - ), - ...snapshot.data!.map((e) => _copyCard(e)), - ], - ), + return Column( + children: [ + Container( + padding: const EdgeInsets.all(30), + child: const Text('获取到下载链接, 您只需要选择其中一个'), + ), + ...snapshot.data!.map((e) => _copyCard(e)), + ], ); }, ), diff --git a/lib/screens/GameInfoScreen.dart b/lib/screens/GameInfoScreen.dart index 3bebdcc..156bdea 100644 --- a/lib/screens/GameInfoScreen.dart +++ b/lib/screens/GameInfoScreen.dart @@ -14,7 +14,7 @@ import 'components/GameTitleCard.dart'; class GameInfoScreen extends StatefulWidget { final String gameId; - const GameInfoScreen(this.gameId); + const GameInfoScreen(this.gameId,{Key? key}):super(key: key); @override State createState() => _GameInfoScreenState(); @@ -127,33 +127,31 @@ class _GameInfoScreenState extends State { ), ), Container(height: 20), - Container( - child: Column( - children: [ - Container( - height: 40, - color: Theme.of(context) - .colorScheme - .secondary - .withOpacity(.025), - child: TabBar( - tabs: [ - Tab(text: '详情 '), - Tab(text: '评论 (${info.commentsCount})'), - ], - indicatorColor: - Theme.of(context).colorScheme.secondary, - labelColor: - Theme.of(context).colorScheme.secondary, - onTap: (val) async { - setState(() { - _tabIndex = val; - }); - }, - ), + Column( + children: [ + Container( + height: 40, + color: Theme.of(context) + .colorScheme + .secondary + .withOpacity(.025), + child: TabBar( + tabs: [ + Tab(text: '详情 '), + Tab(text: '评论 (${info.commentsCount})'), + ], + indicatorColor: + Theme.of(context).colorScheme.secondary, + labelColor: + Theme.of(context).colorScheme.secondary, + onTap: (val) async { + setState(() { + _tabIndex = val; + }); + }, ), - ], - ), + ), + ], ), _tabIndex == 0 ? Container( diff --git a/lib/screens/GamesScreen.dart b/lib/screens/GamesScreen.dart index 3d4ba46..2d91daa 100644 --- a/lib/screens/GamesScreen.dart +++ b/lib/screens/GamesScreen.dart @@ -9,6 +9,8 @@ import 'components/Images.dart'; // 游戏列表 class GamesScreen extends StatefulWidget { + const GamesScreen({Key? key}) : super(key: key); + @override State createState() => _GamesScreenState(); } @@ -43,7 +45,7 @@ class _GamesScreenState extends State { List wraps = []; GameCard? gameCard; - page.docs.forEach((element) { + for (var element in page.docs) { if (gameCard == null) { gameCard = GameCard(element); } else { @@ -53,7 +55,7 @@ class _GamesScreenState extends State { )); gameCard = null; } - }); + } if (gameCard != null) { wraps.add(Wrap( children: [gameCard!], @@ -85,18 +87,16 @@ class _GamesScreenState extends State { builder: (context) { return AlertDialog( content: Card( - child: Container( - child: TextField( - controller: _textEditController, - decoration: new InputDecoration( - labelText: "请输入页数:", - ), - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp(r'\d+')), - ], + child: TextField( + controller: _textEditController, + decoration: const InputDecoration( + labelText: "请输入页数:", ), + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(r'\d+')), + ], ), ), actions: [ @@ -104,13 +104,13 @@ class _GamesScreenState extends State { onPressed: () { Navigator.pop(context); }, - child: Text('取消'), + child: const Text('取消'), ), MaterialButton( onPressed: () { Navigator.pop(context); var text = _textEditController.text; - if (text.length == 0 || text.length > 5) { + if (text.isEmpty || text.length > 5) { return; } var num = int.parse(text); @@ -119,7 +119,7 @@ class _GamesScreenState extends State { } _onPageChange(num); }, - child: Text('确定'), + child: const Text('确定'), ), ], ); @@ -186,7 +186,7 @@ class _GamesScreenState extends State { class GameCard extends StatelessWidget { final GameSimple info; - GameCard(this.info); + const GameCard(this.info, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -215,8 +215,8 @@ class GameCard extends StatelessWidget { ); }, child: Container( - padding: EdgeInsets.all(10), - child: Container( + padding: const EdgeInsets.all(10), + child: SizedBox( width: imageWidth, child: Column( children: [ diff --git a/lib/screens/InitScreen.dart b/lib/screens/InitScreen.dart index 830d160..d28b576 100644 --- a/lib/screens/InitScreen.dart +++ b/lib/screens/InitScreen.dart @@ -36,6 +36,8 @@ import 'AppScreen.dart'; // 初始化界面 class InitScreen extends StatefulWidget { + const InitScreen({Key? key}) : super(key: key); + @override State createState() => _InitScreenState(); } @@ -104,7 +106,7 @@ class _InitScreenState extends State { backgroundColor: Color(0xfffffced), body: ConstrainedBox( constraints: BoxConstraints.expand(), - child: new Image.asset( + child: Image.asset( "lib/assets/init.jpg", fit: BoxFit.contain, ), diff --git a/lib/screens/MigrateScreen.dart b/lib/screens/MigrateScreen.dart index 402cdb2..2cadb6d 100644 --- a/lib/screens/MigrateScreen.dart +++ b/lib/screens/MigrateScreen.dart @@ -8,12 +8,14 @@ import 'package:pikapika/screens/components/ContentLoading.dart'; // 数据迁移页面 class MigrateScreen extends StatefulWidget { + const MigrateScreen({Key? key}) : super(key: key); + @override State createState() => _MigrateScreenState(); } class _MigrateScreenState extends State { - late Future _future = _load(); + late final Future _future = _load(); late String _current; late List paths; String _message = ""; diff --git a/lib/screens/RegisterScreen.dart b/lib/screens/RegisterScreen.dart index 66764fd..7bce3a5 100644 --- a/lib/screens/RegisterScreen.dart +++ b/lib/screens/RegisterScreen.dart @@ -89,14 +89,14 @@ class _RegisterScreenState extends State { if (_registerOver) { return Scaffold( appBar: AppBar( - title: Text('注册成功'), + title: const Text('注册成功'), ), body: Center( child: Container( child: Column( children: [ Expanded(child: Container()), - Text('您已经注册成功, 请返回登录'), + const Text('您已经注册成功, 请返回登录'), Text('账号 : $_email'), Text('昵称 : $_name'), Expanded(child: Container()), diff --git a/lib/screens/SearchScreen.dart b/lib/screens/SearchScreen.dart index 351642b..c020d78 100644 --- a/lib/screens/SearchScreen.dart +++ b/lib/screens/SearchScreen.dart @@ -24,9 +24,9 @@ class SearchScreen extends StatefulWidget { } class _SearchScreenState extends State { - late TextEditingController _textEditController = + late final TextEditingController _textEditController = TextEditingController(text: widget.keyword); - late SearchBar _searchBar = SearchBar( + late final SearchBar _searchBar = SearchBar( hintText: '搜索 ${categoryTitle(widget.category)}', controller: _textEditController, inBar: false, diff --git a/lib/screens/SettingsScreen.dart b/lib/screens/SettingsScreen.dart index 79edd73..a04be13 100644 --- a/lib/screens/SettingsScreen.dart +++ b/lib/screens/SettingsScreen.dart @@ -34,12 +34,14 @@ import 'MigrateScreen.dart'; import 'ModifyPasswordScreen.dart'; class SettingsScreen extends StatelessWidget { + const SettingsScreen({Key? key}) : super(key: key); + @override Widget build(BuildContext context) => Scaffold( - appBar: AppBar(title: Text('设置')), + appBar: AppBar(title: const Text('设置')), body: ListView( children: [ - Divider(), + const Divider(), ListTile( onTap: () async { Navigator.push( @@ -48,11 +50,11 @@ class SettingsScreen extends StatelessWidget { builder: (context) => ModifyPasswordScreen()), ); }, - title: Text('修改密码'), + title: const Text('修改密码'), ), - Divider(), - NetworkSetting(), - Divider(), + const Divider(), + const NetworkSetting(), + const Divider(), qualitySetting(), convertToPNGSetting(), readerTypeSetting(), @@ -63,7 +65,7 @@ class SettingsScreen extends StatelessWidget { volumeControllerSetting(), keyboardControllerSetting(), noAnimationSetting(), - Divider(), + const Divider(), shadowCategoriesModeSetting(), shadowCategoriesSetting(), pagerActionSetting(), diff --git a/lib/screens/SpaceScreen.dart b/lib/screens/SpaceScreen.dart index a154626..d3afbc1 100644 --- a/lib/screens/SpaceScreen.dart +++ b/lib/screens/SpaceScreen.dart @@ -15,7 +15,8 @@ import 'components/UserProfileCard.dart'; // 个人空间页面 class SpaceScreen extends StatefulWidget { - const SpaceScreen(); + const SpaceScreen({Key? key}) : super(key: key); + @override State createState() => _SpaceScreenState(); @@ -58,17 +59,17 @@ class _SpaceScreenState extends State { ); } }, - icon: Icon(Icons.exit_to_app), + icon: const Icon(Icons.exit_to_app), ), IconButton( onPressed: () { Navigator.push( context, - MaterialPageRoute(builder: (context) => AboutScreen()), + MaterialPageRoute(builder: (context) => const AboutScreen()), ); }, icon: Badged( - child: Icon(Icons.info_outline), + child: const Icon(Icons.info_outline), badge: latestVersion() == null ? null : "1", ), ), @@ -76,18 +77,18 @@ class _SpaceScreenState extends State { onPressed: () { Navigator.push( context, - MaterialPageRoute(builder: (context) => SettingsScreen()), + MaterialPageRoute(builder: (context) => const SettingsScreen()), ); }, - icon: Icon(Icons.settings), + icon: const Icon(Icons.settings), ), ], ), body: ListView( children: [ - Divider(), - UserProfileCard(), - Divider(), + const Divider(), + const UserProfileCard(), + const Divider(), ListTile( onTap: () async { await chooseTheme(context); @@ -96,7 +97,7 @@ class _SpaceScreenState extends State { title: Text('主题'), subtitle: Text(currentThemeName()), ), - Divider(), + const Divider(), ListTile( onTap: () { Navigator.push( @@ -106,7 +107,7 @@ class _SpaceScreenState extends State { }, title: Text('我的收藏'), ), - Divider(), + const Divider(), ListTile( onTap: () { Navigator.push( @@ -116,17 +117,17 @@ class _SpaceScreenState extends State { }, title: Text('浏览记录'), ), - Divider(), + const Divider(), ListTile( onTap: () { Navigator.push( context, - MaterialPageRoute(builder: (context) => DownloadListScreen()), + MaterialPageRoute(builder: (context) => const DownloadListScreen()), ); }, - title: Text('我的下载'), + title: const Text('我的下载'), ), - Divider(), + const Divider(), ], ), ); diff --git a/lib/screens/ViewLogsScreen.dart b/lib/screens/ViewLogsScreen.dart index b663ec7..fa9c1a8 100644 --- a/lib/screens/ViewLogsScreen.dart +++ b/lib/screens/ViewLogsScreen.dart @@ -7,7 +7,7 @@ import 'components/Images.dart'; // 浏览记录 class ViewLogsScreen extends StatefulWidget { - const ViewLogsScreen(); + const ViewLogsScreen({Key? key}) : super(key: key); @override State createState() => _ViewLogsScreenState(); @@ -175,7 +175,7 @@ class ViewLogWrap extends StatelessWidget { onDelete(e.id); }, child: Card( - child: Container( + child: SizedBox( width: width, child: Column( children: [ @@ -200,7 +200,7 @@ class ViewLogWrap extends StatelessWidget { ); }); - Map> map = Map(); + Map> map = {}; for (var i = 0; i < entries.length; i++) { late List list; if (i % 4 == 0) { diff --git a/lib/screens/components/Avatar.dart b/lib/screens/components/Avatar.dart index 4c6fa2e..c10f02a 100644 --- a/lib/screens/components/Avatar.dart +++ b/lib/screens/components/Avatar.dart @@ -10,7 +10,7 @@ class Avatar extends StatelessWidget { final RemoteImageInfo avatarImage; final double size; - const Avatar(this.avatarImage, {this.size = 50}); + const Avatar(this.avatarImage, {this.size = 50, Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/screens/components/Badge.dart b/lib/screens/components/Badge.dart index d5a4dce..6abb5d2 100644 --- a/lib/screens/components/Badge.dart +++ b/lib/screens/components/Badge.dart @@ -15,21 +15,21 @@ class Badged extends StatelessWidget { return Stack( children: [ child, - new Positioned( + Positioned( right: 0, - child: new Container( - padding: EdgeInsets.all(1), - decoration: new BoxDecoration( + child: Container( + padding: const EdgeInsets.all(1), + decoration: BoxDecoration( color: Colors.red, borderRadius: BorderRadius.circular(6), ), - constraints: BoxConstraints( + constraints: const BoxConstraints( minWidth: 12, minHeight: 12, ), - child: new Text( + child: Text( badge!, - style: new TextStyle( + style: const TextStyle( color: Colors.white, fontSize: 8, ), diff --git a/lib/screens/components/ComicDescriptionCard.dart b/lib/screens/components/ComicDescriptionCard.dart index 983cada..59f4afc 100644 --- a/lib/screens/components/ComicDescriptionCard.dart +++ b/lib/screens/components/ComicDescriptionCard.dart @@ -4,13 +4,14 @@ import 'package:flutter/material.dart'; class ComicDescriptionCard extends StatelessWidget { final String description; - ComicDescriptionCard({Key? key, required this.description}) : super(key: key); + const ComicDescriptionCard({Key? key, required this.description}) + : super(key: key); @override Widget build(BuildContext context) { var theme = Theme.of(context); return Container( - padding: EdgeInsets.only( + padding: const EdgeInsets.only( top: 5, bottom: 5, left: 10, diff --git a/lib/screens/components/ComicInfoCard.dart b/lib/screens/components/ComicInfoCard.dart index f5677df..f7f4fcf 100644 --- a/lib/screens/components/ComicInfoCard.dart +++ b/lib/screens/components/ComicInfoCard.dart @@ -168,7 +168,7 @@ class _ComicInfoCard extends State { ], ), ), - Container( + SizedBox( height: imageHeight, child: Column( mainAxisAlignment: MainAxisAlignment.start, @@ -180,7 +180,7 @@ class _ComicInfoCard extends State { ? [] : [ Container(height: 10), - Container( + SizedBox( height: 26, child: _likeLoading ? IconButton( @@ -205,7 +205,7 @@ class _ComicInfoCard extends State { ? [] : [ Container(height: 10), - Container( + SizedBox( height: 26, child: _favouriteLoading ? IconButton( diff --git a/lib/screens/components/ComicList.dart b/lib/screens/components/ComicList.dart index 1cd89dd..a0ccdde 100644 --- a/lib/screens/components/ComicList.dart +++ b/lib/screens/components/ComicList.dart @@ -18,7 +18,9 @@ class ComicList extends StatefulWidget { final List comicList; final ScrollController? controller; - const ComicList(this.comicList, {this.appendWidget, this.controller}); + const ComicList(this.comicList, + {this.appendWidget, this.controller, Key? key}) + : super(key: key); @override State createState() => _ComicListState(); @@ -112,7 +114,7 @@ class _ComicListState extends State { }).toList(), ...widget.appendWidget != null ? [ - Container( + SizedBox( height: 80, child: widget.appendWidget, ), @@ -132,7 +134,7 @@ class _ComicListState extends State { var height = width * coverHeight / coverWidth; List wraps = []; List tmp = []; - widget.comicList.forEach((e) { + for (var e in widget.comicList) { var shadow = e.categories.map( (c) { switch (currentShadowCategoriesMode()) { @@ -193,12 +195,13 @@ class _ComicListState extends State { )); tmp = []; } - }); + } // 追加特殊按钮 if (widget.appendWidget != null) { tmp.add(Container( - color: (Theme.of(context).textTheme.bodyText1?.color ?? Color(0)) - .withOpacity(.1), + color: + (Theme.of(context).textTheme.bodyText1?.color ?? Colors.transparent) + .withOpacity(.1), margin: EdgeInsets.only( left: (rowCap - tmp.length) * gap, right: (rowCap - tmp.length) * gap, @@ -211,7 +214,7 @@ class _ComicListState extends State { )); } // 最后一页没有下一页所有有可能为空 - if (tmp.length > 0) { + if (tmp.isNotEmpty) { wraps.add(Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceAround, @@ -240,7 +243,7 @@ class _ComicListState extends State { double shadowFontSize = max(width / 9, 12); List wraps = []; List tmp = []; - widget.comicList.forEach((e) { + for (var e in widget.comicList) { var shadow = e.categories.map( (c) { switch (currentShadowCategoriesMode()) { @@ -330,12 +333,13 @@ class _ComicListState extends State { )); tmp = []; } - }); + } // 追加特殊按钮 if (widget.appendWidget != null) { tmp.add(Container( - color: (Theme.of(context).textTheme.bodyText1?.color ?? Color(0)) - .withOpacity(.1), + color: + (Theme.of(context).textTheme.bodyText1?.color ?? Colors.transparent) + .withOpacity(.1), margin: EdgeInsets.only( left: (rowCap - tmp.length) * gap, right: (rowCap - tmp.length) * gap, @@ -348,7 +352,7 @@ class _ComicListState extends State { )); } // 最后一页没有下一页所有有可能为空 - if (tmp.length > 0) { + if (tmp.isNotEmpty) { wraps.add(Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceAround, diff --git a/lib/screens/components/ComicListBuilder.dart b/lib/screens/components/ComicListBuilder.dart index 77c0125..489edb3 100644 --- a/lib/screens/components/ComicListBuilder.dart +++ b/lib/screens/components/ComicListBuilder.dart @@ -10,7 +10,8 @@ class ComicListBuilder extends StatefulWidget { final Future> future; final Future Function() reload; - ComicListBuilder(this.future, this.reload); + const ComicListBuilder(this.future, this.reload, {Key? key}) + : super(key: key); @override State createState() => _ComicListBuilderState(); diff --git a/lib/screens/components/ComicPager.dart b/lib/screens/components/ComicPager.dart index e04b0b0..28b8f92 100644 --- a/lib/screens/components/ComicPager.dart +++ b/lib/screens/components/ComicPager.dart @@ -153,17 +153,15 @@ class _ControllerComicPagerState extends State { builder: (context) { return AlertDialog( content: Card( - child: Container( - child: TextField( - controller: _textEditController, - decoration: new InputDecoration( - labelText: "请输入页数:", - ), - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.allow(RegExp(r'\d+')), - ], + child: TextField( + controller: _textEditController, + decoration: const InputDecoration( + labelText: "请输入页数:", ), + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.allow(RegExp(r'\d+')), + ], ), ), actions: [ @@ -177,7 +175,7 @@ class _ControllerComicPagerState extends State { onPressed: () { Navigator.pop(context); var text = _textEditController.text; - if (text.length == 0 || text.length > 5) { + if (text.isEmpty || text.length > 5) { return; } var num = int.parse(text); @@ -240,6 +238,7 @@ class _ControllerComicPagerState extends State { text: '下一页', ); } + return null; } } @@ -391,5 +390,6 @@ class _StreamComicPagerState extends State { if (_loading) { return FitButton(onPressed: () {}, text: '加载中'); } + return null; } } diff --git a/lib/screens/components/CommentItem.dart b/lib/screens/components/CommentItem.dart index c744d55..1d542ef 100644 --- a/lib/screens/components/CommentItem.dart +++ b/lib/screens/components/CommentItem.dart @@ -11,7 +11,8 @@ class ComicCommentItem extends StatefulWidget { final String mainId; final CommentBase comment; - const ComicCommentItem(this.mainType, this.mainId, this.comment); + const ComicCommentItem(this.mainType, this.mainId, this.comment, {Key? key}) + : super(key: key); @override State createState() => _ComicCommentItemState(); @@ -24,7 +25,7 @@ class _ComicCommentItemState extends State { Widget build(BuildContext context) { var comment = widget.comment; var theme = Theme.of(context); - var nameStyle = TextStyle(fontWeight: FontWeight.bold); + var nameStyle = const TextStyle(fontWeight: FontWeight.bold); var levelStyle = TextStyle( fontSize: 12, color: theme.colorScheme.secondary.withOpacity(.8)); var connectStyle = @@ -32,7 +33,7 @@ class _ComicCommentItemState extends State { var datetimeStyle = TextStyle( color: theme.textTheme.bodyText1?.color?.withOpacity(.6), fontSize: 12); return Container( - padding: EdgeInsets.all(5), + padding: const EdgeInsets.all(5), decoration: BoxDecoration( border: Border( top: BorderSide( @@ -58,7 +59,7 @@ class _ComicCommentItemState extends State { children: [ LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { - return Container( + return SizedBox( width: constraints.maxWidth, child: Wrap( crossAxisAlignment: WrapCrossAlignment.center, @@ -77,7 +78,7 @@ class _ComicCommentItemState extends State { Container(height: 3), LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { - return Container( + return SizedBox( width: constraints.maxWidth, child: Wrap( crossAxisAlignment: WrapCrossAlignment.center, @@ -103,7 +104,7 @@ class _ComicCommentItemState extends State { text: '${comment.commentsCount}', ), ]) - : TextSpan(), + : const TextSpan(), WidgetSpan(child: Container(width: 12)), WidgetSpan( child: GestureDetector( @@ -136,6 +137,7 @@ class _ComicCommentItemState extends State { } }); } catch (e, s) { + print("$e\n$s"); defaultToast(context, "点赞失败"); } finally { setState(() { diff --git a/lib/screens/components/ContentError.dart b/lib/screens/components/ContentError.dart index 40bed73..5ab1a1a 100644 --- a/lib/screens/components/ContentError.dart +++ b/lib/screens/components/ContentError.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:pikapika/basic/config/ContentFailedReloadAction.dart'; -import 'dart:ui'; import 'package:pikapika/basic/enum/ErrorTypes.dart'; @@ -60,21 +59,19 @@ class ContentError extends StatelessWidget { onTap: onRefresh, child: ListView( children: [ - Container( + SizedBox( height: height, child: Column( children: [ Expanded(child: Container()), - Container( - child: Icon( - iconData, - size: iconSize, - color: Colors.grey.shade600, - ), + Icon( + iconData, + size: iconSize, + color: Colors.grey.shade600, ), Container(height: min / 10), Container( - padding: EdgeInsets.only( + padding: const EdgeInsets.only( left: 30, right: 30, ), @@ -99,21 +96,19 @@ class ContentError extends StatelessWidget { onRefresh: onRefresh, child: ListView( children: [ - Container( + SizedBox( height: height, child: Column( children: [ Expanded(child: Container()), - Container( - child: Icon( - iconData, - size: iconSize, - color: Colors.grey.shade600, - ), + Icon( + iconData, + size: iconSize, + color: Colors.grey.shade600, ), Container(height: min / 10), Container( - padding: EdgeInsets.only( + padding: const EdgeInsets.only( left: 30, right: 30, ), diff --git a/lib/screens/components/DownloadInfoCard.dart b/lib/screens/components/DownloadInfoCard.dart index 0fe6cd6..e4e68c4 100644 --- a/lib/screens/components/DownloadInfoCard.dart +++ b/lib/screens/components/DownloadInfoCard.dart @@ -115,53 +115,43 @@ class DownloadInfoCard extends StatelessWidget { ), Container(width: 20), task.deleting - ? Container( - child: Text('删除中', + ? Text('删除中', + style: TextStyle( + color: Color.alphaBlend( + textColor.withAlpha(0x33), + Colors.red.shade500))) + : task.downloadFailed + ? Text('下载失败', style: TextStyle( color: Color.alphaBlend( textColor.withAlpha(0x33), - Colors.red.shade500))), - ) - : task.downloadFailed - ? Container( - child: Text('下载失败', + Colors.red.shade500))) + : task.downloadFinished + ? Text('下载完成', style: TextStyle( color: Color.alphaBlend( - textColor.withAlpha(0x33), - Colors.red.shade500))), - ) - : task.downloadFinished - ? Container( - child: Text('下载完成', + textColorAlpha, + Colors.green.shade500))) + : downloading // downloader.downloadingTask() == task.id + ? Text('下载中', style: TextStyle( color: Color.alphaBlend( textColorAlpha, - Colors.green.shade500))), - ) - : downloading // downloader.downloadingTask() == task.id - ? Container( - child: Text('下载中', - style: TextStyle( - color: Color.alphaBlend( - textColorAlpha, - Colors - .blue.shade500))), - ) - : Container( - child: Text('队列中', - style: TextStyle( - color: Color.alphaBlend( - textColorAlpha, - Colors.lightBlue - .shade500))), - ), + Colors + .blue.shade500))) + : Text('队列中', + style: TextStyle( + color: Color.alphaBlend( + textColorAlpha, + Colors.lightBlue + .shade500))), ], ), ], ), ), Container( - padding: EdgeInsets.only(left: 8), + padding: const EdgeInsets.only(left: 8), height: imageHeight, child: Column( mainAxisAlignment: MainAxisAlignment.start, diff --git a/lib/screens/components/FitButton.dart b/lib/screens/components/FitButton.dart index 67f625e..1bfb043 100644 --- a/lib/screens/components/FitButton.dart +++ b/lib/screens/components/FitButton.dart @@ -15,13 +15,11 @@ class FitButton extends StatelessWidget { width: constraints.maxWidth, height: constraints.maxHeight, child: Container( - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), child: MaterialButton( onPressed: onPressed, - child: Container( - child: Center( - child: Text(text), - ), + child: Center( + child: Text(text), ), ), ), diff --git a/lib/screens/components/GameTitleCard.dart b/lib/screens/components/GameTitleCard.dart index 77b0d2c..c9465ef 100644 --- a/lib/screens/components/GameTitleCard.dart +++ b/lib/screens/components/GameTitleCard.dart @@ -9,21 +9,20 @@ import 'Images.dart'; class GameTitleCard extends StatelessWidget { final GameInfo info; - const GameTitleCard(this.info); + const GameTitleCard(this.info, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { double iconMargin = 20; double iconSize = 60; - BorderRadius iconRadius = BorderRadius.all(Radius.circular(6)); - TextStyle titleStyle = TextStyle(fontSize: 16, fontWeight: FontWeight.bold); + BorderRadius iconRadius = const BorderRadius.all(Radius.circular(6)); + TextStyle titleStyle = + const TextStyle(fontSize: 16, fontWeight: FontWeight.bold); TextStyle publisherStyle = TextStyle( color: Theme.of(context).colorScheme.secondary, fontSize: 12.5, ); - TextStyle versionStyle = TextStyle( - fontSize: 12.5, - ); + TextStyle versionStyle = const TextStyle(fontSize: 12.5); double platformMargin = 10; double platformSize = 25; return Row( diff --git a/lib/screens/components/ImageReader.dart b/lib/screens/components/ImageReader.dart index 826d7b0..d4ea653 100644 --- a/lib/screens/components/ImageReader.dart +++ b/lib/screens/components/ImageReader.dart @@ -139,7 +139,7 @@ class ImageReaderStruct { class ImageReader extends StatefulWidget { final ImageReaderStruct struct; - const ImageReader(this.struct); + const ImageReader(this.struct, {Key? key}) : super(key: key); @override State createState() => _ImageReaderState(); @@ -153,9 +153,9 @@ class _ImageReaderState extends State { final ReaderType _pagerType = currentReaderType(); // 记录了控制器 - late FullScreenAction _fullScreenAction = currentFullScreenAction(); + late final FullScreenAction _fullScreenAction = currentFullScreenAction(); - late ReaderSliderPosition _readerSliderPosition = + late final ReaderSliderPosition _readerSliderPosition = currentReaderSliderPosition(); @override @@ -245,7 +245,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { void _onPageControl(_ReaderControllerEventArgs? args) { if (args != null) { var event = args.key; - switch ("$event") { + switch (event) { case "UP": if (_current > 0) { _needJumpTo(_current - 1, true); @@ -369,7 +369,6 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { ], ); } - return Container(); } Widget _buildAppBar() => widget.struct.fullScreen @@ -393,7 +392,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { return Column( children: [ Expanded(child: Container()), - Container( + SizedBox( height: 25, child: _buildSliderWidget(Axis.horizontal), ), @@ -407,7 +406,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { : Align( alignment: Alignment.centerLeft, child: Material( - color: Color(0x0), + color: Colors.transparent, child: Container( width: 35, height: 300, @@ -431,7 +430,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { : Align( alignment: Alignment.centerRight, child: Material( - color: Color(0x0), + color: Colors.transparent, child: Container( width: 35, height: 300, @@ -525,7 +524,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { return Align( alignment: Alignment.bottomLeft, child: Material( - color: Color(0x0), + color: Colors.transparent, child: Container( padding: EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4), margin: EdgeInsets.only(bottom: 10), @@ -577,8 +576,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { return GestureDetector( behavior: HitTestBehavior.translucent, onTap: () { - _readerControllerEvent - .broadcast(_ReaderControllerEventArgs("DOWN")); + _readerControllerEvent.broadcast(_ReaderControllerEventArgs("DOWN")); }, onDoubleTap: () { widget.struct.onFullScreenChange(!widget.struct.fullScreen); @@ -656,7 +654,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { context: context, backgroundColor: Color(0xAA000000), builder: (context) { - return Container( + return SizedBox( height: MediaQuery.of(context).size.height * (.45), child: _EpChooser( widget.struct.epNameMap, @@ -677,7 +675,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> { context: context, backgroundColor: Color(0xAA000000), builder: (context) { - return Container( + return SizedBox( height: MediaQuery.of(context).size.height * (.45), child: _SettingPanel( widget.struct.onReloadEp, @@ -749,11 +747,11 @@ class _EpChooserState extends State<_EpChooser> { Container(height: 20), ...entries.map((e) { return Container( - margin: EdgeInsets.only(left: 15, right: 15, top: 5, bottom: 5), + margin: const EdgeInsets.only(left: 15, right: 15, top: 5, bottom: 5), decoration: BoxDecoration( color: widget.epOrder == e.key ? Colors.grey.withAlpha(100) : null, border: Border.all( - color: Color(0xff484c60), + color: const Color(0xff484c60), style: BorderStyle.solid, width: .5, ), @@ -764,7 +762,7 @@ class _EpChooserState extends State<_EpChooser> { widget.onChangeEp(e.key); }, textColor: Colors.white, - child: Text('${e.value}'), + child: Text(e.value), ), ); }) @@ -792,78 +790,74 @@ class _SettingPanelState extends State<_SettingPanel> { Widget build(BuildContext context) { return ListView( children: [ - Container( - child: Row( - children: [ - _bottomIcon( - icon: Icons.crop_sharp, - title: gReaderDirectionName(), - onPressed: () async { - await choosePagerDirection(context); - setState(() {}); - }, - ), - _bottomIcon( - icon: Icons.view_day_outlined, - title: currentReaderTypeName(), - onPressed: () async { - await choosePagerType(context); - setState(() {}); - }, - ), - _bottomIcon( - icon: Icons.image_aspect_ratio_outlined, - title: currentQualityName(), - onPressed: () async { - await chooseQuality(context); - setState(() {}); - }, - ), - _bottomIcon( - icon: Icons.control_camera_outlined, - title: currentFullScreenActionName(), - onPressed: () async { - await chooseFullScreenAction(context); - setState(() {}); - }, - ), - ], - ), + Row( + children: [ + _bottomIcon( + icon: Icons.crop_sharp, + title: gReaderDirectionName(), + onPressed: () async { + await choosePagerDirection(context); + setState(() {}); + }, + ), + _bottomIcon( + icon: Icons.view_day_outlined, + title: currentReaderTypeName(), + onPressed: () async { + await choosePagerType(context); + setState(() {}); + }, + ), + _bottomIcon( + icon: Icons.image_aspect_ratio_outlined, + title: currentQualityName(), + onPressed: () async { + await chooseQuality(context); + setState(() {}); + }, + ), + _bottomIcon( + icon: Icons.control_camera_outlined, + title: currentFullScreenActionName(), + onPressed: () async { + await chooseFullScreenAction(context); + setState(() {}); + }, + ), + ], ), - Container( - child: Row( - children: [ - _bottomIcon( - icon: Icons.shuffle, - title: currentAddressName(), - onPressed: () async { - await chooseAddress(context); - setState(() {}); - }, - ), - _bottomIcon( - icon: Icons.repeat_one, - title: currentImageAddressName(), - onPressed: () async { - await chooseImageAddress(context); - setState(() {}); - }, - ), - _bottomIcon( - icon: Icons.refresh, - title: "重载页面", - onPressed: () { - Navigator.of(context).pop(); - widget.onReloadEp(); - }, - ), - _bottomIcon( - icon: Icons.file_download, - title: "下载本作", - onPressed: widget.onDownload, - ), - ], - ), + Row( + children: [ + _bottomIcon( + icon: Icons.shuffle, + title: currentAddressName(), + onPressed: () async { + await chooseAddress(context); + setState(() {}); + }, + ), + _bottomIcon( + icon: Icons.repeat_one, + title: currentImageAddressName(), + onPressed: () async { + await chooseImageAddress(context); + setState(() {}); + }, + ), + _bottomIcon( + icon: Icons.refresh, + title: "重载页面", + onPressed: () { + Navigator.of(context).pop(); + widget.onReloadEp(); + }, + ), + _bottomIcon( + icon: Icons.file_download, + title: "下载本作", + onPressed: widget.onDownload, + ), + ], ), ], ); @@ -917,13 +911,13 @@ class _WebToonReaderState extends _ImageReaderContentState { @override void initState() { - widget.struct.images.forEach((e) { + for (var e in widget.struct.images) { if (e.downloadLocalPath != null) { _trueSizes.add(Size(e.width!.toDouble(), e.height!.toDouble())); } else { _trueSizes.add(null); } - }); + } _itemScrollController = ItemScrollController(); _itemPositionsListener = ItemPositionsListener.create(); _itemPositionsListener.itemPositions.addListener(_onListCurrentChange); @@ -1077,7 +1071,7 @@ class _WebToonReaderState extends _ImageReaderContentState { } return Container( color: Colors.transparent, - padding: EdgeInsets.all(20), + padding: const EdgeInsets.all(20), child: MaterialButton( onPressed: () { if (super._hasNextEp()) { @@ -1238,18 +1232,18 @@ class _ListViewReaderState extends _ImageReaderContentState late TapDownDetails _doubleTapDetails; late final _animationController = AnimationController( vsync: this, - duration: Duration(milliseconds: 100), + duration: const Duration(milliseconds: 100), ); @override void initState() { - widget.struct.images.forEach((e) { + for (var e in widget.struct.images) { if (e.downloadLocalPath != null) { _trueSizes.add(Size(e.width!.toDouble(), e.height!.toDouble())); } else { _trueSizes.add(null); } - }); + } super.initState(); } @@ -1467,6 +1461,7 @@ class _GalleryReaderState extends _ImageReaderContentState { } } + @override Widget _buildViewer() { Widget gallery = PhotoViewGallery.builder( scrollDirection: widget.pagerDirection == ReaderDirection.TOP_TO_BOTTOM @@ -1574,7 +1569,7 @@ class _GalleryReaderState extends _ImageReaderContentState { return Align( alignment: Alignment.bottomRight, child: Material( - color: Color(0x0), + color: Colors.transparent, child: Container( margin: EdgeInsets.only(bottom: 10), padding: EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4), diff --git a/lib/screens/components/Images.dart b/lib/screens/components/Images.dart index b8b8a1c..a344850 100644 --- a/lib/screens/components/Images.dart +++ b/lib/screens/components/Images.dart @@ -181,7 +181,7 @@ class DownloadImage extends StatefulWidget { } class _DownloadImageState extends State { - late Future _future = method.downloadImagePath(widget.path); + late final Future _future = method.downloadImagePath(widget.path); @override Widget build(BuildContext context) { @@ -276,7 +276,7 @@ Widget buildSvg(String source, double? width, double? height, var widget = Container( width: width, height: height, - padding: margin != null ? EdgeInsets.all(10) : null, + padding: margin != null ? const EdgeInsets.all(10) : null, child: Center( child: SvgPicture.asset( source, @@ -319,7 +319,7 @@ Widget buildLoading(double? width, double? height) { if (width != null && height != null) { size = width < height ? width : height; } - return Container( + return SizedBox( width: width, height: height, child: Center( diff --git a/lib/screens/components/ItemBuilder.dart b/lib/screens/components/ItemBuilder.dart index a73563a..42d3a14 100644 --- a/lib/screens/components/ItemBuilder.dart +++ b/lib/screens/components/ItemBuilder.dart @@ -31,7 +31,7 @@ class ItemBuilder extends StatelessWidget { print("${snapshot.stackTrace}"); return InkWell( onTap: onRefresh, - child: Container( + child: SizedBox( width: _maxWidth, height: _loadingHeight, child: Center( @@ -42,7 +42,7 @@ class ItemBuilder extends StatelessWidget { ); } if (snapshot.connectionState != ConnectionState.done) { - return Container( + return SizedBox( width: _maxWidth, height: _loadingHeight, child: Center( @@ -50,7 +50,7 @@ class ItemBuilder extends StatelessWidget { ), ); } - return Container( + return SizedBox( width: _maxWidth, height: height, child: successBuilder(context, snapshot), diff --git a/lib/screens/components/LinkToComicInfo.dart b/lib/screens/components/LinkToComicInfo.dart index db787f8..1f68d4c 100644 --- a/lib/screens/components/LinkToComicInfo.dart +++ b/lib/screens/components/LinkToComicInfo.dart @@ -10,7 +10,8 @@ class LinkToComicInfo extends StatelessWidget { const LinkToComicInfo({ required this.comicId, required this.child, - }); + Key? key, + }):super(key: key); @override Widget build(BuildContext context) => InkWell( diff --git a/lib/screens/components/NetworkSetting.dart b/lib/screens/components/NetworkSetting.dart index df4f19c..46e4a00 100644 --- a/lib/screens/components/NetworkSetting.dart +++ b/lib/screens/components/NetworkSetting.dart @@ -5,16 +5,16 @@ import 'package:pikapika/basic/config/Proxy.dart'; // 网络设置 class NetworkSetting extends StatelessWidget { + const NetworkSetting({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( - child: Column( - children: [ - switchAddressSetting(), - imageSwitchAddressSetting(), - proxySetting(), - ], - ), + return Column( + children: [ + switchAddressSetting(), + imageSwitchAddressSetting(), + proxySetting(), + ], ); } } diff --git a/lib/screens/components/Recommendation.dart b/lib/screens/components/Recommendation.dart index 83fc90d..44c0ba9 100644 --- a/lib/screens/components/Recommendation.dart +++ b/lib/screens/components/Recommendation.dart @@ -44,7 +44,7 @@ class _RecommendationState extends State { (route) => i++ < 10); }, child: Card( - child: Container( + child: SizedBox( width: width, child: Column( children: [ @@ -60,8 +60,8 @@ class _RecommendationState extends State { e.title + '\n', maxLines: 2, overflow: TextOverflow.ellipsis, - style: TextStyle(height: 1.4), - strutStyle: StrutStyle(height: 1.4), + style: const TextStyle(height: 1.4), + strutStyle: const StrutStyle(height: 1.4), ), ], ), diff --git a/lib/screens/components/UserProfileCard.dart b/lib/screens/components/UserProfileCard.dart index bead9ce..b7ceb45 100644 --- a/lib/screens/components/UserProfileCard.dart +++ b/lib/screens/components/UserProfileCard.dart @@ -16,6 +16,8 @@ const double _cardHeight = 180; // 用户信息卡 class UserProfileCard extends StatefulWidget { + const UserProfileCard({Key? key}) : super(key: key); + @override State createState() => _UserProfileCardState(); } @@ -46,11 +48,11 @@ class _UserProfileCardState extends State { @override Widget build(BuildContext context) { var theme = Theme.of(context); - var nameStyle = TextStyle( + var nameStyle = const TextStyle( fontSize: 14, fontWeight: FontWeight.bold, ); - var nameStrutStyle = StrutStyle( + var nameStrutStyle = const StrutStyle( fontSize: 14, forceStrutHeight: true, fontWeight: FontWeight.bold, @@ -60,7 +62,7 @@ class _UserProfileCardState extends State { color: theme.colorScheme.secondary.withOpacity(.9), fontWeight: FontWeight.bold, ); - var levelStrutStyle = StrutStyle( + var levelStrutStyle = const StrutStyle( fontSize: 12, forceStrutHeight: true, fontWeight: FontWeight.bold, @@ -69,7 +71,7 @@ class _UserProfileCardState extends State { fontSize: 10, color: theme.textTheme.bodyText1?.color?.withOpacity(.5), ); - var sloganStrutStyle = StrutStyle( + var sloganStrutStyle = const StrutStyle( fontSize: 10, forceStrutHeight: true, ); @@ -84,34 +86,32 @@ class _UserProfileCardState extends State { UserProfile profile = snapshot.data!; return Stack( children: [ - Container( - child: Stack( - children: [ - Opacity( - opacity: .25, // - child: LayoutBuilder( - builder: - (BuildContext context, BoxConstraints constraints) { - return RemoteImage( - path: profile.avatar.path, - fileServer: profile.avatar.fileServer, - width: constraints.maxWidth, - height: _cardHeight, - ); - }, - ), + Stack( + children: [ + Opacity( + opacity: .25, // + child: LayoutBuilder( + builder: + (BuildContext context, BoxConstraints constraints) { + return RemoteImage( + path: profile.avatar.path, + fileServer: profile.avatar.fileServer, + width: constraints.maxWidth, + height: _cardHeight, + ); + }, ), - Positioned.fromRect( - rect: Rect.largest, - child: BackdropFilter( - filter: ImageFilter.blur(sigmaX: 30, sigmaY: 30), - child: Container(), - ), + ), + Positioned.fromRect( + rect: Rect.largest, + child: BackdropFilter( + filter: ImageFilter.blur(sigmaX: 30, sigmaY: 30), + child: Container(), ), - ], - ), + ), + ], ), - Container( + SizedBox( height: _cardHeight, child: Column( children: [ @@ -177,7 +177,7 @@ class _UserProfileCardState extends State { aspectRatioPresets: [ CropAspectRatioPreset.square, ], - aspectRatio: CropAspectRatio(ratioX: 200, ratioY: 200), + aspectRatio: const CropAspectRatio(ratioX: 200, ratioY: 200), maxWidth: 200, maxHeight: 200, androidUiSettings: AndroidUiSettings( @@ -187,7 +187,7 @@ class _UserProfileCardState extends State { initAspectRatio: CropAspectRatioPreset.original, lockAspectRatio: true, ), - iosUiSettings: IOSUiSettings( + iosUiSettings: const IOSUiSettings( resetAspectRatioEnabled: true, aspectRatioLockEnabled: true, title: "修改头像", diff --git a/lib/screens/components/gesture_zoom_box.dart b/lib/screens/components/gesture_zoom_box.dart index 0badbdd..73b9b32 100644 --- a/lib/screens/components/gesture_zoom_box.dart +++ b/lib/screens/components/gesture_zoom_box.dart @@ -36,7 +36,7 @@ class _GestureZoomBoxState extends State bool _isScaling = false; bool _isDragging = false; - double _maxDragOver = 100; // 拖动超出边界的最大值 + final double _maxDragOver = 100; // 拖动超出边界的最大值 @override void initState() { diff --git a/pubspec.lock b/pubspec.lock index 6b71527..2d7747d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -104,6 +104,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.5.1" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" flutter_localizations: dependency: transitive description: flutter @@ -174,7 +181,7 @@ packages: name: image_picker url: "https://pub.dartlang.org" source: hosted - version: "0.8.4+9" + version: "0.8.4+11" image_picker_for_web: dependency: transitive description: @@ -210,6 +217,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.6.3" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -237,14 +251,14 @@ packages: name: modal_bottom_sheet url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" multi_select_flutter: dependency: "direct main" description: name: multi_select_flutter url: "https://pub.dartlang.org" source: hosted - version: "4.0.0" + version: "4.1.2" path: dependency: transitive description: @@ -417,7 +431,7 @@ packages: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.0.9" url_launcher_windows: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index d499d96..378eebd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -49,6 +49,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + flutter_lints: ^1.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/test/widget_test.dart b/test/widget_test.dart index d672e3c..2892f88 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -13,7 +13,7 @@ import 'package:pikapika/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(PikapikaApp()); + await tester.pumpWidget(const PikapikaApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget);