add lint rules

This commit is contained in:
niuhuan 2022-03-17 11:31:25 +08:00
parent 6842d323e8
commit be634e763a
67 changed files with 503 additions and 498 deletions

8
analysis_options.yaml Normal file
View File

@ -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

View File

@ -360,7 +360,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 5BU82VSTV4; DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0; IPHONEOS_DEPLOYMENT_TARGET = 11.0;
@ -492,7 +492,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 5BU82VSTV4; DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0; IPHONEOS_DEPLOYMENT_TARGET = 11.0;
@ -516,7 +516,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 5BU82VSTV4; DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0; IPHONEOS_DEPLOYMENT_TARGET = 11.0;

View File

@ -7,7 +7,7 @@ import 'package:flutter/services.dart';
// Flutter的EventChannel只能订阅一次, golang的的通信, // Flutter的EventChannel只能订阅一次, golang的的通信,
// eventName订阅和取消订阅 // eventName订阅和取消订阅
var _eventChannel = EventChannel("flatEvent"); var _eventChannel = const EventChannel("flatEvent");
StreamSubscription? _eventChannelListen; StreamSubscription? _eventChannelListen;
Map<void Function(String args), String> _eventMap = {}; Map<void Function(String args), String> _eventMap = {};
@ -28,7 +28,7 @@ void unregisterEvent(void Function(String args) eventHandler) {
throw 'no register'; throw 'no register';
} }
_eventMap.remove(eventHandler); _eventMap.remove(eventHandler);
if (_eventMap.length == 0) { if (_eventMap.isEmpty) {
_eventChannelListen?.cancel(); _eventChannelListen?.cancel();
} }
} }

View File

@ -19,8 +19,8 @@ void defaultToast(BuildContext context, String title) {
position: StyledToastPosition.center, position: StyledToastPosition.center,
animation: StyledToastAnimation.scale, animation: StyledToastAnimation.scale,
reverseAnimation: StyledToastAnimation.fade, reverseAnimation: StyledToastAnimation.fade,
duration: Duration(seconds: 4), duration: const Duration(seconds: 4),
animDuration: Duration(seconds: 1), animDuration: const Duration(seconds: 1),
curve: Curves.elasticOut, curve: Curves.elasticOut,
reverseCurve: Curves.linear, reverseCurve: Curves.linear,
); );
@ -33,22 +33,20 @@ Future<bool> confirmDialog(
context: context, context: context,
builder: (context) => AlertDialog( builder: (context) => AlertDialog(
title: Text(title), title: Text(title),
content: new SingleChildScrollView( content: SingleChildScrollView(
child: new ListBody( child: ListBody(
children: <Widget>[ children: <Widget>[Text(content)],
new Text(content),
],
), ),
), ),
actions: <Widget>[ actions: <Widget>[
new MaterialButton( MaterialButton(
child: new Text('取消'), child: const Text('取消'),
onPressed: () { onPressed: () {
Navigator.of(context).pop(false); Navigator.of(context).pop(false);
}, },
), ),
new MaterialButton( MaterialButton(
child: new Text('确定'), child: const Text('确定'),
onPressed: () { onPressed: () {
Navigator.of(context).pop(true); Navigator.of(context).pop(true);
}, },
@ -61,35 +59,36 @@ Future<bool> confirmDialog(
/// ///
Future alertDialog(BuildContext context, String title, String content) { Future alertDialog(BuildContext context, String title, String content) {
return showDialog( return showDialog(
context: context, context: context,
builder: (context) => AlertDialog( builder: (context) => AlertDialog(
title: Text(title), title: Text(title),
content: new SingleChildScrollView( content: SingleChildScrollView(
child: new ListBody( child: ListBody(
children: <Widget>[ children: <Widget>[
new Text(content), Text(content),
], ],
), ),
), ),
actions: <Widget>[ actions: <Widget>[
new MaterialButton( MaterialButton(
child: new Text('确定'), child: const Text('确定'),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
), ),
], ],
)); ),
);
} }
/// stream-filter的替代方法 /// stream-filter的替代方法
List<T> filteredList<T>(List<T> list, bool Function(T) filter) { List<T> filteredList<T>(List<T> list, bool Function(T) filter) {
List<T> result = []; List<T> result = [];
list.forEach((element) { for (var element in list) {
if (filter(element)) { if (filter(element)) {
result.add(element); result.add(element);
} }
}); }
return result; return result;
} }
@ -197,7 +196,7 @@ Future<String?> displayTextInputDialog(BuildContext context,
}, },
), ),
MaterialButton( MaterialButton(
child: Text('确认'), child: const Text('确认'),
onPressed: () { onPressed: () {
Navigator.of(context).pop(_controller.text); Navigator.of(context).pop(_controller.text);
}, },
@ -258,12 +257,10 @@ Future<String?> inputString(BuildContext context, String title,
child: ListBody( child: ListBody(
children: [ children: [
Text(title), Text(title),
Container( TextField(
child: TextField( controller: _textEditController,
controller: _textEditController, decoration: InputDecoration(
decoration: new InputDecoration( labelText: hint,
labelText: "$hint",
),
), ),
), ),
], ],
@ -275,13 +272,13 @@ Future<String?> inputString(BuildContext context, String title,
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
}, },
child: Text('取消'), child: const Text('取消'),
), ),
MaterialButton( MaterialButton(
onPressed: () { onPressed: () {
Navigator.pop(context, _textEditController.text); Navigator.pop(context, _textEditController.text);
}, },
child: Text('确定'), child: const Text('确定'),
), ),
], ],
); );

View File

@ -13,7 +13,7 @@ class Method {
Method._(); Method._();
/// channel /// channel
MethodChannel _channel = MethodChannel("method"); final MethodChannel _channel = const MethodChannel("method");
/// , golang进行通信 /// , golang进行通信
Future<dynamic> _flatInvoke(String method, dynamic params) { Future<dynamic> _flatInvoke(String method, dynamic params) {

View File

@ -29,7 +29,7 @@ Future<void> _chooseAndroidDisplayMode(BuildContext context) async {
list.addAll(_modes); list.addAll(_modes);
String? result = await chooseListDialog<String>(context, "安卓屏幕刷新率", list); String? result = await chooseListDialog<String>(context, "安卓屏幕刷新率", list);
if (result != null) { if (result != null) {
await method.saveProperty(_propertyName, "$result"); await method.saveProperty(_propertyName, result);
_androidDisplayMode = result; _androidDisplayMode = result;
await _changeMode(); await _changeMode();
} }

View File

@ -2,7 +2,6 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:pikapika/basic/Common.dart'; import 'package:pikapika/basic/Common.dart';
import 'package:pikapika/basic/Cross.dart'; import 'package:pikapika/basic/Cross.dart';

View File

@ -1,6 +1,5 @@
/// 线 /// 线
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:pikapika/basic/Common.dart'; import 'package:pikapika/basic/Common.dart';
import 'package:pikapika/basic/Method.dart'; import 'package:pikapika/basic/Method.dart';

View File

@ -67,6 +67,8 @@ void switchFullScreenUI() {
case FullScreenUI.ALL: case FullScreenUI.ALL:
list.clear(); list.clear();
break; break;
case FullScreenUI.NO:
break;
} }
if (Platform.isAndroid || Platform.isIOS) { if (Platform.isAndroid || Platform.isIOS) {
SystemChrome.setEnabledSystemUIOverlays(list); SystemChrome.setEnabledSystemUIOverlays(list);
@ -78,7 +80,7 @@ Widget fullScreenUISetting() {
return StatefulBuilder( return StatefulBuilder(
builder: (BuildContext context, void Function(void Function()) setState) { builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile( return ListTile(
title: Text("全屏UI"), title: const Text("全屏UI"),
subtitle: Text(currentFullScreenUIName()), subtitle: Text(currentFullScreenUIName()),
onTap: () async { onTap: () async {
await chooseFullScreenUI(context); await chooseFullScreenUI(context);

View File

@ -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 galleryPrePreloadCount = 1;
const galleryPreloadCount = 2; const galleryPreloadCount = 2;

View File

@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../Method.dart'; import '../Method.dart';

View File

@ -1,5 +1,3 @@
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../Common.dart'; import '../Common.dart';

View File

@ -9,6 +9,7 @@ late String _currentProxy;
Future<String?> initProxy() async { Future<String?> initProxy() async {
_currentProxy = await method.getProxy(); _currentProxy = await method.getProxy();
return null;
} }
String currentProxyName() { String currentProxyName() {

View File

@ -3,7 +3,6 @@
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/material.dart'; 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 'package:multi_select_flutter/multi_select_flutter.dart';
import '../Method.dart'; import '../Method.dart';
@ -33,11 +32,11 @@ Future<void> _chooseShadowCategories(BuildContext context) async {
context: context, context: context,
builder: (ctx) { builder: (ctx) {
var initialValue = <String>[]; var initialValue = <String>[];
shadowCategories.forEach((element) { for (var element in shadowCategories) {
if (shadowCategories.contains(element)) { if (shadowCategories.contains(element)) {
initialValue.add(element); initialValue.add(element);
} }
}); }
return MultiSelectDialog<String>( return MultiSelectDialog<String>(
title: Text('封印'), title: Text('封印'),
searchHint: '搜索', searchHint: '搜索',

View File

@ -380,7 +380,7 @@ Future<dynamic> chooseTheme(BuildContext buildContext) async {
) )
)); ));
return SimpleDialog( return SimpleDialog(
title: Text("选择主题"), title: const Text("选择主题"),
children: list, children: list,
); );
}) })

View File

@ -31,7 +31,7 @@ Future<void> _chooseTimeZone(BuildContext context) async {
result = result.substring(1); result = result.substring(1);
} }
_timeOffsetHour = int.parse(result); _timeOffsetHour = int.parse(result);
await method.saveProperty(_propertyName, "$result"); await method.saveProperty(_propertyName, result);
} }
} }

View File

@ -9,6 +9,8 @@ const _releasesUrl = "https://github.com/niuhuan/pikapika/releases";
// //
class AboutScreen extends StatefulWidget { class AboutScreen extends StatefulWidget {
const AboutScreen({Key? key}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _AboutScreenState(); State<StatefulWidget> createState() => _AboutScreenState();
} }
@ -40,11 +42,11 @@ class _AboutScreenState extends State<AboutScreen> {
var _dirty = dirtyVersion(); var _dirty = dirtyVersion();
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text('关于'), title: const Text('关于'),
), ),
body: ListView( body: ListView(
children: [ children: [
Container( SizedBox(
width: min / 2, width: min / 2,
height: min / 2, height: min / 2,
child: Center( child: Center(

View File

@ -13,6 +13,8 @@ import 'components/ContentLoading.dart';
// //
class AccountScreen extends StatefulWidget { class AccountScreen extends StatefulWidget {
const AccountScreen({Key? key}) : super(key: key);
@override @override
_AccountScreenState createState() => _AccountScreenState(); _AccountScreenState createState() => _AccountScreenState();
} }

View File

@ -31,8 +31,8 @@ class _AppScreenState extends State<AppScreen> {
} }
static const List<Widget> _widgetOptions = <Widget>[ static const List<Widget> _widgetOptions = <Widget>[
const CategoriesScreen(), CategoriesScreen(),
const SpaceScreen(), SpaceScreen(),
]; ];
late int _selectedIndex = 0; late int _selectedIndex = 0;

View File

@ -18,7 +18,7 @@ import 'components/Images.dart';
// //
class CategoriesScreen extends StatefulWidget { class CategoriesScreen extends StatefulWidget {
const CategoriesScreen(); const CategoriesScreen({Key? key}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _CategoriesScreenState(); State<StatefulWidget> createState() => _CategoriesScreenState();
@ -41,7 +41,7 @@ class _CategoriesScreenState extends State<CategoriesScreen> {
}, },
buildDefaultAppBar: (BuildContext context) { buildDefaultAppBar: (BuildContext context) {
return AppBar( return AppBar(
title: new Text('分类'), title: Text('分类'),
actions: [ actions: [
shadowCategoriesActionButton(context), shadowCategoriesActionButton(context),
_searchBar.getSearchAction(context), _searchBar.getSearchAction(context),
@ -55,11 +55,11 @@ class _CategoriesScreenState extends State<CategoriesScreen> {
Future<List<Category>> _fetch() async { Future<List<Category>> _fetch() async {
List<Category> categories = await method.categories(); List<Category> categories = await method.categories();
storedCategories = []; storedCategories = [];
categories.forEach((element) { for (var element in categories) {
if (!element.isWeb) { if (!element.isWeb) {
storedCategories.add(element.title); storedCategories.add(element.title);
} }
}); }
return categories; return categories;
} }
@ -151,7 +151,7 @@ class _CategoriesScreenState extends State<CategoriesScreen> {
list.add( list.add(
GestureDetector( GestureDetector(
onTap: onTap, onTap: onTap,
child: Container( child: SizedBox(
width: blockSize, width: blockSize,
child: Column( child: Column(
children: [ children: [
@ -221,7 +221,7 @@ class _CategoriesScreenState extends State<CategoriesScreen> {
list.add( list.add(
GestureDetector( GestureDetector(
onTap: onTap, onTap: onTap,
child: Container( child: SizedBox(
width: blockSize, width: blockSize,
child: Column( child: Column(
children: [ children: [

View File

@ -8,6 +8,8 @@ import 'components/ContentLoading.dart';
// //
class CleanScreen extends StatefulWidget { class CleanScreen extends StatefulWidget {
const CleanScreen({Key? key}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _CleanScreenState(); State<StatefulWidget> createState() => _CleanScreenState();
} }
@ -44,15 +46,15 @@ class _CleanScreenState extends State<CleanScreen> {
} }
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text('清理'), title: const Text('清理'),
), ),
body: ListView( body: ListView(
children: [ children: [
Container( Container(
padding: EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: _cleanResult != "" ? Text(_cleanResult) : Container(), child: _cleanResult != "" ? Text(_cleanResult) : Container(),
), ),
Container( SizedBox(
height: 50, height: 50,
child: FitButton( child: FitButton(
text: '清理网络缓存', text: '清理网络缓存',
@ -61,7 +63,7 @@ class _CleanScreenState extends State<CleanScreen> {
}, },
), ),
), ),
Container( SizedBox(
height: 50, height: 50,
child: FitButton( child: FitButton(
text: '清理图片缓存', text: '清理图片缓存',
@ -70,7 +72,7 @@ class _CleanScreenState extends State<CleanScreen> {
}, },
), ),
), ),
Container( SizedBox(
height: 50, height: 50,
child: FitButton( child: FitButton(
text: '清理全部缓存', text: '清理全部缓存',

View File

@ -151,19 +151,19 @@ class _ComicInfoScreenState extends State<ComicInfoScreen> with RouteAware {
onLongPress: () { onLongPress: () {
confirmCopy( confirmCopy(
context, context,
"${_comicInfo.creator.name}", _comicInfo.creator.name,
); );
}, },
child: Text( child: Text(
"${_comicInfo.creator.name}", _comicInfo.creator.name,
style: TextStyle( style: const TextStyle(
fontSize: 14, fontSize: 14,
color: Colors.grey, color: Colors.grey,
), ),
), ),
), ),
), ),
TextSpan( const TextSpan(
text: " ", text: " ",
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
@ -195,8 +195,8 @@ class _ComicInfoScreenState extends State<ComicInfoScreen> with RouteAware {
confirmCopy(context, _comicInfo.chineseTeam); confirmCopy(context, _comicInfo.chineseTeam);
}, },
child: Text( child: Text(
"${_comicInfo.chineseTeam}", _comicInfo.chineseTeam,
style: TextStyle( style: const TextStyle(
fontSize: 13, fontSize: 13,
color: Colors.grey, color: Colors.grey,
), ),
@ -300,15 +300,13 @@ class _ComicInfoScreenState extends State<ComicInfoScreen> with RouteAware {
alignment: WrapAlignment.spaceAround, alignment: WrapAlignment.spaceAround,
children: [ children: [
..._epList.map((e) { ..._epList.map((e) {
return Container( return MaterialButton(
child: MaterialButton( onPressed: () {
onPressed: () { _push(_comicInfo, _epList, e.order, null);
_push(_comicInfo, _epList, e.order, null); },
}, color: Colors.white,
color: Colors.white, child:
child: Text(e.title, style: TextStyle(color: Colors.black)),
Text(e.title, style: TextStyle(color: Colors.black)),
),
); );
}), }),
], ],

View File

@ -3,7 +3,6 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:pikapika/basic/Common.dart';
import 'package:pikapika/basic/Entities.dart'; import 'package:pikapika/basic/Entities.dart';
import 'package:pikapika/basic/Method.dart'; import 'package:pikapika/basic/Method.dart';
import 'package:pikapika/basic/config/AutoFullScreen.dart'; import 'package:pikapika/basic/config/AutoFullScreen.dart';
@ -76,10 +75,10 @@ class _ComicReaderScreenState extends State<ComicReaderScreen> {
} }
FutureOr<dynamic> _onChangeEp(int epOrder) { FutureOr<dynamic> _onChangeEp(int epOrder) {
var orderMap = Map<int, Ep>(); var orderMap = <int, Ep>{};
widget.epList.forEach((element) { for (var element in widget.epList) {
orderMap[element.order] = element; orderMap[element.order] = element;
}); }
if (orderMap.containsKey(epOrder)) { if (orderMap.containsKey(epOrder)) {
_replacement = true; _replacement = true;
Navigator.of(context).pushReplacement( Navigator.of(context).pushReplacement(
@ -124,11 +123,11 @@ class _ComicReaderScreenState extends State<ComicReaderScreen> {
@override @override
void initState() { void initState() {
// EP // EP
widget.epList.forEach((element) { for (var element in widget.epList) {
if (element.order == widget.currentEpOrder) { if (element.order == widget.currentEpOrder) {
_ep = element; _ep = element;
} }
}); }
// INIT // INIT
_future = _load(); _future = _load();
super.initState(); super.initState();
@ -177,13 +176,13 @@ class _ComicReaderScreenState extends State<ComicReaderScreen> {
: AppBar( : AppBar(
title: Text("${_ep.title} - ${widget.comicInfo.title}"), title: Text("${_ep.title} - ${widget.comicInfo.title}"),
), ),
body: ContentLoading(label: '加载中'), body: const ContentLoading(label: '加载中'),
); );
} }
var epNameMap = Map<int, String>(); var epNameMap = <int, String>{};
widget.epList.forEach((element) { for (var element in widget.epList) {
epNameMap[element.order] = element.title; epNameMap[element.order] = element.title;
}); }
return Scaffold( return Scaffold(
body: ImageReader( body: ImageReader(
ImageReaderStruct( ImageReaderStruct(

View File

@ -32,7 +32,7 @@ class ComicsScreen extends StatefulWidget {
} }
class _ComicsScreenState extends State<ComicsScreen> { class _ComicsScreenState extends State<ComicsScreen> {
late SearchBar _categorySearchBar = SearchBar( late final SearchBar _categorySearchBar = SearchBar(
hintText: '搜索分类 - ${categoryTitle(widget.category)}', hintText: '搜索分类 - ${categoryTitle(widget.category)}',
inBar: false, inBar: false,
setState: setState, setState: setState,
@ -49,7 +49,7 @@ class _ComicsScreenState extends State<ComicsScreen> {
}, },
buildDefaultAppBar: (BuildContext context) { buildDefaultAppBar: (BuildContext context) {
return AppBar( return AppBar(
title: new Text(categoryTitle(widget.category)), title: Text(categoryTitle(widget.category)),
actions: [ actions: [
shadowCategoriesActionButton(context), shadowCategoriesActionButton(context),
chooseLayoutActionButton(context), chooseLayoutActionButton(context),

View File

@ -28,7 +28,8 @@ class CommentScreen extends StatefulWidget {
final String mainId; final String mainId;
final CommentBase comment; 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 @override
State<StatefulWidget> createState() => _CommentScreenState(); State<StatefulWidget> createState() => _CommentScreenState();

View File

@ -25,8 +25,8 @@ class DownloadConfirmScreen extends StatefulWidget {
class _DownloadConfirmScreenState extends State<DownloadConfirmScreen> { class _DownloadConfirmScreenState extends State<DownloadConfirmScreen> {
DownloadComic? _task; // DownloadComic? _task; //
List<int> _taskedEps = []; // EP final List<int> _taskedEps = []; // EP
List<int> _selectedEps = []; // EP final List<int> _selectedEps = []; // EP
late Future f = _load(); late Future f = _load();
Future<dynamic> _load() async { Future<dynamic> _load() async {
@ -41,11 +41,11 @@ class _DownloadConfirmScreenState extends State<DownloadConfirmScreen> {
void _selectAll() { void _selectAll() {
setState(() { setState(() {
_selectedEps.clear(); _selectedEps.clear();
widget.epList.forEach((element) { for (var element in widget.epList) {
if (!_taskedEps.contains(element.order)) { if (!_taskedEps.contains(element.order)) {
_selectedEps.add(element.order); _selectedEps.add(element.order);
} }
}); }
}); });
} }
@ -75,7 +75,7 @@ class _DownloadConfirmScreenState extends State<DownloadConfirmScreen> {
}; };
// EP列表 // EP列表
List<Map<String, dynamic>> list = []; List<Map<String, dynamic>> list = [];
widget.epList.forEach((element) { for (var element in widget.epList) {
if (_selectedEps.contains(element.order)) { if (_selectedEps.contains(element.order)) {
list.add({ list.add({
"comicId": widget.comicInfo.id, "comicId": widget.comicInfo.id,
@ -85,7 +85,7 @@ class _DownloadConfirmScreenState extends State<DownloadConfirmScreen> {
"title": element.title, "title": element.title,
}); });
} }
}); }
// EP加入下载 // EP加入下载
// //
if (_task != null) { if (_task != null) {

View File

@ -20,10 +20,11 @@ class DownloadExportToFileScreen extends StatefulWidget {
final String comicId; final String comicId;
final String comicTitle; final String comicTitle;
DownloadExportToFileScreen({ const DownloadExportToFileScreen({
required this.comicId, required this.comicId,
required this.comicTitle, required this.comicTitle,
}); Key? key,
}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _DownloadExportToFileScreenState(); State<StatefulWidget> createState() => _DownloadExportToFileScreenState();
@ -233,7 +234,7 @@ class _DownloadExportToFileScreenState
return; return;
} }
if (!(await Permission.storage.request()).isGranted) { if (!(await Permission.storage.request()).isGranted) {
return null; return;
} }
try { try {
setState(() { setState(() {

View File

@ -15,11 +15,12 @@ class DownloadExportToSocketScreen extends StatefulWidget {
final String comicId; final String comicId;
final String comicTitle; final String comicTitle;
DownloadExportToSocketScreen({ const DownloadExportToSocketScreen({
required this.task, required this.task,
required this.comicId, required this.comicId,
required this.comicTitle, required this.comicTitle,
}); Key? key,
}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _DownloadExportToSocketScreenState(); State<StatefulWidget> createState() => _DownloadExportToSocketScreenState();
@ -28,7 +29,7 @@ class DownloadExportToSocketScreen extends StatefulWidget {
class _DownloadExportToSocketScreenState class _DownloadExportToSocketScreenState
extends State<DownloadExportToSocketScreen> { extends State<DownloadExportToSocketScreen> {
late Future<int> _future = method.exportComicUsingSocket(widget.comicId); late Future<int> _future = method.exportComicUsingSocket(widget.comicId);
late Future<String> _ipFuture = method.clientIpSet(); late final Future<String> _ipFuture = method.clientIpSet();
late String exportMessage = ""; late String exportMessage = "";
@ -89,16 +90,16 @@ class _DownloadExportToSocketScreenState
builder: (BuildContext context, builder: (BuildContext context,
AsyncSnapshot<String> snapshot) { AsyncSnapshot<String> snapshot) {
if (snapshot.hasError) { if (snapshot.hasError) {
return Text('获取IP失败'); return const Text('获取IP失败');
} }
if (snapshot.connectionState != ConnectionState.done) { if (snapshot.connectionState != ConnectionState.done) {
return Text('正在获取IP'); return const Text('正在获取IP');
} }
return Text('${snapshot.data}'); return Text('${snapshot.data}');
}, },
), ),
Text('端口号:${snapshot.data}'), Text('端口号:${snapshot.data}'),
Text('$exportMessage'), Text(exportMessage),
], ],
), ),
), ),

View File

@ -1,9 +1,7 @@
import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:filesystem_picker/filesystem_picker.dart'; import 'package:filesystem_picker/filesystem_picker.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:pikapika/basic/Channels.dart'; import 'package:pikapika/basic/Channels.dart';
import 'package:pikapika/basic/Common.dart'; import 'package:pikapika/basic/Common.dart';
import 'package:pikapika/basic/Method.dart'; import 'package:pikapika/basic/Method.dart';
@ -13,6 +11,8 @@ import 'components/ContentLoading.dart';
// //
class DownloadImportScreen extends StatefulWidget { class DownloadImportScreen extends StatefulWidget {
const DownloadImportScreen({Key? key}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _DownloadImportScreenState(); State<StatefulWidget> createState() => _DownloadImportScreenState();
} }

View File

@ -19,10 +19,11 @@ class DownloadInfoScreen extends StatefulWidget {
final String comicId; final String comicId;
final String comicTitle; final String comicTitle;
DownloadInfoScreen({ const DownloadInfoScreen({
required this.comicId, required this.comicId,
required this.comicTitle, required this.comicTitle,
}); Key? key,
}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _DownloadInfoScreenState(); State<StatefulWidget> createState() => _DownloadInfoScreenState();
@ -143,15 +144,13 @@ class _DownloadInfoScreenState extends State<DownloadInfoScreen>
}, },
), ),
..._epList.map((e) { ..._epList.map((e) {
return Container( return MaterialButton(
child: MaterialButton( onPressed: () {
onPressed: () { _push(_task, _epList, e.epOrder, null);
_push(_task, _epList, e.epOrder, null); },
}, color: Colors.white,
color: Colors.white, child: Text(e.title,
child: Text(e.title, style: const TextStyle(color: Colors.black)),
style: TextStyle(color: Colors.black)),
),
); );
}), }),
], ],

View File

@ -13,6 +13,8 @@ import 'components/DownloadInfoCard.dart';
// //
class DownloadListScreen extends StatefulWidget { class DownloadListScreen extends StatefulWidget {
const DownloadListScreen({Key? key}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _DownloadListScreenState(); State<StatefulWidget> createState() => _DownloadListScreenState();
} }
@ -25,15 +27,13 @@ class _DownloadListScreenState extends State<DownloadListScreen> {
void _onMessageChange(String event) { void _onMessageChange(String event) {
print("EVENT"); print("EVENT");
print(event); print(event);
if (event is String) { try {
try { setState(() {
setState(() { _downloading = DownloadComic.fromJson(json.decode(event));
_downloading = DownloadComic.fromJson(json.decode(event)); });
}); } catch (e, s) {
} catch (e, s) { print(e);
print(e); print(s);
print(s);
}
} }
} }

View File

@ -76,10 +76,10 @@ class _DownloadReaderScreenState extends State<DownloadReaderScreen> {
} }
FutureOr<dynamic> _onChangeEp(int epOrder) { FutureOr<dynamic> _onChangeEp(int epOrder) {
var orderMap = Map<int, DownloadEp>(); var orderMap = <int, DownloadEp>{};
widget.epList.forEach((element) { for (var element in widget.epList) {
orderMap[element.epOrder] = element; orderMap[element.epOrder] = element;
}); }
if (orderMap.containsKey(epOrder)) { if (orderMap.containsKey(epOrder)) {
_replacement = true; _replacement = true;
Navigator.of(context).pushReplacement( Navigator.of(context).pushReplacement(
@ -114,11 +114,11 @@ class _DownloadReaderScreenState extends State<DownloadReaderScreen> {
@override @override
void initState() { void initState() {
// EP // EP
widget.epList.forEach((element) { for (var element in widget.epList) {
if (element.epOrder == widget.currentEpOrder) { if (element.epOrder == widget.currentEpOrder) {
_ep = element; _ep = element;
} }
}); }
// INIT // INIT
_future = _load(); _future = _load();
super.initState(); super.initState();
@ -169,10 +169,10 @@ class _DownloadReaderScreenState extends State<DownloadReaderScreen> {
body: ContentLoading(label: '加载中'), body: ContentLoading(label: '加载中'),
); );
} }
var epNameMap = Map<int, String>(); var epNameMap = <int, String>{};
widget.epList.forEach((element) { for (var element in widget.epList) {
epNameMap[element.epOrder] = element.title; epNameMap[element.epOrder] = element.title;
}); }
return Scaffold( return Scaffold(
body: ImageReader( body: ImageReader(
ImageReaderStruct( ImageReaderStruct(

View File

@ -5,6 +5,8 @@ import 'components/ComicPager.dart';
// //
class FavouritePaperScreen extends StatefulWidget { class FavouritePaperScreen extends StatefulWidget {
const FavouritePaperScreen({Key? key}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _FavouritePaperScreen(); State<StatefulWidget> createState() => _FavouritePaperScreen();
} }

View File

@ -8,7 +8,7 @@ import 'package:pikapika/screens/components/Images.dart';
class FilePhotoViewScreen extends StatelessWidget { class FilePhotoViewScreen extends StatelessWidget {
final String filePath; final String filePath;
FilePhotoViewScreen(this.filePath); const FilePhotoViewScreen(this.filePath, {Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) => Scaffold( Widget build(BuildContext context) => Scaffold(

View File

@ -18,7 +18,7 @@ class GameDownloadScreen extends StatefulWidget {
class _GameDownloadScreenState extends State<GameDownloadScreen> { class _GameDownloadScreenState extends State<GameDownloadScreen> {
late Future<List<String>> _future = late Future<List<String>> _future =
method.downloadGame("${widget.info.androidLinks[0]}"); method.downloadGame(widget.info.androidLinks[0]);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -34,21 +34,19 @@ class _GameDownloadScreenState extends State<GameDownloadScreen> {
onRefresh: () async { onRefresh: () async {
setState(() { setState(() {
_future = _future =
method.downloadGame("${widget.info.androidLinks[0]}"); method.downloadGame(widget.info.androidLinks[0]);
}); });
}, },
successBuilder: successBuilder:
(BuildContext context, AsyncSnapshot<List<String>> snapshot) { (BuildContext context, AsyncSnapshot<List<String>> snapshot) {
return Container( return Column(
child: Column( children: [
children: [ Container(
Container( padding: const EdgeInsets.all(30),
padding: EdgeInsets.all(30), child: const Text('获取到下载链接, 您只需要选择其中一个'),
child: Text('获取到下载链接, 您只需要选择其中一个'), ),
), ...snapshot.data!.map((e) => _copyCard(e)),
...snapshot.data!.map((e) => _copyCard(e)), ],
],
),
); );
}, },
), ),

View File

@ -14,7 +14,7 @@ import 'components/GameTitleCard.dart';
class GameInfoScreen extends StatefulWidget { class GameInfoScreen extends StatefulWidget {
final String gameId; final String gameId;
const GameInfoScreen(this.gameId); const GameInfoScreen(this.gameId,{Key? key}):super(key: key);
@override @override
State<StatefulWidget> createState() => _GameInfoScreenState(); State<StatefulWidget> createState() => _GameInfoScreenState();
@ -127,33 +127,31 @@ class _GameInfoScreenState extends State<GameInfoScreen> {
), ),
), ),
Container(height: 20), Container(height: 20),
Container( Column(
child: Column( children: [
children: [ Container(
Container( height: 40,
height: 40, color: Theme.of(context)
color: Theme.of(context) .colorScheme
.colorScheme .secondary
.secondary .withOpacity(.025),
.withOpacity(.025), child: TabBar(
child: TabBar( tabs: <Widget>[
tabs: <Widget>[ Tab(text: '详情 '),
Tab(text: '详情 '), Tab(text: '评论 (${info.commentsCount})'),
Tab(text: '评论 (${info.commentsCount})'), ],
], indicatorColor:
indicatorColor: Theme.of(context).colorScheme.secondary,
Theme.of(context).colorScheme.secondary, labelColor:
labelColor: Theme.of(context).colorScheme.secondary,
Theme.of(context).colorScheme.secondary, onTap: (val) async {
onTap: (val) async { setState(() {
setState(() { _tabIndex = val;
_tabIndex = val; });
}); },
},
),
), ),
], ),
), ],
), ),
_tabIndex == 0 _tabIndex == 0
? Container( ? Container(

View File

@ -9,6 +9,8 @@ import 'components/Images.dart';
// //
class GamesScreen extends StatefulWidget { class GamesScreen extends StatefulWidget {
const GamesScreen({Key? key}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _GamesScreenState(); State<StatefulWidget> createState() => _GamesScreenState();
} }
@ -43,7 +45,7 @@ class _GamesScreenState extends State<GamesScreen> {
List<Wrap> wraps = []; List<Wrap> wraps = [];
GameCard? gameCard; GameCard? gameCard;
page.docs.forEach((element) { for (var element in page.docs) {
if (gameCard == null) { if (gameCard == null) {
gameCard = GameCard(element); gameCard = GameCard(element);
} else { } else {
@ -53,7 +55,7 @@ class _GamesScreenState extends State<GamesScreen> {
)); ));
gameCard = null; gameCard = null;
} }
}); }
if (gameCard != null) { if (gameCard != null) {
wraps.add(Wrap( wraps.add(Wrap(
children: [gameCard!], children: [gameCard!],
@ -85,18 +87,16 @@ class _GamesScreenState extends State<GamesScreen> {
builder: (context) { builder: (context) {
return AlertDialog( return AlertDialog(
content: Card( content: Card(
child: Container( child: TextField(
child: TextField( controller: _textEditController,
controller: _textEditController, decoration: const InputDecoration(
decoration: new InputDecoration( labelText: "请输入页数:",
labelText: "请输入页数:",
),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.allow(
RegExp(r'\d+')),
],
), ),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.allow(
RegExp(r'\d+')),
],
), ),
), ),
actions: <Widget>[ actions: <Widget>[
@ -104,13 +104,13 @@ class _GamesScreenState extends State<GamesScreen> {
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
}, },
child: Text('取消'), child: const Text('取消'),
), ),
MaterialButton( MaterialButton(
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
var text = _textEditController.text; var text = _textEditController.text;
if (text.length == 0 || text.length > 5) { if (text.isEmpty || text.length > 5) {
return; return;
} }
var num = int.parse(text); var num = int.parse(text);
@ -119,7 +119,7 @@ class _GamesScreenState extends State<GamesScreen> {
} }
_onPageChange(num); _onPageChange(num);
}, },
child: Text('确定'), child: const Text('确定'),
), ),
], ],
); );
@ -186,7 +186,7 @@ class _GamesScreenState extends State<GamesScreen> {
class GameCard extends StatelessWidget { class GameCard extends StatelessWidget {
final GameSimple info; final GameSimple info;
GameCard(this.info); const GameCard(this.info, {Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -215,8 +215,8 @@ class GameCard extends StatelessWidget {
); );
}, },
child: Container( child: Container(
padding: EdgeInsets.all(10), padding: const EdgeInsets.all(10),
child: Container( child: SizedBox(
width: imageWidth, width: imageWidth,
child: Column( child: Column(
children: [ children: [

View File

@ -36,6 +36,8 @@ import 'AppScreen.dart';
// //
class InitScreen extends StatefulWidget { class InitScreen extends StatefulWidget {
const InitScreen({Key? key}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _InitScreenState(); State<StatefulWidget> createState() => _InitScreenState();
} }
@ -104,7 +106,7 @@ class _InitScreenState extends State<InitScreen> {
backgroundColor: Color(0xfffffced), backgroundColor: Color(0xfffffced),
body: ConstrainedBox( body: ConstrainedBox(
constraints: BoxConstraints.expand(), constraints: BoxConstraints.expand(),
child: new Image.asset( child: Image.asset(
"lib/assets/init.jpg", "lib/assets/init.jpg",
fit: BoxFit.contain, fit: BoxFit.contain,
), ),

View File

@ -8,12 +8,14 @@ import 'package:pikapika/screens/components/ContentLoading.dart';
// //
class MigrateScreen extends StatefulWidget { class MigrateScreen extends StatefulWidget {
const MigrateScreen({Key? key}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _MigrateScreenState(); State<StatefulWidget> createState() => _MigrateScreenState();
} }
class _MigrateScreenState extends State<MigrateScreen> { class _MigrateScreenState extends State<MigrateScreen> {
late Future _future = _load(); late final Future _future = _load();
late String _current; late String _current;
late List<String> paths; late List<String> paths;
String _message = ""; String _message = "";

View File

@ -89,14 +89,14 @@ class _RegisterScreenState extends State<RegisterScreen> {
if (_registerOver) { if (_registerOver) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text('注册成功'), title: const Text('注册成功'),
), ),
body: Center( body: Center(
child: Container( child: Container(
child: Column( child: Column(
children: [ children: [
Expanded(child: Container()), Expanded(child: Container()),
Text('您已经注册成功, 请返回登录'), const Text('您已经注册成功, 请返回登录'),
Text('账号 : $_email'), Text('账号 : $_email'),
Text('昵称 : $_name'), Text('昵称 : $_name'),
Expanded(child: Container()), Expanded(child: Container()),

View File

@ -24,9 +24,9 @@ class SearchScreen extends StatefulWidget {
} }
class _SearchScreenState extends State<SearchScreen> { class _SearchScreenState extends State<SearchScreen> {
late TextEditingController _textEditController = late final TextEditingController _textEditController =
TextEditingController(text: widget.keyword); TextEditingController(text: widget.keyword);
late SearchBar _searchBar = SearchBar( late final SearchBar _searchBar = SearchBar(
hintText: '搜索 ${categoryTitle(widget.category)}', hintText: '搜索 ${categoryTitle(widget.category)}',
controller: _textEditController, controller: _textEditController,
inBar: false, inBar: false,

View File

@ -34,12 +34,14 @@ import 'MigrateScreen.dart';
import 'ModifyPasswordScreen.dart'; import 'ModifyPasswordScreen.dart';
class SettingsScreen extends StatelessWidget { class SettingsScreen extends StatelessWidget {
const SettingsScreen({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) => Scaffold( Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: Text('设置')), appBar: AppBar(title: const Text('设置')),
body: ListView( body: ListView(
children: [ children: [
Divider(), const Divider(),
ListTile( ListTile(
onTap: () async { onTap: () async {
Navigator.push( Navigator.push(
@ -48,11 +50,11 @@ class SettingsScreen extends StatelessWidget {
builder: (context) => ModifyPasswordScreen()), builder: (context) => ModifyPasswordScreen()),
); );
}, },
title: Text('修改密码'), title: const Text('修改密码'),
), ),
Divider(), const Divider(),
NetworkSetting(), const NetworkSetting(),
Divider(), const Divider(),
qualitySetting(), qualitySetting(),
convertToPNGSetting(), convertToPNGSetting(),
readerTypeSetting(), readerTypeSetting(),
@ -63,7 +65,7 @@ class SettingsScreen extends StatelessWidget {
volumeControllerSetting(), volumeControllerSetting(),
keyboardControllerSetting(), keyboardControllerSetting(),
noAnimationSetting(), noAnimationSetting(),
Divider(), const Divider(),
shadowCategoriesModeSetting(), shadowCategoriesModeSetting(),
shadowCategoriesSetting(), shadowCategoriesSetting(),
pagerActionSetting(), pagerActionSetting(),

View File

@ -15,7 +15,8 @@ import 'components/UserProfileCard.dart';
// //
class SpaceScreen extends StatefulWidget { class SpaceScreen extends StatefulWidget {
const SpaceScreen(); const SpaceScreen({Key? key}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _SpaceScreenState(); State<StatefulWidget> createState() => _SpaceScreenState();
@ -58,17 +59,17 @@ class _SpaceScreenState extends State<SpaceScreen> {
); );
} }
}, },
icon: Icon(Icons.exit_to_app), icon: const Icon(Icons.exit_to_app),
), ),
IconButton( IconButton(
onPressed: () { onPressed: () {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) => AboutScreen()), MaterialPageRoute(builder: (context) => const AboutScreen()),
); );
}, },
icon: Badged( icon: Badged(
child: Icon(Icons.info_outline), child: const Icon(Icons.info_outline),
badge: latestVersion() == null ? null : "1", badge: latestVersion() == null ? null : "1",
), ),
), ),
@ -76,18 +77,18 @@ class _SpaceScreenState extends State<SpaceScreen> {
onPressed: () { onPressed: () {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) => SettingsScreen()), MaterialPageRoute(builder: (context) => const SettingsScreen()),
); );
}, },
icon: Icon(Icons.settings), icon: const Icon(Icons.settings),
), ),
], ],
), ),
body: ListView( body: ListView(
children: [ children: [
Divider(), const Divider(),
UserProfileCard(), const UserProfileCard(),
Divider(), const Divider(),
ListTile( ListTile(
onTap: () async { onTap: () async {
await chooseTheme(context); await chooseTheme(context);
@ -96,7 +97,7 @@ class _SpaceScreenState extends State<SpaceScreen> {
title: Text('主题'), title: Text('主题'),
subtitle: Text(currentThemeName()), subtitle: Text(currentThemeName()),
), ),
Divider(), const Divider(),
ListTile( ListTile(
onTap: () { onTap: () {
Navigator.push( Navigator.push(
@ -106,7 +107,7 @@ class _SpaceScreenState extends State<SpaceScreen> {
}, },
title: Text('我的收藏'), title: Text('我的收藏'),
), ),
Divider(), const Divider(),
ListTile( ListTile(
onTap: () { onTap: () {
Navigator.push( Navigator.push(
@ -116,17 +117,17 @@ class _SpaceScreenState extends State<SpaceScreen> {
}, },
title: Text('浏览记录'), title: Text('浏览记录'),
), ),
Divider(), const Divider(),
ListTile( ListTile(
onTap: () { onTap: () {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute(builder: (context) => DownloadListScreen()), MaterialPageRoute(builder: (context) => const DownloadListScreen()),
); );
}, },
title: Text('我的下载'), title: const Text('我的下载'),
), ),
Divider(), const Divider(),
], ],
), ),
); );

View File

@ -7,7 +7,7 @@ import 'components/Images.dart';
// //
class ViewLogsScreen extends StatefulWidget { class ViewLogsScreen extends StatefulWidget {
const ViewLogsScreen(); const ViewLogsScreen({Key? key}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _ViewLogsScreenState(); State<StatefulWidget> createState() => _ViewLogsScreenState();
@ -175,7 +175,7 @@ class ViewLogWrap extends StatelessWidget {
onDelete(e.id); onDelete(e.id);
}, },
child: Card( child: Card(
child: Container( child: SizedBox(
width: width, width: width,
child: Column( child: Column(
children: [ children: [
@ -200,7 +200,7 @@ class ViewLogWrap extends StatelessWidget {
); );
}); });
Map<int, List<Widget>> map = Map(); Map<int, List<Widget>> map = {};
for (var i = 0; i < entries.length; i++) { for (var i = 0; i < entries.length; i++) {
late List<Widget> list; late List<Widget> list;
if (i % 4 == 0) { if (i % 4 == 0) {

View File

@ -10,7 +10,7 @@ class Avatar extends StatelessWidget {
final RemoteImageInfo avatarImage; final RemoteImageInfo avatarImage;
final double size; final double size;
const Avatar(this.avatarImage, {this.size = 50}); const Avatar(this.avatarImage, {this.size = 50, Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -15,21 +15,21 @@ class Badged extends StatelessWidget {
return Stack( return Stack(
children: [ children: [
child, child,
new Positioned( Positioned(
right: 0, right: 0,
child: new Container( child: Container(
padding: EdgeInsets.all(1), padding: const EdgeInsets.all(1),
decoration: new BoxDecoration( decoration: BoxDecoration(
color: Colors.red, color: Colors.red,
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(6),
), ),
constraints: BoxConstraints( constraints: const BoxConstraints(
minWidth: 12, minWidth: 12,
minHeight: 12, minHeight: 12,
), ),
child: new Text( child: Text(
badge!, badge!,
style: new TextStyle( style: const TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 8, fontSize: 8,
), ),

View File

@ -4,13 +4,14 @@ import 'package:flutter/material.dart';
class ComicDescriptionCard extends StatelessWidget { class ComicDescriptionCard extends StatelessWidget {
final String description; final String description;
ComicDescriptionCard({Key? key, required this.description}) : super(key: key); const ComicDescriptionCard({Key? key, required this.description})
: super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var theme = Theme.of(context); var theme = Theme.of(context);
return Container( return Container(
padding: EdgeInsets.only( padding: const EdgeInsets.only(
top: 5, top: 5,
bottom: 5, bottom: 5,
left: 10, left: 10,

View File

@ -168,7 +168,7 @@ class _ComicInfoCard extends State<ComicInfoCard> {
], ],
), ),
), ),
Container( SizedBox(
height: imageHeight, height: imageHeight,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
@ -180,7 +180,7 @@ class _ComicInfoCard extends State<ComicInfoCard> {
? [] ? []
: [ : [
Container(height: 10), Container(height: 10),
Container( SizedBox(
height: 26, height: 26,
child: _likeLoading child: _likeLoading
? IconButton( ? IconButton(
@ -205,7 +205,7 @@ class _ComicInfoCard extends State<ComicInfoCard> {
? [] ? []
: [ : [
Container(height: 10), Container(height: 10),
Container( SizedBox(
height: 26, height: 26,
child: _favouriteLoading child: _favouriteLoading
? IconButton( ? IconButton(

View File

@ -18,7 +18,9 @@ class ComicList extends StatefulWidget {
final List<ComicSimple> comicList; final List<ComicSimple> comicList;
final ScrollController? controller; 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 @override
State<StatefulWidget> createState() => _ComicListState(); State<StatefulWidget> createState() => _ComicListState();
@ -112,7 +114,7 @@ class _ComicListState extends State<ComicList> {
}).toList(), }).toList(),
...widget.appendWidget != null ...widget.appendWidget != null
? [ ? [
Container( SizedBox(
height: 80, height: 80,
child: widget.appendWidget, child: widget.appendWidget,
), ),
@ -132,7 +134,7 @@ class _ComicListState extends State<ComicList> {
var height = width * coverHeight / coverWidth; var height = width * coverHeight / coverWidth;
List<Widget> wraps = []; List<Widget> wraps = [];
List<Widget> tmp = []; List<Widget> tmp = [];
widget.comicList.forEach((e) { for (var e in widget.comicList) {
var shadow = e.categories.map( var shadow = e.categories.map(
(c) { (c) {
switch (currentShadowCategoriesMode()) { switch (currentShadowCategoriesMode()) {
@ -193,12 +195,13 @@ class _ComicListState extends State<ComicList> {
)); ));
tmp = []; tmp = [];
} }
}); }
// //
if (widget.appendWidget != null) { if (widget.appendWidget != null) {
tmp.add(Container( tmp.add(Container(
color: (Theme.of(context).textTheme.bodyText1?.color ?? Color(0)) color:
.withOpacity(.1), (Theme.of(context).textTheme.bodyText1?.color ?? Colors.transparent)
.withOpacity(.1),
margin: EdgeInsets.only( margin: EdgeInsets.only(
left: (rowCap - tmp.length) * gap, left: (rowCap - tmp.length) * gap,
right: (rowCap - tmp.length) * gap, right: (rowCap - tmp.length) * gap,
@ -211,7 +214,7 @@ class _ComicListState extends State<ComicList> {
)); ));
} }
// //
if (tmp.length > 0) { if (tmp.isNotEmpty) {
wraps.add(Row( wraps.add(Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
@ -240,7 +243,7 @@ class _ComicListState extends State<ComicList> {
double shadowFontSize = max(width / 9, 12); double shadowFontSize = max(width / 9, 12);
List<Widget> wraps = []; List<Widget> wraps = [];
List<Widget> tmp = []; List<Widget> tmp = [];
widget.comicList.forEach((e) { for (var e in widget.comicList) {
var shadow = e.categories.map( var shadow = e.categories.map(
(c) { (c) {
switch (currentShadowCategoriesMode()) { switch (currentShadowCategoriesMode()) {
@ -330,12 +333,13 @@ class _ComicListState extends State<ComicList> {
)); ));
tmp = []; tmp = [];
} }
}); }
// //
if (widget.appendWidget != null) { if (widget.appendWidget != null) {
tmp.add(Container( tmp.add(Container(
color: (Theme.of(context).textTheme.bodyText1?.color ?? Color(0)) color:
.withOpacity(.1), (Theme.of(context).textTheme.bodyText1?.color ?? Colors.transparent)
.withOpacity(.1),
margin: EdgeInsets.only( margin: EdgeInsets.only(
left: (rowCap - tmp.length) * gap, left: (rowCap - tmp.length) * gap,
right: (rowCap - tmp.length) * gap, right: (rowCap - tmp.length) * gap,
@ -348,7 +352,7 @@ class _ComicListState extends State<ComicList> {
)); ));
} }
// //
if (tmp.length > 0) { if (tmp.isNotEmpty) {
wraps.add(Row( wraps.add(Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,

View File

@ -10,7 +10,8 @@ class ComicListBuilder extends StatefulWidget {
final Future<List<ComicSimple>> future; final Future<List<ComicSimple>> future;
final Future Function() reload; final Future Function() reload;
ComicListBuilder(this.future, this.reload); const ComicListBuilder(this.future, this.reload, {Key? key})
: super(key: key);
@override @override
State<StatefulWidget> createState() => _ComicListBuilderState(); State<StatefulWidget> createState() => _ComicListBuilderState();

View File

@ -153,17 +153,15 @@ class _ControllerComicPagerState extends State<ControllerComicPager> {
builder: (context) { builder: (context) {
return AlertDialog( return AlertDialog(
content: Card( content: Card(
child: Container( child: TextField(
child: TextField( controller: _textEditController,
controller: _textEditController, decoration: const InputDecoration(
decoration: new InputDecoration( labelText: "请输入页数:",
labelText: "请输入页数:",
),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.allow(RegExp(r'\d+')),
],
), ),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.allow(RegExp(r'\d+')),
],
), ),
), ),
actions: <Widget>[ actions: <Widget>[
@ -177,7 +175,7 @@ class _ControllerComicPagerState extends State<ControllerComicPager> {
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
var text = _textEditController.text; var text = _textEditController.text;
if (text.length == 0 || text.length > 5) { if (text.isEmpty || text.length > 5) {
return; return;
} }
var num = int.parse(text); var num = int.parse(text);
@ -240,6 +238,7 @@ class _ControllerComicPagerState extends State<ControllerComicPager> {
text: '下一页', text: '下一页',
); );
} }
return null;
} }
} }
@ -391,5 +390,6 @@ class _StreamComicPagerState extends State<StreamComicPager> {
if (_loading) { if (_loading) {
return FitButton(onPressed: () {}, text: '加载中'); return FitButton(onPressed: () {}, text: '加载中');
} }
return null;
} }
} }

View File

@ -11,7 +11,8 @@ class ComicCommentItem extends StatefulWidget {
final String mainId; final String mainId;
final CommentBase comment; 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 @override
State<StatefulWidget> createState() => _ComicCommentItemState(); State<StatefulWidget> createState() => _ComicCommentItemState();
@ -24,7 +25,7 @@ class _ComicCommentItemState extends State<ComicCommentItem> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
var comment = widget.comment; var comment = widget.comment;
var theme = Theme.of(context); var theme = Theme.of(context);
var nameStyle = TextStyle(fontWeight: FontWeight.bold); var nameStyle = const TextStyle(fontWeight: FontWeight.bold);
var levelStyle = TextStyle( var levelStyle = TextStyle(
fontSize: 12, color: theme.colorScheme.secondary.withOpacity(.8)); fontSize: 12, color: theme.colorScheme.secondary.withOpacity(.8));
var connectStyle = var connectStyle =
@ -32,7 +33,7 @@ class _ComicCommentItemState extends State<ComicCommentItem> {
var datetimeStyle = TextStyle( var datetimeStyle = TextStyle(
color: theme.textTheme.bodyText1?.color?.withOpacity(.6), fontSize: 12); color: theme.textTheme.bodyText1?.color?.withOpacity(.6), fontSize: 12);
return Container( return Container(
padding: EdgeInsets.all(5), padding: const EdgeInsets.all(5),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border( border: Border(
top: BorderSide( top: BorderSide(
@ -58,7 +59,7 @@ class _ComicCommentItemState extends State<ComicCommentItem> {
children: [ children: [
LayoutBuilder( LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) { builder: (BuildContext context, BoxConstraints constraints) {
return Container( return SizedBox(
width: constraints.maxWidth, width: constraints.maxWidth,
child: Wrap( child: Wrap(
crossAxisAlignment: WrapCrossAlignment.center, crossAxisAlignment: WrapCrossAlignment.center,
@ -77,7 +78,7 @@ class _ComicCommentItemState extends State<ComicCommentItem> {
Container(height: 3), Container(height: 3),
LayoutBuilder( LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) { builder: (BuildContext context, BoxConstraints constraints) {
return Container( return SizedBox(
width: constraints.maxWidth, width: constraints.maxWidth,
child: Wrap( child: Wrap(
crossAxisAlignment: WrapCrossAlignment.center, crossAxisAlignment: WrapCrossAlignment.center,
@ -103,7 +104,7 @@ class _ComicCommentItemState extends State<ComicCommentItem> {
text: '${comment.commentsCount}', text: '${comment.commentsCount}',
), ),
]) ])
: TextSpan(), : const TextSpan(),
WidgetSpan(child: Container(width: 12)), WidgetSpan(child: Container(width: 12)),
WidgetSpan( WidgetSpan(
child: GestureDetector( child: GestureDetector(
@ -136,6 +137,7 @@ class _ComicCommentItemState extends State<ComicCommentItem> {
} }
}); });
} catch (e, s) { } catch (e, s) {
print("$e\n$s");
defaultToast(context, "点赞失败"); defaultToast(context, "点赞失败");
} finally { } finally {
setState(() { setState(() {

View File

@ -1,6 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:pikapika/basic/config/ContentFailedReloadAction.dart'; import 'package:pikapika/basic/config/ContentFailedReloadAction.dart';
import 'dart:ui';
import 'package:pikapika/basic/enum/ErrorTypes.dart'; import 'package:pikapika/basic/enum/ErrorTypes.dart';
@ -60,21 +59,19 @@ class ContentError extends StatelessWidget {
onTap: onRefresh, onTap: onRefresh,
child: ListView( child: ListView(
children: [ children: [
Container( SizedBox(
height: height, height: height,
child: Column( child: Column(
children: [ children: [
Expanded(child: Container()), Expanded(child: Container()),
Container( Icon(
child: Icon( iconData,
iconData, size: iconSize,
size: iconSize, color: Colors.grey.shade600,
color: Colors.grey.shade600,
),
), ),
Container(height: min / 10), Container(height: min / 10),
Container( Container(
padding: EdgeInsets.only( padding: const EdgeInsets.only(
left: 30, left: 30,
right: 30, right: 30,
), ),
@ -99,21 +96,19 @@ class ContentError extends StatelessWidget {
onRefresh: onRefresh, onRefresh: onRefresh,
child: ListView( child: ListView(
children: [ children: [
Container( SizedBox(
height: height, height: height,
child: Column( child: Column(
children: [ children: [
Expanded(child: Container()), Expanded(child: Container()),
Container( Icon(
child: Icon( iconData,
iconData, size: iconSize,
size: iconSize, color: Colors.grey.shade600,
color: Colors.grey.shade600,
),
), ),
Container(height: min / 10), Container(height: min / 10),
Container( Container(
padding: EdgeInsets.only( padding: const EdgeInsets.only(
left: 30, left: 30,
right: 30, right: 30,
), ),

View File

@ -115,53 +115,43 @@ class DownloadInfoCard extends StatelessWidget {
), ),
Container(width: 20), Container(width: 20),
task.deleting task.deleting
? Container( ? Text('删除中',
child: Text('删除中', style: TextStyle(
color: Color.alphaBlend(
textColor.withAlpha(0x33),
Colors.red.shade500)))
: task.downloadFailed
? Text('下载失败',
style: TextStyle( style: TextStyle(
color: Color.alphaBlend( color: Color.alphaBlend(
textColor.withAlpha(0x33), textColor.withAlpha(0x33),
Colors.red.shade500))), Colors.red.shade500)))
) : task.downloadFinished
: task.downloadFailed ? Text('下载完成',
? Container(
child: Text('下载失败',
style: TextStyle( style: TextStyle(
color: Color.alphaBlend( color: Color.alphaBlend(
textColor.withAlpha(0x33), textColorAlpha,
Colors.red.shade500))), Colors.green.shade500)))
) : downloading // downloader.downloadingTask() == task.id
: task.downloadFinished ? Text('下载中',
? Container(
child: Text('下载完成',
style: TextStyle( style: TextStyle(
color: Color.alphaBlend( color: Color.alphaBlend(
textColorAlpha, textColorAlpha,
Colors.green.shade500))), Colors
) .blue.shade500)))
: downloading // downloader.downloadingTask() == task.id : Text('队列中',
? Container( style: TextStyle(
child: Text('下载中', color: Color.alphaBlend(
style: TextStyle( textColorAlpha,
color: Color.alphaBlend( Colors.lightBlue
textColorAlpha, .shade500))),
Colors
.blue.shade500))),
)
: Container(
child: Text('队列中',
style: TextStyle(
color: Color.alphaBlend(
textColorAlpha,
Colors.lightBlue
.shade500))),
),
], ],
), ),
], ],
), ),
), ),
Container( Container(
padding: EdgeInsets.only(left: 8), padding: const EdgeInsets.only(left: 8),
height: imageHeight, height: imageHeight,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,

View File

@ -15,13 +15,11 @@ class FitButton extends StatelessWidget {
width: constraints.maxWidth, width: constraints.maxWidth,
height: constraints.maxHeight, height: constraints.maxHeight,
child: Container( child: Container(
padding: EdgeInsets.all(10), padding: const EdgeInsets.all(10),
child: MaterialButton( child: MaterialButton(
onPressed: onPressed, onPressed: onPressed,
child: Container( child: Center(
child: Center( child: Text(text),
child: Text(text),
),
), ),
), ),
), ),

View File

@ -9,21 +9,20 @@ import 'Images.dart';
class GameTitleCard extends StatelessWidget { class GameTitleCard extends StatelessWidget {
final GameInfo info; final GameInfo info;
const GameTitleCard(this.info); const GameTitleCard(this.info, {Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
double iconMargin = 20; double iconMargin = 20;
double iconSize = 60; double iconSize = 60;
BorderRadius iconRadius = BorderRadius.all(Radius.circular(6)); BorderRadius iconRadius = const BorderRadius.all(Radius.circular(6));
TextStyle titleStyle = TextStyle(fontSize: 16, fontWeight: FontWeight.bold); TextStyle titleStyle =
const TextStyle(fontSize: 16, fontWeight: FontWeight.bold);
TextStyle publisherStyle = TextStyle( TextStyle publisherStyle = TextStyle(
color: Theme.of(context).colorScheme.secondary, color: Theme.of(context).colorScheme.secondary,
fontSize: 12.5, fontSize: 12.5,
); );
TextStyle versionStyle = TextStyle( TextStyle versionStyle = const TextStyle(fontSize: 12.5);
fontSize: 12.5,
);
double platformMargin = 10; double platformMargin = 10;
double platformSize = 25; double platformSize = 25;
return Row( return Row(

View File

@ -139,7 +139,7 @@ class ImageReaderStruct {
class ImageReader extends StatefulWidget { class ImageReader extends StatefulWidget {
final ImageReaderStruct struct; final ImageReaderStruct struct;
const ImageReader(this.struct); const ImageReader(this.struct, {Key? key}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _ImageReaderState(); State<StatefulWidget> createState() => _ImageReaderState();
@ -153,9 +153,9 @@ class _ImageReaderState extends State<ImageReader> {
final ReaderType _pagerType = currentReaderType(); final ReaderType _pagerType = currentReaderType();
// //
late FullScreenAction _fullScreenAction = currentFullScreenAction(); late final FullScreenAction _fullScreenAction = currentFullScreenAction();
late ReaderSliderPosition _readerSliderPosition = late final ReaderSliderPosition _readerSliderPosition =
currentReaderSliderPosition(); currentReaderSliderPosition();
@override @override
@ -245,7 +245,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
void _onPageControl(_ReaderControllerEventArgs? args) { void _onPageControl(_ReaderControllerEventArgs? args) {
if (args != null) { if (args != null) {
var event = args.key; var event = args.key;
switch ("$event") { switch (event) {
case "UP": case "UP":
if (_current > 0) { if (_current > 0) {
_needJumpTo(_current - 1, true); _needJumpTo(_current - 1, true);
@ -369,7 +369,6 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
], ],
); );
} }
return Container();
} }
Widget _buildAppBar() => widget.struct.fullScreen Widget _buildAppBar() => widget.struct.fullScreen
@ -393,7 +392,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
return Column( return Column(
children: [ children: [
Expanded(child: Container()), Expanded(child: Container()),
Container( SizedBox(
height: 25, height: 25,
child: _buildSliderWidget(Axis.horizontal), child: _buildSliderWidget(Axis.horizontal),
), ),
@ -407,7 +406,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
: Align( : Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Material( child: Material(
color: Color(0x0), color: Colors.transparent,
child: Container( child: Container(
width: 35, width: 35,
height: 300, height: 300,
@ -431,7 +430,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
: Align( : Align(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Material( child: Material(
color: Color(0x0), color: Colors.transparent,
child: Container( child: Container(
width: 35, width: 35,
height: 300, height: 300,
@ -525,7 +524,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
return Align( return Align(
alignment: Alignment.bottomLeft, alignment: Alignment.bottomLeft,
child: Material( child: Material(
color: Color(0x0), color: Colors.transparent,
child: Container( child: Container(
padding: EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4), padding: EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4),
margin: EdgeInsets.only(bottom: 10), margin: EdgeInsets.only(bottom: 10),
@ -577,8 +576,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
return GestureDetector( return GestureDetector(
behavior: HitTestBehavior.translucent, behavior: HitTestBehavior.translucent,
onTap: () { onTap: () {
_readerControllerEvent _readerControllerEvent.broadcast(_ReaderControllerEventArgs("DOWN"));
.broadcast(_ReaderControllerEventArgs("DOWN"));
}, },
onDoubleTap: () { onDoubleTap: () {
widget.struct.onFullScreenChange(!widget.struct.fullScreen); widget.struct.onFullScreenChange(!widget.struct.fullScreen);
@ -656,7 +654,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
context: context, context: context,
backgroundColor: Color(0xAA000000), backgroundColor: Color(0xAA000000),
builder: (context) { builder: (context) {
return Container( return SizedBox(
height: MediaQuery.of(context).size.height * (.45), height: MediaQuery.of(context).size.height * (.45),
child: _EpChooser( child: _EpChooser(
widget.struct.epNameMap, widget.struct.epNameMap,
@ -677,7 +675,7 @@ abstract class _ImageReaderContentState extends State<_ImageReaderContent> {
context: context, context: context,
backgroundColor: Color(0xAA000000), backgroundColor: Color(0xAA000000),
builder: (context) { builder: (context) {
return Container( return SizedBox(
height: MediaQuery.of(context).size.height * (.45), height: MediaQuery.of(context).size.height * (.45),
child: _SettingPanel( child: _SettingPanel(
widget.struct.onReloadEp, widget.struct.onReloadEp,
@ -749,11 +747,11 @@ class _EpChooserState extends State<_EpChooser> {
Container(height: 20), Container(height: 20),
...entries.map((e) { ...entries.map((e) {
return Container( 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( decoration: BoxDecoration(
color: widget.epOrder == e.key ? Colors.grey.withAlpha(100) : null, color: widget.epOrder == e.key ? Colors.grey.withAlpha(100) : null,
border: Border.all( border: Border.all(
color: Color(0xff484c60), color: const Color(0xff484c60),
style: BorderStyle.solid, style: BorderStyle.solid,
width: .5, width: .5,
), ),
@ -764,7 +762,7 @@ class _EpChooserState extends State<_EpChooser> {
widget.onChangeEp(e.key); widget.onChangeEp(e.key);
}, },
textColor: Colors.white, textColor: Colors.white,
child: Text('${e.value}'), child: Text(e.value),
), ),
); );
}) })
@ -792,78 +790,74 @@ class _SettingPanelState extends State<_SettingPanel> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ListView( return ListView(
children: [ children: [
Container( Row(
child: Row( children: [
children: [ _bottomIcon(
_bottomIcon( icon: Icons.crop_sharp,
icon: Icons.crop_sharp, title: gReaderDirectionName(),
title: gReaderDirectionName(), onPressed: () async {
onPressed: () async { await choosePagerDirection(context);
await choosePagerDirection(context); setState(() {});
setState(() {}); },
}, ),
), _bottomIcon(
_bottomIcon( icon: Icons.view_day_outlined,
icon: Icons.view_day_outlined, title: currentReaderTypeName(),
title: currentReaderTypeName(), onPressed: () async {
onPressed: () async { await choosePagerType(context);
await choosePagerType(context); setState(() {});
setState(() {}); },
}, ),
), _bottomIcon(
_bottomIcon( icon: Icons.image_aspect_ratio_outlined,
icon: Icons.image_aspect_ratio_outlined, title: currentQualityName(),
title: currentQualityName(), onPressed: () async {
onPressed: () async { await chooseQuality(context);
await chooseQuality(context); setState(() {});
setState(() {}); },
}, ),
), _bottomIcon(
_bottomIcon( icon: Icons.control_camera_outlined,
icon: Icons.control_camera_outlined, title: currentFullScreenActionName(),
title: currentFullScreenActionName(), onPressed: () async {
onPressed: () async { await chooseFullScreenAction(context);
await chooseFullScreenAction(context); setState(() {});
setState(() {}); },
}, ),
), ],
],
),
), ),
Container( Row(
child: Row( children: [
children: [ _bottomIcon(
_bottomIcon( icon: Icons.shuffle,
icon: Icons.shuffle, title: currentAddressName(),
title: currentAddressName(), onPressed: () async {
onPressed: () async { await chooseAddress(context);
await chooseAddress(context); setState(() {});
setState(() {}); },
}, ),
), _bottomIcon(
_bottomIcon( icon: Icons.repeat_one,
icon: Icons.repeat_one, title: currentImageAddressName(),
title: currentImageAddressName(), onPressed: () async {
onPressed: () async { await chooseImageAddress(context);
await chooseImageAddress(context); setState(() {});
setState(() {}); },
}, ),
), _bottomIcon(
_bottomIcon( icon: Icons.refresh,
icon: Icons.refresh, title: "重载页面",
title: "重载页面", onPressed: () {
onPressed: () { Navigator.of(context).pop();
Navigator.of(context).pop(); widget.onReloadEp();
widget.onReloadEp(); },
}, ),
), _bottomIcon(
_bottomIcon( icon: Icons.file_download,
icon: Icons.file_download, title: "下载本作",
title: "下载本作", onPressed: widget.onDownload,
onPressed: widget.onDownload, ),
), ],
],
),
), ),
], ],
); );
@ -917,13 +911,13 @@ class _WebToonReaderState extends _ImageReaderContentState {
@override @override
void initState() { void initState() {
widget.struct.images.forEach((e) { for (var e in widget.struct.images) {
if (e.downloadLocalPath != null) { if (e.downloadLocalPath != null) {
_trueSizes.add(Size(e.width!.toDouble(), e.height!.toDouble())); _trueSizes.add(Size(e.width!.toDouble(), e.height!.toDouble()));
} else { } else {
_trueSizes.add(null); _trueSizes.add(null);
} }
}); }
_itemScrollController = ItemScrollController(); _itemScrollController = ItemScrollController();
_itemPositionsListener = ItemPositionsListener.create(); _itemPositionsListener = ItemPositionsListener.create();
_itemPositionsListener.itemPositions.addListener(_onListCurrentChange); _itemPositionsListener.itemPositions.addListener(_onListCurrentChange);
@ -1077,7 +1071,7 @@ class _WebToonReaderState extends _ImageReaderContentState {
} }
return Container( return Container(
color: Colors.transparent, color: Colors.transparent,
padding: EdgeInsets.all(20), padding: const EdgeInsets.all(20),
child: MaterialButton( child: MaterialButton(
onPressed: () { onPressed: () {
if (super._hasNextEp()) { if (super._hasNextEp()) {
@ -1238,18 +1232,18 @@ class _ListViewReaderState extends _ImageReaderContentState
late TapDownDetails _doubleTapDetails; late TapDownDetails _doubleTapDetails;
late final _animationController = AnimationController( late final _animationController = AnimationController(
vsync: this, vsync: this,
duration: Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
); );
@override @override
void initState() { void initState() {
widget.struct.images.forEach((e) { for (var e in widget.struct.images) {
if (e.downloadLocalPath != null) { if (e.downloadLocalPath != null) {
_trueSizes.add(Size(e.width!.toDouble(), e.height!.toDouble())); _trueSizes.add(Size(e.width!.toDouble(), e.height!.toDouble()));
} else { } else {
_trueSizes.add(null); _trueSizes.add(null);
} }
}); }
super.initState(); super.initState();
} }
@ -1467,6 +1461,7 @@ class _GalleryReaderState extends _ImageReaderContentState {
} }
} }
@override
Widget _buildViewer() { Widget _buildViewer() {
Widget gallery = PhotoViewGallery.builder( Widget gallery = PhotoViewGallery.builder(
scrollDirection: widget.pagerDirection == ReaderDirection.TOP_TO_BOTTOM scrollDirection: widget.pagerDirection == ReaderDirection.TOP_TO_BOTTOM
@ -1574,7 +1569,7 @@ class _GalleryReaderState extends _ImageReaderContentState {
return Align( return Align(
alignment: Alignment.bottomRight, alignment: Alignment.bottomRight,
child: Material( child: Material(
color: Color(0x0), color: Colors.transparent,
child: Container( child: Container(
margin: EdgeInsets.only(bottom: 10), margin: EdgeInsets.only(bottom: 10),
padding: EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4), padding: EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4),

View File

@ -181,7 +181,7 @@ class DownloadImage extends StatefulWidget {
} }
class _DownloadImageState extends State<DownloadImage> { class _DownloadImageState extends State<DownloadImage> {
late Future<String> _future = method.downloadImagePath(widget.path); late final Future<String> _future = method.downloadImagePath(widget.path);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -276,7 +276,7 @@ Widget buildSvg(String source, double? width, double? height,
var widget = Container( var widget = Container(
width: width, width: width,
height: height, height: height,
padding: margin != null ? EdgeInsets.all(10) : null, padding: margin != null ? const EdgeInsets.all(10) : null,
child: Center( child: Center(
child: SvgPicture.asset( child: SvgPicture.asset(
source, source,
@ -319,7 +319,7 @@ Widget buildLoading(double? width, double? height) {
if (width != null && height != null) { if (width != null && height != null) {
size = width < height ? width : height; size = width < height ? width : height;
} }
return Container( return SizedBox(
width: width, width: width,
height: height, height: height,
child: Center( child: Center(

View File

@ -31,7 +31,7 @@ class ItemBuilder<T> extends StatelessWidget {
print("${snapshot.stackTrace}"); print("${snapshot.stackTrace}");
return InkWell( return InkWell(
onTap: onRefresh, onTap: onRefresh,
child: Container( child: SizedBox(
width: _maxWidth, width: _maxWidth,
height: _loadingHeight, height: _loadingHeight,
child: Center( child: Center(
@ -42,7 +42,7 @@ class ItemBuilder<T> extends StatelessWidget {
); );
} }
if (snapshot.connectionState != ConnectionState.done) { if (snapshot.connectionState != ConnectionState.done) {
return Container( return SizedBox(
width: _maxWidth, width: _maxWidth,
height: _loadingHeight, height: _loadingHeight,
child: Center( child: Center(
@ -50,7 +50,7 @@ class ItemBuilder<T> extends StatelessWidget {
), ),
); );
} }
return Container( return SizedBox(
width: _maxWidth, width: _maxWidth,
height: height, height: height,
child: successBuilder(context, snapshot), child: successBuilder(context, snapshot),

View File

@ -10,7 +10,8 @@ class LinkToComicInfo extends StatelessWidget {
const LinkToComicInfo({ const LinkToComicInfo({
required this.comicId, required this.comicId,
required this.child, required this.child,
}); Key? key,
}):super(key: key);
@override @override
Widget build(BuildContext context) => InkWell( Widget build(BuildContext context) => InkWell(

View File

@ -5,16 +5,16 @@ import 'package:pikapika/basic/config/Proxy.dart';
// //
class NetworkSetting extends StatelessWidget { class NetworkSetting extends StatelessWidget {
const NetworkSetting({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Column(
child: Column( children: [
children: [ switchAddressSetting(),
switchAddressSetting(), imageSwitchAddressSetting(),
imageSwitchAddressSetting(), proxySetting(),
proxySetting(), ],
],
),
); );
} }
} }

View File

@ -44,7 +44,7 @@ class _RecommendationState extends State<Recommendation> {
(route) => i++ < 10); (route) => i++ < 10);
}, },
child: Card( child: Card(
child: Container( child: SizedBox(
width: width, width: width,
child: Column( child: Column(
children: [ children: [
@ -60,8 +60,8 @@ class _RecommendationState extends State<Recommendation> {
e.title + '\n', e.title + '\n',
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle(height: 1.4), style: const TextStyle(height: 1.4),
strutStyle: StrutStyle(height: 1.4), strutStyle: const StrutStyle(height: 1.4),
), ),
], ],
), ),

View File

@ -16,6 +16,8 @@ const double _cardHeight = 180;
// //
class UserProfileCard extends StatefulWidget { class UserProfileCard extends StatefulWidget {
const UserProfileCard({Key? key}) : super(key: key);
@override @override
State<StatefulWidget> createState() => _UserProfileCardState(); State<StatefulWidget> createState() => _UserProfileCardState();
} }
@ -46,11 +48,11 @@ class _UserProfileCardState extends State<UserProfileCard> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var theme = Theme.of(context); var theme = Theme.of(context);
var nameStyle = TextStyle( var nameStyle = const TextStyle(
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
); );
var nameStrutStyle = StrutStyle( var nameStrutStyle = const StrutStyle(
fontSize: 14, fontSize: 14,
forceStrutHeight: true, forceStrutHeight: true,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -60,7 +62,7 @@ class _UserProfileCardState extends State<UserProfileCard> {
color: theme.colorScheme.secondary.withOpacity(.9), color: theme.colorScheme.secondary.withOpacity(.9),
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
); );
var levelStrutStyle = StrutStyle( var levelStrutStyle = const StrutStyle(
fontSize: 12, fontSize: 12,
forceStrutHeight: true, forceStrutHeight: true,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -69,7 +71,7 @@ class _UserProfileCardState extends State<UserProfileCard> {
fontSize: 10, fontSize: 10,
color: theme.textTheme.bodyText1?.color?.withOpacity(.5), color: theme.textTheme.bodyText1?.color?.withOpacity(.5),
); );
var sloganStrutStyle = StrutStyle( var sloganStrutStyle = const StrutStyle(
fontSize: 10, fontSize: 10,
forceStrutHeight: true, forceStrutHeight: true,
); );
@ -84,34 +86,32 @@ class _UserProfileCardState extends State<UserProfileCard> {
UserProfile profile = snapshot.data!; UserProfile profile = snapshot.data!;
return Stack( return Stack(
children: [ children: [
Container( Stack(
child: Stack( children: [
children: [ Opacity(
Opacity( opacity: .25, //
opacity: .25, // child: LayoutBuilder(
child: LayoutBuilder( builder:
builder: (BuildContext context, BoxConstraints constraints) {
(BuildContext context, BoxConstraints constraints) { return RemoteImage(
return RemoteImage( path: profile.avatar.path,
path: profile.avatar.path, fileServer: profile.avatar.fileServer,
fileServer: profile.avatar.fileServer, width: constraints.maxWidth,
width: constraints.maxWidth, height: _cardHeight,
height: _cardHeight, );
); },
},
),
), ),
Positioned.fromRect( ),
rect: Rect.largest, Positioned.fromRect(
child: BackdropFilter( rect: Rect.largest,
filter: ImageFilter.blur(sigmaX: 30, sigmaY: 30), child: BackdropFilter(
child: Container(), filter: ImageFilter.blur(sigmaX: 30, sigmaY: 30),
), child: Container(),
), ),
], ),
), ],
), ),
Container( SizedBox(
height: _cardHeight, height: _cardHeight,
child: Column( child: Column(
children: [ children: [
@ -177,7 +177,7 @@ class _UserProfileCardState extends State<UserProfileCard> {
aspectRatioPresets: [ aspectRatioPresets: [
CropAspectRatioPreset.square, CropAspectRatioPreset.square,
], ],
aspectRatio: CropAspectRatio(ratioX: 200, ratioY: 200), aspectRatio: const CropAspectRatio(ratioX: 200, ratioY: 200),
maxWidth: 200, maxWidth: 200,
maxHeight: 200, maxHeight: 200,
androidUiSettings: AndroidUiSettings( androidUiSettings: AndroidUiSettings(
@ -187,7 +187,7 @@ class _UserProfileCardState extends State<UserProfileCard> {
initAspectRatio: CropAspectRatioPreset.original, initAspectRatio: CropAspectRatioPreset.original,
lockAspectRatio: true, lockAspectRatio: true,
), ),
iosUiSettings: IOSUiSettings( iosUiSettings: const IOSUiSettings(
resetAspectRatioEnabled: true, resetAspectRatioEnabled: true,
aspectRatioLockEnabled: true, aspectRatioLockEnabled: true,
title: "修改头像", title: "修改头像",

View File

@ -36,7 +36,7 @@ class _GestureZoomBoxState extends State<GestureZoomBox>
bool _isScaling = false; bool _isScaling = false;
bool _isDragging = false; bool _isDragging = false;
double _maxDragOver = 100; // final double _maxDragOver = 100; //
@override @override
void initState() { void initState() {

View File

@ -104,6 +104,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.5.1" 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: flutter_localizations:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -174,7 +181,7 @@ packages:
name: image_picker name: image_picker
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.8.4+9" version: "0.8.4+11"
image_picker_for_web: image_picker_for_web:
dependency: transitive dependency: transitive
description: description:
@ -210,6 +217,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.3" version: "0.6.3"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
@ -237,14 +251,14 @@ packages:
name: modal_bottom_sheet name: modal_bottom_sheet
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.1"
multi_select_flutter: multi_select_flutter:
dependency: "direct main" dependency: "direct main"
description: description:
name: multi_select_flutter name: multi_select_flutter
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.0" version: "4.1.2"
path: path:
dependency: transitive dependency: transitive
description: description:
@ -417,7 +431,7 @@ packages:
name: url_launcher_web name: url_launcher_web
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.8" version: "2.0.9"
url_launcher_windows: url_launcher_windows:
dependency: transitive dependency: transitive
description: description:

View File

@ -49,6 +49,7 @@ dependencies:
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^1.0.0
# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec # following page: https://dart.dev/tools/pub/pubspec

View File

@ -13,7 +13,7 @@ import 'package:pikapika/main.dart';
void main() { void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async { testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame. // Build our app and trigger a frame.
await tester.pumpWidget(PikapikaApp()); await tester.pumpWidget(const PikapikaApp());
// Verify that our counter starts at 0. // Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget); expect(find.text('0'), findsOneWidget);