diff --git a/assets/images/flutter.png b/assets/images/flutter.png new file mode 100644 index 0000000..7da1247 Binary files /dev/null and b/assets/images/flutter.png differ diff --git a/lib/app/router/unit_router.dart b/lib/app/router/unit_router.dart index 90c3d3f..624160d 100644 --- a/lib/app/router/unit_router.dart +++ b/lib/app/router/unit_router.dart @@ -12,7 +12,6 @@ import 'package:flutter_unit/app/views/setting/theme_color_setting.dart'; import 'package:flutter_unit/app/views/unit_todo/attr_unit_page.dart'; import 'package:flutter_unit/app/views/unit_todo/layout_unit_page.dart'; import 'package:flutter_unit/app/views/unit_todo/point_unit_page.dart'; -import 'package:flutter_unit/painter_system/gallery_page.dart'; import 'package:flutter_unit/point_system/views/issues_point/issues_detail.dart'; import 'package:flutter_unit/point_system/views/issues_point/issues_point_page.dart'; import 'package:flutter_unit/user_system/pages/login/login_page.dart'; @@ -47,7 +46,6 @@ class UnitRouter { static const String attr = 'AttrUnitPage'; static const String bug = 'BugUnitPage'; - static const String galley = 'GalleryPage'; static const String layout = 'LayoutUnitPage'; static const String about_me = 'AboutMePage'; static const String about_app = 'AboutAppPage'; @@ -102,8 +100,6 @@ class UnitRouter { return Right2LeftRouter(child: AttrUnitPage()); case bug: return Right2LeftRouter(child: BugUnitPage()); - case galley: - return Right2LeftRouter(child: GalleryPage()); case layout: return Right2LeftRouter(child: LayoutUnitPage()); case about_app: diff --git a/lib/app/views/about/about_app_page.dart b/lib/app/views/about/about_app_page.dart index c40a9af..6dcdabd 100644 --- a/lib/app/views/about/about_app_page.dart +++ b/lib/app/views/about/about_app_page.dart @@ -2,9 +2,10 @@ import 'package:flutter/cupertino.dart'; /// create by 张风捷特烈 on 2020-04-13 /// contact me by email 1981462002@qq.com /// 说明: - import 'package:flutter/material.dart'; import 'package:flutter_unit/app/res/toly_icon.dart'; +import 'package:flutter_unit/app/router/router_utils.dart'; +import 'package:flutter_unit/app/views/time_line/flutter_unit_time_line.dart'; import 'package:flutter_unit/components/permanent/circle.dart'; import 'package:flutter_unit/components/permanent/circle_image.dart'; import 'package:flutter_unit/components/permanent/feedback_widget.dart'; @@ -22,27 +23,28 @@ class AboutAppPage extends StatelessWidget { Container( child: Stack( children: [ - Column( - children: [ - Container( - height: 150, - width: MediaQuery.of(context).size.width, - margin: EdgeInsets.only(bottom: 50), - child: Image.asset( - 'assets/images/sabar.webp', - fit: BoxFit.cover, - ), - ), - ], + Container( + height: 150, + width: MediaQuery.of(context).size.width, + margin: EdgeInsets.only(bottom: 50), + child: Image.asset( + 'assets/images/sabar.webp', + fit: BoxFit.cover, + ), ), _buildBar(context), Positioned( bottom: 0, left: 50, - child: CircleImage( - size: 100, - shadowColor: Theme.of(context).primaryColor, - image: AssetImage('assets/images/icon_head.webp'), + child: GestureDetector( + onTap: (){ + Navigator.push(context, Right2LeftRouter(child: FlutterUnitTimeLine())); + }, + child: CircleImage( + size: 100, + shadowColor: Theme.of(context).primaryColor, + image: AssetImage('assets/images/icon_head.webp'), + ), )), ], ), @@ -151,10 +153,10 @@ class AboutAppPage extends StatelessWidget { ), InfoPanel( title: '项目简介', - info: ' Flutter Unit 是一个非盈利性的开源项目,' + info: ' Flutter Unit 是一个非盈利性的开源项目,' '旨在提供全面的Flutter学习指南及编程者的交流技术的接口。' '由【张风捷特烈】提供技术支持和全权维护。唯一开源网站网址: ' - 'https://github_model.com/toly1994328/FlutterUnit', + 'https://github.com/toly1994328/FlutterUnit', ), Divider( height: 20, @@ -192,7 +194,7 @@ class InfoPanel extends StatelessWidget { final String info; - InfoPanel({required this.title,required this.info}); + const InfoPanel({Key? key, required this.title,required this.info}) : super(key: key); @override Widget build(BuildContext context) { @@ -201,7 +203,8 @@ class InfoPanel extends StatelessWidget { Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Circle(color: Theme.of(context).primaryColor,), Padding( + Circle(color: Theme.of(context).primaryColor), + Padding( padding: const EdgeInsets.only(left: 15,top: 15,bottom: 15), child: Text('$title',style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold),), ) diff --git a/lib/app/views/about/about_me_page.dart b/lib/app/views/about/about_me_page.dart index de33c53..a17c510 100644 --- a/lib/app/views/about/about_me_page.dart +++ b/lib/app/views/about/about_me_page.dart @@ -1,7 +1,6 @@ /// create by 张风捷特烈 on 2020-04-13 /// contact me by email 1981462002@qq.com /// 说明: - import 'package:flutter/material.dart'; import 'package:flutter_unit/app/res/toly_icon.dart'; import 'package:flutter_unit/components/permanent/circle_image.dart'; @@ -9,27 +8,25 @@ import 'package:flutter_unit/components/permanent/feedback_widget.dart'; import 'package:url_launcher/url_launcher.dart'; class AboutMePage extends StatelessWidget { + const AboutMePage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, body: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Stack( - children: [ - Column( - children: [ - Container( - height: 180, - width: MediaQuery.of(context).size.width, - margin: EdgeInsets.only(bottom: 50), - child: Image.asset( - 'assets/images/sabar.webp', - fit: BoxFit.cover, - ), - ), - ], + children: [ + Container( + height: 180, + width: MediaQuery.of(context).size.width, + margin:const EdgeInsets.only(bottom: 50), + child: Image.asset( + 'assets/images/sabar.webp', + fit: BoxFit.cover, + ), ), _buildBar(context), Positioned( @@ -38,23 +35,21 @@ class AboutMePage extends StatelessWidget { child: CircleImage( size: 100, shadowColor: Theme.of(context).primaryColor, - image: AssetImage('assets/images/icon_head.webp'), + image: const AssetImage('assets/images/icon_head.webp'), )), ], ), Expanded( - child: SingleChildScrollView( - child: Container( - margin: EdgeInsets.all(24), - child: Stack(children: [ - Positioned( - right: 10, - top: 0, - child: _buildLinkIcon(), - ), - _buildInfo() - ]), - ), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 15), + child: Stack(children: [ + Positioned( + right: 10, + top: 0, + child: _buildLinkIcon(), + ), + _buildInfo() + ]), ), ), ], @@ -70,8 +65,8 @@ class AboutMePage extends StatelessWidget { children: [ GestureDetector( onTap: () => Navigator.of(context).pop(), - child: Container( - padding: EdgeInsets.only(left: 10), + child: Padding( + padding: const EdgeInsets.only(left: 10), child: Icon( Icons.arrow_back, size: 30, @@ -79,7 +74,7 @@ class AboutMePage extends StatelessWidget { ), ), ), - Spacer(), + const Spacer(), FeedbackWidget( onPressed: () => _launchURL("mailto:1981462002@qq.com?subject=来自Flutter Unit"), @@ -89,9 +84,7 @@ class AboutMePage extends StatelessWidget { color: Theme.of(context).primaryColor, ), ), - SizedBox( - width: 20, - ) + const SizedBox(width: 20) ], ), ); @@ -108,59 +101,35 @@ class AboutMePage extends StatelessWidget { Widget _buildInfo() { return Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - '张风捷特烈', - style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold), - ), - SizedBox(height: 20), - Text( - 'The King Of Coder. 「编程之王」', - style: TextStyle(fontSize: 16), - ), - SizedBox(height: 10), - Text( - '海的彼岸有我未曾见证的风采。', - style: TextStyle(fontSize: 16), - ), - Divider( - height: 18, - ), - - Text( - '微信群: 编程技术交流圣地-【Flutter群】\n' - '愿青梅煮酒,与君天涯共话。', - style: TextStyle(color: Colors.grey), - ), - SizedBox(height: 10), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Container( - width: 190, - child: Column( - children: [ - Image.asset('assets/images/wechat.webp'), - Text( - '我的微信', - style: TextStyle(fontSize: 16), - ), - ], - ), - ), -// Container( -// width: 160, -// child: Column( -// children: [ -// Image.asset('assets/images/wei_x.jpg'), -// Text( -// '请我喝茶(慎扫)', -// style: TextStyle(fontSize: 16), -// ), -// ], -// ), -// ), - ], + children: [ + const Text('张风捷特烈', + style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold)), + const SizedBox(height: 20), + const Divider(height: 18), + const Text('The King Of Coder. 「编程之王」', style: TextStyle(fontSize: 16)), + const SizedBox(height: 10), + const Text('海的彼岸有我未曾见证的风采。', style: TextStyle(fontSize: 16)), + const SizedBox(height: 10), + const Text( + '微信群: 编程技术交流圣地 -【Flutter群】\n' + '愿青梅煮酒,与君天涯共话。', + style: TextStyle(color: Colors.grey)), + const SizedBox(height: 10), + Expanded( + child: Padding( + padding: const EdgeInsets.all(30.0), + child: AspectRatio( + aspectRatio: 1, + child: Image.asset( + 'assets/images/wechat.webp', + fit: BoxFit.fitWidth, + )), + )), + const Center( + child: Text( + '我的微信', + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), ), ], ); diff --git a/lib/app/views/about/version_info.dart b/lib/app/views/about/version_info.dart index a99d585..4dea397 100644 --- a/lib/app/views/about/version_info.dart +++ b/lib/app/views/about/version_info.dart @@ -17,6 +17,8 @@ import 'version/version_shower.dart'; /// 说明: class VersionInfo extends StatelessWidget { + const VersionInfo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/app/views/data_manage/data_manage_page.dart b/lib/app/views/data_manage/data_manage_page.dart index e963911..94b9315 100644 --- a/lib/app/views/data_manage/data_manage_page.dart +++ b/lib/app/views/data_manage/data_manage_page.dart @@ -24,6 +24,8 @@ import 'package:sqflite/sqflite.dart'; /// class DataManagePage extends StatelessWidget { + const DataManagePage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/app/views/navigation/bloc_wrapper.dart b/lib/app/views/navigation/bloc_wrapper.dart index c0b6fdd..2d84e26 100644 --- a/lib/app/views/navigation/bloc_wrapper.dart +++ b/lib/app/views/navigation/bloc_wrapper.dart @@ -23,7 +23,7 @@ final AppStart storage = AppStart(); class BlocWrapper extends StatefulWidget { final Widget child; - BlocWrapper({required this.child}); + const BlocWrapper({Key? key, required this.child}) : super(key: key); @override _BlocWrapperState createState() => _BlocWrapperState(); diff --git a/lib/app/views/navigation/flutter_unit.dart b/lib/app/views/navigation/flutter_unit.dart index bc3bd20..06a7c0f 100644 --- a/lib/app/views/navigation/flutter_unit.dart +++ b/lib/app/views/navigation/flutter_unit.dart @@ -15,6 +15,8 @@ import 'package:flutter_unit/app/views/splash/unit_splash.dart'; /// 说明: 主程序 class FlutterUnit extends StatelessWidget { + const FlutterUnit({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return BlocBuilder( diff --git a/lib/app/views/navigation/unit_navigation.dart b/lib/app/views/navigation/unit_navigation.dart index 18d17d2..648ce3d 100644 --- a/lib/app/views/navigation/unit_navigation.dart +++ b/lib/app/views/navigation/unit_navigation.dart @@ -18,7 +18,7 @@ import '../../blocs/color_change_bloc.dart'; /// 说明: 主题结构 左右滑页 + 底部导航栏 class UnitNavigation extends StatefulWidget { - const UnitNavigation(); + const UnitNavigation({Key? key}) : super(key: key); @override _UnitNavigationState createState() => _UnitNavigationState(); diff --git a/lib/app/views/setting/code_style_setting.dart b/lib/app/views/setting/code_style_setting.dart index 418f2bb..cc3fa2a 100644 --- a/lib/app/views/setting/code_style_setting.dart +++ b/lib/app/views/setting/code_style_setting.dart @@ -15,7 +15,10 @@ import 'package:flutter_unit/components/permanent/circle.dart'; /// 说明: class CodeStyleSettingPage extends StatelessWidget { - final code = """ + + const CodeStyleSettingPage({Key? key}) : super(key: key); + + final String code = """ const String _kCounty = 'China'; class Hello { @@ -30,6 +33,7 @@ class Hello { }); }"""; + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/app/views/setting/font_setting.dart b/lib/app/views/setting/font_setting.dart index 6cce1d9..190263a 100644 --- a/lib/app/views/setting/font_setting.dart +++ b/lib/app/views/setting/font_setting.dart @@ -13,6 +13,8 @@ import 'package:flutter_unit/components/permanent/circle.dart'; /// 说明: class FontSettingPage extends StatelessWidget { + const FontSettingPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { diff --git a/lib/app/views/setting/item_style_setting.dart b/lib/app/views/setting/item_style_setting.dart index 678d698..ea68f0e 100644 --- a/lib/app/views/setting/item_style_setting.dart +++ b/lib/app/views/setting/item_style_setting.dart @@ -13,6 +13,8 @@ import 'package:flutter_unit/components/project/items/widget/home_item_support.d /// 说明: item样式切换支持 class ItemStyleSettingPage extends StatelessWidget { + const ItemStyleSettingPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/app/views/setting/setting_page.dart b/lib/app/views/setting/setting_page.dart index bcd401a..aeb7c3b 100644 --- a/lib/app/views/setting/setting_page.dart +++ b/lib/app/views/setting/setting_page.dart @@ -7,6 +7,8 @@ import 'package:flutter_unit/app/blocs/global/global_event.dart'; import 'package:flutter_unit/app/blocs/global/global_state.dart'; class SettingPage extends StatelessWidget { + const SettingPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/app/views/setting/theme_color_setting.dart b/lib/app/views/setting/theme_color_setting.dart index 0d704fb..ab9baaa 100644 --- a/lib/app/views/setting/theme_color_setting.dart +++ b/lib/app/views/setting/theme_color_setting.dart @@ -12,6 +12,8 @@ import 'package:flutter_unit/components/permanent/circle.dart'; /// 说明: class ThemeColorSettingPage extends StatelessWidget { + const ThemeColorSettingPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { diff --git a/lib/app/views/splash/splash_bottom.dart b/lib/app/views/splash/splash_bottom.dart index 7662d79..88a2194 100644 --- a/lib/app/views/splash/splash_bottom.dart +++ b/lib/app/views/splash/splash_bottom.dart @@ -3,7 +3,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_unit/app/res/style/unit_text_style.dart'; class SplashBottom extends StatefulWidget { - const SplashBottom(); + const SplashBottom({Key? key}) : super(key: key); + + @override _SplashBottomState createState() => _SplashBottomState(); diff --git a/lib/app/views/splash/unit_splash.dart b/lib/app/views/splash/unit_splash.dart index 2a6a1e1..1625de2 100644 --- a/lib/app/views/splash/unit_splash.dart +++ b/lib/app/views/splash/unit_splash.dart @@ -18,7 +18,8 @@ import 'unit_paint.dart'; /// 说明: app 闪屏页 class UnitSplash extends StatefulWidget { - const UnitSplash(); + const UnitSplash({Key? key}) : super(key: key); + @override _UnitSplashState createState() => _UnitSplashState(); diff --git a/lib/app/views/time_line/flutter_unit_time_line.dart b/lib/app/views/time_line/flutter_unit_time_line.dart new file mode 100644 index 0000000..2e4f8f9 --- /dev/null +++ b/lib/app/views/time_line/flutter_unit_time_line.dart @@ -0,0 +1,239 @@ +import 'package:dash_painter/dash_painter.dart'; +import 'package:flutter/material.dart'; +import 'package:wrapper/wrapper.dart'; + +import 'model/time_node.dart'; + +class FlutterUnitTimeLine extends StatelessWidget { + const FlutterUnitTimeLine({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.black, + appBar: AppBar( + backgroundColor: Colors.black, + title: Text('FlutterUnit 时光轴'), + ), + body: Container( + margin: EdgeInsets.only(top: 0), + child: ListView( + padding: EdgeInsets.only(top: 0, bottom: 20), + children: [ + TimeLineNode( + timeNode: TimeNode( + title: 'FlutterUnit 正式开源', + year: '2020', + content: 'V1.0 版本: 核心功能是组件集录,此时收录 200+ 组件的基本使用方式。', + imageUrl: + 'https://gitee.com/toly1994/toly_blog_pic/raw/master/node1.webp', + time: '2020-04-15', + ), + ), + TimeLineNode( + timeNode: TimeNode( + title: '收藏夹功能完成', + content: '通过收藏夹功能,使用者可以自由创建收藏夹,对组件进行自己的分类。', + imageUrl: + 'https://gitee.com/toly1994/toly_blog_pic/raw/master/node2.webp', + time: '2020-04-23', + ), + ), + TimeLineNode( + timeNode: TimeNode( + title: 'FlutterUnit 支持 MacOS', + content: '通过收藏夹功能,使用者可以自由创建收藏夹,对组件进行自己的分类。', + imageUrl: + 'https://gitee.com/toly1994/toly_blog_pic/raw/master/node4.webp', + time: '2020-05-05', + ), + ), + TimeLineNode( + timeNode: TimeNode( + title: ' Flutter 要点集录', + content: + '要点集录会收集 FlutterUnit 中 point 标签的 issues,在应用中进行展示,从而达到对要点知识的收集', + imageUrl: + 'https://gitee.com/toly1994/toly_blog_pic/raw/master/node3.webp', + time: '2020-09-04', + ), + ), + ], + ), + ), + ); + } +} + +class TimeLineNode extends StatelessWidget { + final TimeNode timeNode; + + const TimeLineNode({Key? key, required this.timeNode}) : super(key: key); + + final double dashLineWith = 20; + final double marginTop = 10; + final double offset = 20 + 10; + final double lineWidth = 2; + final double circleRadius = 5; + + @override + Widget build(BuildContext context) { + return IntrinsicHeight( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(top: 20 + 5, left: 10), + child: timeNode.year != null + ? Text( + '${timeNode.year} 年', + style: TextStyle( + color: Colors.white, fontWeight: FontWeight.bold), + ) + : Visibility( + visible: false, + maintainState: true, + maintainSize: true, + maintainAnimation: true, + child: const Text( + '2020 年', + style: TextStyle( + color: Colors.white, fontWeight: FontWeight.bold), + ))), + _buildDecoration(), + Expanded(flex: 8, child: _buildCenterWidget()), + const Spacer(flex: 1) + ], + ), + ); + } + + Widget _buildDecoration() => Container( + margin: const EdgeInsets.only(left: 10), + width: dashLineWith, + decoration: DashDecoration( + circleColor: Colors.blueAccent, + lineColor: Colors.white, + circleRadius: circleRadius, + color: Colors.white, + circleOffset: Offset(lineWidth / 2, offset + 10 / 2)), + ); + + Widget _buildCenterWidget() { + return Padding( + padding: const EdgeInsets.only(top: 10), + child: Wrapper( + color: Colors.white, + offset: 20 + 10 / 2 - 6, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + timeNode.title, + style: const TextStyle( + fontWeight: FontWeight.bold, color: Colors.purple), + ), + Container( + margin: const EdgeInsets.symmetric(vertical: 5), + child: Text( + timeNode.content, + style: const TextStyle( + color: Colors.lightBlue, + fontSize: 12, + shadows: [ + Shadow(color: Colors.blueAccent, blurRadius: .1) + ]), + ), + ), + if (timeNode.imageUrl != null) + Container( + width: double.infinity, + margin: EdgeInsets.symmetric(vertical: 5), + child: Image( + image: NetworkImage( + timeNode.imageUrl!, + ), + height: 100, + fit: BoxFit.cover, + ), + ), + Align( + alignment: Alignment.centerRight, + child: Text(timeNode.time, + style: const TextStyle( + color: Colors.grey, + fontSize: 14, + fontWeight: FontWeight.bold)), + ) + ], + ), + ), + ); + } +} + +class DashDecoration extends Decoration { + final Color color; + final Color circleColor; + final Color lineColor; + final Offset circleOffset; + final double circleRadius; + + const DashDecoration( + {required this.color, + required this.circleColor, + required this.lineColor, + required this.circleOffset, + required this.circleRadius}); + + @override + BoxPainter createBoxPainter([VoidCallback? onChanged]) => + DashBoxPainter(decoration: this); +} + +class DashBoxPainter extends BoxPainter { + final DashDecoration decoration; + + const DashBoxPainter({required this.decoration}); + + @override + void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) { + canvas.save(); + final Paint paint = Paint()..style = PaintingStyle.stroke; + final Path path = Path(); + canvas.translate( + offset.dx, + offset.dy, + ); + // 绘制直线 + canvas.drawLine( + Offset(-decoration.circleOffset.dx, 0), + Offset(-decoration.circleOffset.dx, configuration.size!.height), + paint + ..color = decoration.lineColor + ..strokeWidth = 2); + + // 绘制虚线 + path + ..moveTo(0, decoration.circleOffset.dy) + ..relativeLineTo(configuration.size!.width, 0); + const DashPainter(span: 2, step: 3).paint( + canvas, + path, + paint + ..color = decoration.color + ..strokeWidth = 1); + + //绘制圆点 + final Paint paint2 = Paint()..color = Colors.white; + canvas.drawCircle( + Offset(-decoration.circleOffset.dx, decoration.circleOffset.dy), + decoration.circleRadius, + paint2); + canvas.drawCircle( + Offset(-decoration.circleOffset.dx, decoration.circleOffset.dy), + decoration.circleRadius * 0.6, + paint2..color = decoration.circleColor); + canvas.restore(); + } +} diff --git a/lib/app/views/time_line/model/time_node.dart b/lib/app/views/time_line/model/time_node.dart new file mode 100644 index 0000000..bb80065 --- /dev/null +++ b/lib/app/views/time_line/model/time_node.dart @@ -0,0 +1,19 @@ +class TimeNode { + final String title; + final String time; + final String? year; + final String content; + final String? imageUrl; + + TimeNode( + {required this.title, + required this.time, + this.year, + required this.content, + this.imageUrl}); + + @override + String toString() { + return 'TimeNode{title: $title, time: $time, content: $content, imageUrl: $imageUrl}'; + } +} diff --git a/lib/app/views/unit_todo/attr_unit_page.dart b/lib/app/views/unit_todo/attr_unit_page.dart index 8f97629..b563313 100644 --- a/lib/app/views/unit_todo/attr_unit_page.dart +++ b/lib/app/views/unit_todo/attr_unit_page.dart @@ -3,10 +3,12 @@ import 'package:flutter_unit/components/permanent/circle_image.dart'; import 'package:flutter_unit/components/permanent/text_typer.dart'; class AttrUnitPage extends StatelessWidget { - final info = '【Flutter属性集录】是Unit项目计划的第二阶段的功能之一。' + final String info = '【Flutter属性集录】是Unit项目计划的第二阶段的功能之一。' '会对所有Widget的所有属性进行收录整理到数据库,进行数据分析和组件关联。' '并且对一些重要属性,进行全面讲解。'; + const AttrUnitPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/app/views/unit_todo/layout_unit_page.dart b/lib/app/views/unit_todo/layout_unit_page.dart index 4dd7107..d710a2b 100644 --- a/lib/app/views/unit_todo/layout_unit_page.dart +++ b/lib/app/views/unit_todo/layout_unit_page.dart @@ -5,10 +5,15 @@ import 'package:flutter_unit/components/permanent/circle_image.dart'; import 'package:flutter_unit/components/permanent/text_typer.dart'; class LayoutUnitPage extends StatelessWidget { - final info = '【Flutter布局集录】是Unit项目计划的第二阶段的功能之一。' + + const LayoutUnitPage({Key? key}) : super(key: key); + + + final String info = '【Flutter布局集录】是Unit项目计划的第二阶段的功能之一。' '将收录大量的布局样板,一者,方便直接使用;二者,方便布局的学习。' '本集录将支持布局征集,愿开发者共同集录。'; + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/app/views/unit_todo/paint_unit_page.dart b/lib/app/views/unit_todo/paint_unit_page.dart index 1e1503f..21ca9ea 100644 --- a/lib/app/views/unit_todo/paint_unit_page.dart +++ b/lib/app/views/unit_todo/paint_unit_page.dart @@ -5,15 +5,17 @@ import 'package:flutter_unit/components/permanent/circle_image.dart'; import 'package:flutter_unit/components/permanent/text_typer.dart'; class PaintUnitPage extends StatelessWidget { - final info = '【Flutter绘制集录】是Unit项目计划的第二阶段的功能之一。' + final String info = '【Flutter绘制集录】是Unit项目计划的第二阶段的功能之一。' '将收录大量绘制作品,展现Flutter强大的绘制表现力,' '以供学习绘制技能。本集录将支持绘制征集,愿开发者共同集录。'; + const PaintUnitPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('绘制集录'), + title: const Text('绘制集录'), ), body: Stack( alignment: Alignment.center, diff --git a/lib/app/views/unit_todo/point_unit_page.dart b/lib/app/views/unit_todo/point_unit_page.dart index d1d2b5f..04c430a 100644 --- a/lib/app/views/unit_todo/point_unit_page.dart +++ b/lib/app/views/unit_todo/point_unit_page.dart @@ -8,10 +8,14 @@ import 'package:flutter_unit/components/permanent/text_typer.dart'; class BugUnitPage extends StatelessWidget { - final info = '【Flutter要点集录】是Unit项目计划的第二阶段的功能之一。' + const BugUnitPage({Key? key}) : super(key: key); + + + final String info = '【Flutter要点集录】是Unit项目计划的第二阶段的功能之一。' '将收录Flutter的常见异常及解决方案,也可以是Flutter中的特点或注意点,' '以供学习参考。本集录将支持异常/特色征集,愿开发者共同集录。'; + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/components/permanent/burst_menu.dart b/lib/components/permanent/burst_menu.dart index ed0c37a..7c76bd8 100644 --- a/lib/components/permanent/burst_menu.dart +++ b/lib/components/permanent/burst_menu.dart @@ -43,7 +43,7 @@ class BurstMenu extends StatefulWidget { this.burstMenuItemClick, }) : super(key: key); - BurstMenu.topLeft({ + const BurstMenu.topLeft({Key? key, required this.menus, this.burstMenuItemClick, this.radius = 100, @@ -54,9 +54,9 @@ class BurstMenu extends StatefulWidget { this.burstType = BurstType.topLeft, this.swapAngle = 90, this.startAngle = 0, - }); + }) : super(key: key); - BurstMenu.bottomLeft({ + const BurstMenu.bottomLeft({Key? key, required this.menus, this.burstMenuItemClick, this.radius = 100, @@ -67,7 +67,7 @@ class BurstMenu extends StatefulWidget { this.burstType = BurstType.bottomLeft, this.swapAngle = 90, this.startAngle = -90, - }); + }) : super(key: key); BurstMenu.topRight({ required this.menus, @@ -82,7 +82,7 @@ class BurstMenu extends StatefulWidget { this.startAngle = 180, }); - BurstMenu.bottomRight({ + const BurstMenu.bottomRight({Key? key, required this.menus, this.burstMenuItemClick, this.radius = 100, @@ -93,7 +93,7 @@ class BurstMenu extends StatefulWidget { this.burstType = BurstType.bottomRight, this.swapAngle = 90, this.startAngle = 180, - }); + }) : super(key: key); @override BurstMenuState createState() => BurstMenuState(); diff --git a/lib/components/permanent/circle.dart b/lib/components/permanent/circle.dart index 7816653..8393450 100644 --- a/lib/components/permanent/circle.dart +++ b/lib/components/permanent/circle.dart @@ -6,13 +6,13 @@ class Circle extends StatelessWidget { final bool showShadow; final Widget? child; - const Circle({this.color=Colors.blue, this.radius=6,this.showShadow=true,this.child}); + const Circle({Key? key, this.color=Colors.blue, this.radius=6,this.showShadow=true,this.child}) : super(key: key); @override Widget build(BuildContext context) { return Container( alignment: Alignment.center, - child: child==null?Container():child, + child: child ?? const SizedBox.shrink(), width: 2*radius, height: 2*radius, decoration: BoxDecoration( diff --git a/lib/components/permanent/loading/planet_loading.dart b/lib/components/permanent/loading/planet_loading.dart index a0a0d54..6986618 100644 --- a/lib/components/permanent/loading/planet_loading.dart +++ b/lib/components/permanent/loading/planet_loading.dart @@ -10,6 +10,8 @@ import '../math_runner.dart'; /// 说明: class PlateLoading extends StatelessWidget { + const PlateLoading({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Container( diff --git a/lib/components/permanent/markdown/markdown_widget.dart b/lib/components/permanent/markdown/markdown_widget.dart index bb6168e..d7ec43c 100644 --- a/lib/components/permanent/markdown/markdown_widget.dart +++ b/lib/components/permanent/markdown/markdown_widget.dart @@ -13,7 +13,7 @@ class MarkdownWidget extends StatelessWidget { final String markdownData; final int style; - MarkdownWidget({this.markdownData = "", this.style = kWhite}); + const MarkdownWidget({Key? key, this.markdownData = "", this.style = kWhite}) : super(key: key); MarkdownStyleSheet _getCommonSheet(BuildContext context, Color codeBackground) { MarkdownStyleSheet markdownStyleSheet = MarkdownStyleSheet.fromTheme(Theme.of(context)); diff --git a/lib/components/permanent/multi_chip_filter.dart b/lib/components/permanent/multi_chip_filter.dart index a20399f..bf0b853 100644 --- a/lib/components/permanent/multi_chip_filter.dart +++ b/lib/components/permanent/multi_chip_filter.dart @@ -12,7 +12,7 @@ class MultiChipFilter extends StatefulWidget { final IndexedWidgetBuilder? avatarBuilder; final Function(List) onChange; - MultiChipFilter({required this.data,required this.labelBuilder,this.avatarBuilder,required this.onChange}); + const MultiChipFilter({Key? key, required this.data,required this.labelBuilder,this.avatarBuilder,required this.onChange}) : super(key: key); @override _MultiChipFilterState createState() => _MultiChipFilterState(); diff --git a/lib/components/permanent/panel.dart b/lib/components/permanent/panel.dart index b2ea134..75b61ca 100644 --- a/lib/components/permanent/panel.dart +++ b/lib/components/permanent/panel.dart @@ -7,7 +7,7 @@ class Panel extends StatelessWidget { final Color? color; final Widget? child; - Panel({this.radius = 5.0, this.color, this.child}); + const Panel({Key? key, this.radius = 5.0, this.color, this.child}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/components/project/dialogs/delete_category_dialog.dart b/lib/components/project/dialogs/delete_category_dialog.dart index 8737c29..6473e92 100644 --- a/lib/components/project/dialogs/delete_category_dialog.dart +++ b/lib/components/project/dialogs/delete_category_dialog.dart @@ -11,9 +11,9 @@ class DeleteCategoryDialog extends StatelessWidget { final VoidCallback? onSubmit; - DeleteCategoryDialog({ + const DeleteCategoryDialog({Key? key, this.title='', this.content ='',this.onSubmit - }); + }) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/components/project/dialogs/dialog_about.dart b/lib/components/project/dialogs/dialog_about.dart index da91816..a5fa955 100644 --- a/lib/components/project/dialogs/dialog_about.dart +++ b/lib/components/project/dialogs/dialog_about.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_unit/app/res/str_unit.dart'; class DialogAbout extends StatelessWidget { + const DialogAbout({Key? key}) : super(key: key); + static show(BuildContext context){ showDialog(//内置方法,创建对话弹框 context: context, diff --git a/lib/components/project/items/collect_widget_list_item.dart b/lib/components/project/items/collect_widget_list_item.dart index bab8a12..eeb0c22 100644 --- a/lib/components/project/items/collect_widget_list_item.dart +++ b/lib/components/project/items/collect_widget_list_item.dart @@ -12,7 +12,7 @@ class CollectWidgetListItem extends StatelessWidget { final WidgetModel data; final Function(WidgetModel model)? onDeleteItemClick; - CollectWidgetListItem({required this.data, this.onDeleteItemClick}); + const CollectWidgetListItem({Key? key, required this.data, this.onDeleteItemClick}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/components/project/items/widget/coupon_widget_list_item.dart b/lib/components/project/items/widget/coupon_widget_list_item.dart index 27dbf7b..0bbf75a 100644 --- a/lib/components/project/items/widget/coupon_widget_list_item.dart +++ b/lib/components/project/items/widget/coupon_widget_list_item.dart @@ -17,11 +17,11 @@ class CouponWidgetListItem extends StatelessWidget { final bool hasBottomHole; final bool isClip; - CouponWidgetListItem( - {required this.data, + const CouponWidgetListItem( + {Key? key, required this.data, this.hasTopHole = true, this.hasBottomHole = false, - this.isClip = true}); + this.isClip = true}) : super(key: key); final List colors = Cons.tabColors; diff --git a/lib/components/project/items/widget/simple_widget_list_item.dart b/lib/components/project/items/widget/simple_widget_list_item.dart index 6037bbf..57aec7a 100644 --- a/lib/components/project/items/widget/simple_widget_list_item.dart +++ b/lib/components/project/items/widget/simple_widget_list_item.dart @@ -17,9 +17,9 @@ import 'package:flutter_unit/widget_system/repositories/model/widget_model.dart' class SimpleWidgetListItem extends StatelessWidget { final WidgetModel data; - SimpleWidgetListItem({ + const SimpleWidgetListItem({Key? key, required this.data, - }); + }) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/components/project/nav/unit_bottom_bar.dart b/lib/components/project/nav/unit_bottom_bar.dart index a9cfa42..3aa960a 100644 --- a/lib/components/project/nav/unit_bottom_bar.dart +++ b/lib/components/project/nav/unit_bottom_bar.dart @@ -20,11 +20,11 @@ class UnitBottomBar extends StatefulWidget { // item 长按事件 final IndexLongTapCallback? onItemLongTap; - UnitBottomBar({ + const UnitBottomBar({Key? key, this.color = Colors.blue, required this.onItemTap, this.onItemLongTap, - }); + }) : super(key: key); @override _UnitBottomBarState createState() => _UnitBottomBarState(); diff --git a/lib/components/project/no_more_widget.dart b/lib/components/project/no_more_widget.dart index a2c8e54..8677112 100644 --- a/lib/components/project/no_more_widget.dart +++ b/lib/components/project/no_more_widget.dart @@ -5,8 +5,9 @@ import 'package:flutter/material.dart'; /// 说明: class NoMoreWidget extends StatelessWidget { + const NoMoreWidget({Key? key}) : super(key: key); + - const NoMoreWidget(); @override Widget build(BuildContext context) { diff --git a/lib/components/project/overlay_tool_wrapper.dart b/lib/components/project/overlay_tool_wrapper.dart index 0ddd291..e889f2c 100644 --- a/lib/components/project/overlay_tool_wrapper.dart +++ b/lib/components/project/overlay_tool_wrapper.dart @@ -36,7 +36,7 @@ class OverlayToolWrapper extends StatefulWidget { class OverlayToolWrapperState extends State with SingleTickerProviderStateMixin { bool show = false; - Offset offset = Offset(200, 200); + late Offset offset; late AnimationController _ctrl; @@ -62,7 +62,7 @@ class OverlayToolWrapperState extends State WidgetsBinding.instance?.addPostFrameCallback((callback) { var px = MediaQuery.of(context).size.width - 100; - var py = 250.0; + var py = MediaQuery.of(context).size.height*0.05; offset = Offset(px, py); entry = OverlayEntry( @@ -166,7 +166,7 @@ class OverlayToolWrapperState extends State void _toWidget() {} void _toGalley() { - Navigator.of(context).pushNamed(UnitRouter.galley); + } void _toPoint() { diff --git a/lib/components/project/unit_drawer_header.dart b/lib/components/project/unit_drawer_header.dart index d197901..d3a5efd 100644 --- a/lib/components/project/unit_drawer_header.dart +++ b/lib/components/project/unit_drawer_header.dart @@ -8,7 +8,7 @@ class UnitDrawerHeader extends StatelessWidget { final Color color; - const UnitDrawerHeader({required this.color}); + const UnitDrawerHeader({Key? key, required this.color}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/components/project/widget_node_panel.dart b/lib/components/project/widget_node_panel.dart index bb7520a..443d122 100644 --- a/lib/components/project/widget_node_panel.dart +++ b/lib/components/project/widget_node_panel.dart @@ -23,13 +23,13 @@ class WidgetNodePanel extends StatefulWidget { final HighlighterStyle? codeStyle; final String? codeFamily; - WidgetNodePanel( - {this.text='', + const WidgetNodePanel( + {Key? key, this.text='', this.subText='', this.code='', this.show, required this.codeStyle, - this.codeFamily}); + this.codeFamily}) : super(key: key); @override _WidgetNodePanelState createState() => _WidgetNodePanelState(); diff --git a/lib/components/project/wrapper/honour_wrapper.dart b/lib/components/project/wrapper/honour_wrapper.dart index 9d0a0cc..e598d57 100644 --- a/lib/components/project/wrapper/honour_wrapper.dart +++ b/lib/components/project/wrapper/honour_wrapper.dart @@ -9,7 +9,7 @@ import 'package:flutter/material.dart'; class HonourWrapper extends StatefulWidget { final String username; - HonourWrapper({this.username = '张风捷特烈'}); + const HonourWrapper({Key? key, this.username = '张风捷特烈'}) : super(key: key); @override _HonourWrapperState createState() => _HonourWrapperState(); diff --git a/lib/painter_system/gallery.dart b/lib/painter_system/gallery.dart deleted file mode 100644 index 99922bf..0000000 --- a/lib/painter_system/gallery.dart +++ /dev/null @@ -1,191 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -import 'art/circle_packing.dart'; -import 'art/cubic_disarray.dart'; -import 'base/draw_picture.dart'; -import 'art/hypnotic_squares.dart'; -import 'art/joy_division.dart'; -import 'art/piet_mondrian.dart'; -import 'fun/random_portrait.dart'; -import 'art/tiled_lines.dart'; -import 'art/triangular_mesh.dart'; -import 'art/un_deux_trois.dart'; -import 'anim/draw_path.dart'; -import 'picture_frame.dart'; - -/// create by 张风捷特烈 on 2020/10/10 -/// contact me by email 1981462002@qq.com -/// 说明: - -class Gallery extends StatefulWidget { - @override - _GalleryState createState() => _GalleryState(); -} - -class _GalleryState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - body: Column(children: [ - // _buildTitle(), - Expanded( - child: Container( - // color: Colors.lightBlueAccent, - child: Center( - child: PageView( - children: [ - FrameShower( - title: "The Chaos", - author: "张风捷特烈", - info: - " 本样例介绍如何进行图片的绘制。通过加载图片并将图片资源绘制到指定的区域。在上层绘制一批45°倾角的栅格线,可以练习基本的绘制。", - content: DrawPicture()), - FrameShower( - title: "Draw Curve", - author: "张风捷特烈", - info: - " 本样例介绍如何使用路径绘制函数曲线,并使用路径测量进行动画", - content: DrawPath()), - FrameShower( - title: "Random Portrait", - author: "张风捷特烈", - info: - " 本样例介绍绘制矩形及随机数处理。通过点位集合确定矩形位置信息,将其绘制出来。其中对点的随机生成和对称处理能让你练习对数据的控制力。", - content: RandomPortrait()), - FrameShower( - title: "Tiled Line", - author: "generativeartistry.com", - info: - "本样例根源来自generativeartistry.com的tiled-lines,由xrr2016使用Flutter实现。仓库地址:flutter-generative-artistry", - content: TiledLines(), - ), - FrameShower( - title: "Joy Division", - author: "generativeartistry.com", - info: - "本样例根源来自generativeartistry.com的joy-division,由xrr2016使用Flutter实现。仓库地址:flutter-generative-artistry", - content: JoyDivision(), - ), - FrameShower( - title: "Cubic Disarray", - author: "generativeartistry.com", - info: - "本样例根源来自generativeartistry.com的cubic-disarray,由xrr2016使用Flutter实现。仓库地址:flutter-generative-artistry", - content: CubicDisarray(), - ), - FrameShower( - title: "Triangular Mesh", - author: "generativeartistry.com", - info: - "本样例根源来自generativeartistry.com的triangular-mesh,由xrr2016使用Flutter实现。仓库地址:flutter-generative-artistry", - content: TriangularMesh(), - ), - FrameShower( - title: "Un Deux Trois", - author: "generativeartistry.com", - info: - "本样例根源来自generativeartistry.com的un-deux-trois,由xrr2016使用Flutter实现。仓库地址:flutter-generative-artistry", - content: UnDeuxTrois(), - ), - FrameShower( - title: "Circle Packing", - author: "generativeartistry.com", - info: - "本样例根源来自generativeartistry.com的circle-packing,由xrr2016使用Flutter实现。仓库地址:flutter-generative-artistry", - content: CirclePacking(), - ), - FrameShower( - title: "Hypnotic Squares", - author: "generativeartistry.com", - info: - "本样例根源来自generativeartistry.com的hypnotic-squares,由xrr2016使用Flutter实现。仓库地址:flutter-generative-artistry", - content: HypnoticSquares(), - ), - FrameShower( - title: "Piet Mondrian", - author: "generativeartistry.com", - info: - "本样例根源来自generativeartistry.com的piet-mondrian,由xrr2016使用Flutter实现。仓库地址:flutter-generative-artistry", - content: PietMondrian(), - ) - ], - ), - ), - ), - ), - ])); - } -} - -class FrameShower extends StatelessWidget { - final String title; - final String author; - final String srcUrl; - final String info; - final Widget content; - - FrameShower( - {Key? key, - this.title = "", - this.author = "", - this.srcUrl = "", - this.info = "", - required this.content}) - : super(key: key); - - @override - Widget build(BuildContext context) { - return Align( - alignment: Alignment.topCenter, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - SizedBox(height: 15,), - Text( - title, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), - ), - PictureFrame( - width: MediaQuery.of(context).size.shortestSide, - height: MediaQuery.of(context).size.shortestSide, - child: content, - ), - - Container( - padding: EdgeInsets.symmetric(horizontal: 12), - child: Row( - children: [ - Text( - "作者: $author ", - style: TextStyle(fontSize: 12, fontWeight: FontWeight.bold), - ), - Spacer(), - Text( - "源码地址 ", - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.bold, - color: Colors.blueAccent), - ), - ], - ), - ), - SizedBox( - height: 10, - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 12), - alignment: Alignment.topLeft, - child: Text( - info, - style: TextStyle( - fontSize: 12, - color: Colors.grey, - fontWeight: FontWeight.bold), - )), - ], - ), - ); - } -} diff --git a/lib/painter_system/gallery_factory.dart b/lib/painter_system/gallery_factory.dart index 366c693..17a7074 100644 --- a/lib/painter_system/gallery_factory.dart +++ b/lib/painter_system/gallery_factory.dart @@ -21,7 +21,10 @@ import 'base/draw_picture.dart'; import 'fun/dundun_view.dart'; import 'fun/random_portrait.dart'; import 'fun/stemp/stamp_paper.dart'; -import 'gallery.dart'; +import 'particle/random/random_particle.dart'; +import 'particle/split/particle_split.dart'; +import 'particle/split_img/split_image.dart'; +import 'picture_frame.dart'; /// create by 张风捷特烈 on 2020/12/5 /// contact me by email 1981462002@qq.com @@ -100,7 +103,26 @@ class GalleryFactory { content: Bezier3Player()), ]; case GalleryType.particle: - return []; + return [ + FrameShower( + title: "随机粒子生成器", + author: "张风捷特烈", + info: + " 本样例介绍如何创建随机粒子及边界反弹逻辑处理,是学习粒子运动非常好的入门案例。", + content: RandomParticle()), + FrameShower( + title: "粒子分裂", + author: "张风捷特烈", + info: + " 本样例介绍如何对个粒子进行碰撞检测,并分裂处多个粒子,是一个比较有趣的案例。", + content: ParticleSplit()), + FrameShower( + title: "图片粒子分裂", + author: "张风捷特烈", + info: + " 本样例介绍将图片使用粒子表示,并对粒子进行动画处理,达到爆炸的效果。", + content: SplitImage()), + ]; case GalleryType.fun: return [ FrameShower( diff --git a/lib/painter_system/gallery_page.dart b/lib/painter_system/gallery_page.dart deleted file mode 100644 index afeb7d2..0000000 --- a/lib/painter_system/gallery_page.dart +++ /dev/null @@ -1,195 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -import 'package:flutter_unit/painter_system/art/circle_packing.dart'; -import 'package:flutter_unit/painter_system/art/cubic_disarray.dart'; -import 'package:flutter_unit/painter_system/base/draw_picture.dart'; -import 'package:flutter_unit/painter_system/art/hypnotic_squares.dart'; -import 'package:flutter_unit/painter_system/art/joy_division.dart'; -import 'package:flutter_unit/painter_system/art/piet_mondrian.dart'; -import 'package:flutter_unit/painter_system/fun/random_portrait.dart'; -import 'package:flutter_unit/painter_system/art/tiled_lines.dart'; -import 'package:flutter_unit/painter_system/art/triangular_mesh.dart'; -import 'package:flutter_unit/painter_system/art/un_deux_trois.dart'; -import 'package:flutter_unit/painter_system/anim/draw_path.dart'; -import 'package:flutter_unit/painter_system/picture_frame.dart'; - -/// create by 张风捷特烈 on 2020/10/10 -/// contact me by email 1981462002@qq.com -/// 说明: - -class GalleryPage extends StatefulWidget { - @override - _GalleryPageState createState() => _GalleryPageState(); -} - -class _GalleryPageState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - centerTitle: true, - title: Text("Flutter 绘制集录"), - ), - body: Column(children: [ - // _buildTitle(), - Expanded( - child: Container( - // color: Colors.lightBlueAccent, - child: Center( - child: PageView( - children: [ - FrameShower( - title: "The Chaos", - author: "张风捷特烈", - info: - " 本样例介绍如何进行图片的绘制。通过加载图片并将图片资源绘制到指定的区域。在上层绘制一批45°倾角的栅格线,可以练习基本的绘制。", - content: DrawPicture()), - FrameShower( - title: "Draw Curve", - author: "张风捷特烈", - info: - " 本样例介绍如何使用路径绘制函数曲线,并使用路径测量进行动画", - content: DrawPath()), - FrameShower( - title: "Random Portrait", - author: "张风捷特烈", - info: - " 本样例介绍绘制矩形及随机数处理。通过点位集合确定矩形位置信息,将其绘制出来。其中对点的随机生成和对称处理能让你练习对数据的控制力。", - content: RandomPortrait()), - FrameShower( - title: "Tiled Line", - author: "generativeartistry.com", - info: - "本样例根源来自generativeartistry.com的tiled-lines,由xrr2016使用Flutter实现。仓库地址:flutter-generative-artistry", - content: TiledLines(), - ), - FrameShower( - title: "Joy Division", - author: "generativeartistry.com", - info: - "本样例根源来自generativeartistry.com的joy-division,由xrr2016使用Flutter实现。仓库地址:flutter-generative-artistry", - content: JoyDivision(), - ), - FrameShower( - title: "Cubic Disarray", - author: "generativeartistry.com", - info: - "本样例根源来自generativeartistry.com的cubic-disarray,由xrr2016使用Flutter实现。仓库地址:flutter-generative-artistry", - content: CubicDisarray(), - ), - FrameShower( - title: "Triangular Mesh", - author: "generativeartistry.com", - info: - "本样例根源来自generativeartistry.com的triangular-mesh,由xrr2016使用Flutter实现。仓库地址:flutter-generative-artistry", - content: TriangularMesh(), - ), - FrameShower( - title: "Un Deux Trois", - author: "generativeartistry.com", - info: - "本样例根源来自generativeartistry.com的un-deux-trois,由xrr2016使用Flutter实现。仓库地址:flutter-generative-artistry", - content: UnDeuxTrois(), - ), - FrameShower( - title: "Circle Packing", - author: "generativeartistry.com", - info: - "本样例根源来自generativeartistry.com的circle-packing,由xrr2016使用Flutter实现。仓库地址:flutter-generative-artistry", - content: CirclePacking(), - ), - FrameShower( - title: "Hypnotic Squares", - author: "generativeartistry.com", - info: - "本样例根源来自generativeartistry.com的hypnotic-squares,由xrr2016使用Flutter实现。仓库地址:flutter-generative-artistry", - content: HypnoticSquares(), - ), - FrameShower( - title: "Piet Mondrian", - author: "generativeartistry.com", - info: - "本样例根源来自generativeartistry.com的piet-mondrian,由xrr2016使用Flutter实现。仓库地址:flutter-generative-artistry", - content: PietMondrian(), - ) - ], - ), - ), - ), - ), - ])); - } -} - -class FrameShower extends StatelessWidget { - final String title; - final String author; - final String srcUrl; - final String info; - final Widget content; - - FrameShower( - {Key? key, - this.title = "", - this.author = "", - this.srcUrl = "", - this.info = "", - required this.content}) - : super(key: key); - - @override - Widget build(BuildContext context) { - return Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - PictureFrame( - width: MediaQuery.of(context).size.shortestSide, - height: MediaQuery.of(context).size.shortestSide, - child: content, - ), - Text( - title, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), - ), - SizedBox( - height: 10, - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 12), - child: Row( - children: [ - Text( - "作者: $author ", - style: TextStyle(fontSize: 12, fontWeight: FontWeight.bold), - ), - Spacer(), - Text( - "源码地址 ", - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.bold, - color: Colors.blueAccent), - ), - ], - ), - ), - SizedBox( - height: 10, - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 12), - alignment: Alignment.topLeft, - child: Text( - info, - style: TextStyle( - fontSize: 12, - color: Colors.grey, - fontWeight: FontWeight.bold), - )), - ], - ), - ); - } -} diff --git a/lib/painter_system/particle/random/particle.dart b/lib/painter_system/particle/random/particle.dart new file mode 100644 index 0000000..114358a --- /dev/null +++ b/lib/painter_system/particle/random/particle.dart @@ -0,0 +1,42 @@ +import 'dart:ui'; + +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; + +class Particle { + /// x 位移. + double x; + + /// y 位移. + double y; + + /// 粒子水平速度. + double vx; + + // 粒子水平加速度 + double ax; + + // 粒子竖直加速度 + double ay; + + ///粒子竖直速度. + double vy; + + + /// 粒子大小. + double size; + + /// 粒子颜色. + Color color; + + Particle({ + this.x = 0, + this.y = 0, + this.ax = 0, + this.ay = 0, + this.vx = 0, + this.vy = 0, + this.size = 0, + this.color = Colors.black, + }); +} diff --git a/lib/painter_system/particle/random/particle_manage.dart b/lib/painter_system/particle/random/particle_manage.dart new file mode 100644 index 0000000..d8b70b4 --- /dev/null +++ b/lib/painter_system/particle/random/particle_manage.dart @@ -0,0 +1,61 @@ +import 'dart:math'; + +import 'package:flutter/cupertino.dart'; + +import 'particle.dart'; + +/// create by 张风捷特烈 on 2020/11/7 +/// contact me by email 1981462002@qq.com +/// 说明: + +class ParticleManage with ChangeNotifier { + List particles = []; + + Size size; + + ParticleManage({ this.size = Size.zero}); + + void addParticle(Particle particle) { + particles.add(particle); + notifyListeners(); + } + + void tick() { + particles.forEach(doUpdate); + notifyListeners(); + } + + void doUpdate(Particle p) { + p.vy += p.ay; // y加速度变化 + p.vx += p.ax; // x加速度变化 + p.x += p.vx; + p.y += p.vy; + + if(p.x>size.width-p.size){ + p.x = size.width-p.size; + p.vx = -p.vx; + } + + if(p.x < p.size){ + p.x = p.size; + p.vx = -p.vx; + } + + if(p.y > size.height-p.size){ + p.y = size.height-p.size; + p.vy = -p.vy; + } + if(p.y < p.size){ + p.y = p.size; + p.vy = -p.vy; + } + + } + + void reset() { + particles.forEach((p) { + p.x = 0; + }); + notifyListeners(); + } +} diff --git a/lib/painter_system/particle/random/random_particle.dart b/lib/painter_system/particle/random/random_particle.dart new file mode 100644 index 0000000..bee67e1 --- /dev/null +++ b/lib/painter_system/particle/random/random_particle.dart @@ -0,0 +1,93 @@ +import 'dart:async'; +import 'dart:math'; +import 'dart:ui'; + +// import 'dart:ui' as ui; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'particle.dart'; + +import 'particle_manage.dart'; +import 'world_render.dart'; + +/// create by 张风捷特烈 on 2020/11/5 +/// contact me by email 1981462002@qq.com +/// 说明: + +class RandomParticle extends StatefulWidget { + @override + _RandomParticleState createState() => _RandomParticleState(); +} + +class _RandomParticleState extends State with SingleTickerProviderStateMixin { + late AnimationController _controller; + ParticleManage pm = ParticleManage(); + Random random = Random(); + Timer? _timer; + + @override + void initState() { + super.initState(); + + + _timer =Timer.periodic(Duration(seconds: 1),addParticle); + + _controller = AnimationController( + duration: const Duration(seconds: 1), + vsync: this, + )..addListener(pm.tick) + ..repeat(); + } + + void addParticle(Timer timer){ + if(pm.particles.length>20){ + timer.cancel(); + } + pm.addParticle(Particle( + color: randomRGB(), + size: 5 + 4 * random.nextDouble(), + vx: 3 * random.nextDouble() * pow(-1, random.nextInt(20)), + vy: 3 * random.nextDouble() * pow(-1, random.nextInt(20)), + ay: 0.1, + x: 150, + y: 100)); + } + + Color randomRGB({int limitR = 0, int limitG = 0, int limitB = 0,}) { + var r = limitR + random.nextInt(256 - limitR); //红值 + var g = limitG + random.nextInt(256 - limitG); //绿值 + var b = limitB + random.nextInt(256 - limitB); //蓝值 + return Color.fromARGB(255, r, g, b); //生成argb模式的颜色 + } + + @override + void dispose() { + _controller.dispose(); + _timer?.cancel(); + super.dispose(); + } + + theWorld() { + if (_controller.isAnimating) { + _controller.stop(); + } else { + _controller.repeat(); + } + } + + @override + Widget build(BuildContext context) { + return LayoutBuilder( + builder: (_,constraints){ + pm.size = constraints.biggest; + return GestureDetector( + onTap: theWorld, + child: CustomPaint( + size: pm.size, + painter: WorldRender(manage: pm), + ), + ); + }, + ); + } +} diff --git a/lib/painter_system/particle/random/world_render.dart b/lib/painter_system/particle/random/world_render.dart new file mode 100644 index 0000000..06bc79a --- /dev/null +++ b/lib/painter_system/particle/random/world_render.dart @@ -0,0 +1,37 @@ +import 'package:flutter/material.dart'; + +import 'particle.dart'; +import 'particle_manage.dart'; + +/// create by 张风捷特烈 on 2020/11/7 +/// contact me by email 1981462002@qq.com +/// 说明: + +class WorldRender extends CustomPainter { + + final ParticleManage manage; + + Paint fillPaint = Paint(); + + Paint stokePaint = Paint() + ..strokeWidth = 0.5 + ..style = PaintingStyle.stroke; + + WorldRender({required this.manage}) : super(repaint: manage); + + @override + void paint(Canvas canvas, Size size) { + manage.particles.forEach((particle) { + drawParticle(canvas, particle); + }); + } + + void drawParticle(Canvas canvas, Particle particle) { + fillPaint.color = particle.color; + canvas.drawCircle(Offset(particle.x, particle.y), particle.size, fillPaint); + } + + @override + bool shouldRepaint(covariant WorldRender oldDelegate) => + oldDelegate.manage != manage; +} diff --git a/lib/painter_system/particle/split/particle.dart b/lib/painter_system/particle/split/particle.dart new file mode 100644 index 0000000..63df95d --- /dev/null +++ b/lib/painter_system/particle/split/particle.dart @@ -0,0 +1,62 @@ +import 'dart:ui'; + +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; + +class Particle { + /// x 位移. + double x; + + /// y 位移. + double y; + + /// 粒子水平速度. + double vx; + + // 粒子水平加速度 + double ax; + + // 粒子竖直加速度 + double ay; + + ///粒子竖直速度. + double vy; + + /// 粒子大小. + double size; + + /// 粒子颜色. + Color color; + + Particle({ + this.x = 0, + this.y = 0, + this.ax = 0, + this.ay = 0, + this.vx = 0, + this.vy = 0, + this.size = 0, + this.color = Colors.black, + }); + + Particle copyWith( + { double? x, + double? y, + double? ax, + double? ay, + double? vx, + double? vy, + double? size, + Color? color + } + ) => + Particle( + x: x ?? this.x, + y: y ?? this.y, + ax: ax ?? this.ax, + ay: ay ?? this.ay, + vx: vx ?? this.vx, + vy: vy ?? this.vy, + size: size ?? this.size, + color: color ?? this.color); +} diff --git a/lib/painter_system/particle/split/particle_manage.dart b/lib/painter_system/particle/split/particle_manage.dart new file mode 100644 index 0000000..16370a2 --- /dev/null +++ b/lib/painter_system/particle/split/particle_manage.dart @@ -0,0 +1,94 @@ +import 'dart:math'; + +import 'package:flutter/cupertino.dart'; + +import 'particle.dart'; + +/// create by 张风捷特烈 on 2020/11/7 +/// contact me by email 1981462002@qq.com +/// 说明: + +class ParticleManage with ChangeNotifier { + List particles = []; + Random random = Random(); + + Size size; + + ParticleManage({this.size=Size.zero}); + + void setParticles(List particles) { + this.particles = particles; + } + + void addParticle(Particle particle) { + particles.add(particle); + notifyListeners(); + } + + void tick() { + for (int i = 0; i < particles.length; i++) { + doUpdate(particles[i]); + } + notifyListeners(); + } + + void doUpdate(Particle p) { + p.vy += p.ay; // y加速度变化 + p.vx += p.ax; // x加速度变化 + p.x += p.vx; + p.y += p.vy; + + if (p.x > size.width-p.size) { + p.x = size.width-p.size; + + var newSize = p.size / 2; + if (newSize > 1) {// 如果尺寸小于 1 ,执行分裂 + Particle p0 = + p.copyWith(size: newSize, vx: -p.vx, vy: -p.vy, color: randomRGB()); + particles.add(p0); + p.size = newSize; + p.vx = -p.vx; + } + } + + if (p.x < p.size) { + p.x = p.size; + p.vx = -p.vx; + } + + if (p.y > size.height-p.size) { + p.y = size.height-p.size; + + var newSize = p.size / 2; + if (newSize > 1) { + Particle p0 = + p.copyWith(size: newSize, vx: -p.vx, vy: -p.vy, color: randomRGB()); + particles.add(p0); + p.size = newSize; + p.vy = -p.vy; + } + } + if (p.y < p.size) { + p.y = p.size; + p.vy = -p.vy; + } + } + + void reset() { + particles.forEach((p) { + p.x = 0; + }); + notifyListeners(); + } + + Color randomRGB({ + int limitR = 0, + int limitG = 0, + int limitB = 0, + }) { + var r = limitR + random.nextInt(256 - limitR); //红值 + var g = limitG + random.nextInt(256 - limitG); //绿值 + var b = limitB + random.nextInt(256 - limitB); //蓝值 + return Color.fromARGB(255, r, g, b); //生成argb模式的颜色 + } +} diff --git a/lib/painter_system/particle/split/particle_split.dart b/lib/painter_system/particle/split/particle_split.dart new file mode 100644 index 0000000..e92a81b --- /dev/null +++ b/lib/painter_system/particle/split/particle_split.dart @@ -0,0 +1,99 @@ +import 'dart:async'; +import 'dart:math'; +import 'dart:ui'; + +// import 'dart:ui' as ui; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'particle.dart'; + +import 'particle_manage.dart'; +import 'world_render.dart'; + +/// create by 张风捷特烈 on 2020/11/5 +/// contact me by email 1981462002@qq.com +/// 说明: + +class ParticleSplit extends StatefulWidget { + @override + _ParticleSplitState createState() => _ParticleSplitState(); +} + +class _ParticleSplitState extends State with SingleTickerProviderStateMixin { + late AnimationController _controller; + ParticleManage pm = ParticleManage(); + Random random = Random(); + + @override + void initState() { + super.initState(); + + _controller = AnimationController( + duration: const Duration(seconds: 1), + vsync: this, + )..addListener(pm.tick); + + initParticle(); + // Future.delayed(Duration(seconds: 1)).then((value){ + // + // }); + } + + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + // void theWorld() { + // if (_controller.isAnimating) { + // _controller.stop(); + // } else { + // _controller.repeat(); + // } + // } + + @override + Widget build(BuildContext context) { + return LayoutBuilder( + builder: (_,constraints){ + pm.size = constraints.biggest; + return GestureDetector( + // onDoubleTap: (){ + // pm.addParticle(Particle( + // color: Colors.blue, + // size: 50, + // vx: 4 * random.nextDouble() * pow(-1, random.nextInt(20)), + // vy: 4 * random.nextDouble() * pow(-1, random.nextInt(20)), + // ay: 0.1, + // ax: 0.1, + // x: 150, + // y: 100)); + // }, + onTap: initParticle, + child: CustomPaint( + size: pm.size, + painter: WorldRender(manage: pm), + ), + ); + }, + ); + + } + + void initParticle(){ + pm.particles.clear(); + pm.addParticle(Particle( + color: Colors.blue, + size: 50, + vx: 4 * random.nextDouble() * pow(-1, random.nextInt(20)), + vy: 4 * random.nextDouble() * pow(-1, random.nextInt(20)), + ay: 0.1, + ax: 0.1, + x: 150, + y: 100)); + _controller.reset(); + _controller.repeat(); + } +} diff --git a/lib/painter_system/particle/split/world_render.dart b/lib/painter_system/particle/split/world_render.dart new file mode 100644 index 0000000..6ac35a9 --- /dev/null +++ b/lib/painter_system/particle/split/world_render.dart @@ -0,0 +1,37 @@ +import 'package:flutter/material.dart'; + +import 'particle.dart'; +import 'particle_manage.dart'; + +/// create by 张风捷特烈 on 2020/11/7 +/// contact me by email 1981462002@qq.com +/// 说明: + +class WorldRender extends CustomPainter { + + final ParticleManage manage; + + Paint fillPaint = Paint(); + + Paint stokePaint = Paint() + ..strokeWidth = 0.5 + ..style = PaintingStyle.stroke; + + WorldRender({ required this.manage}) : super(repaint: manage); + + @override + void paint(Canvas canvas, Size size) { + manage.particles.forEach((particle) { + drawParticle(canvas, particle); + }); + } + + void drawParticle(Canvas canvas, Particle particle) { + fillPaint.color = particle.color; + canvas.drawCircle(Offset(particle.x, particle.y), particle.size, fillPaint); + } + + @override + bool shouldRepaint(covariant WorldRender oldDelegate) => + oldDelegate.manage != manage; +} diff --git a/lib/painter_system/particle/split_img/particle.dart b/lib/painter_system/particle/split_img/particle.dart new file mode 100644 index 0000000..1930352 --- /dev/null +++ b/lib/painter_system/particle/split_img/particle.dart @@ -0,0 +1,61 @@ +import 'dart:ui'; + +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; + +class Particle { + /// x 位移. + double x; + + /// y 位移. + double y; + + /// 粒子水平速度. + double vx; + + // 粒子水平加速度 + double ax; + + // 粒子竖直加速度 + double ay; + + ///粒子竖直速度. + double vy; + + /// 粒子大小. + double size; + + /// 粒子颜色. + Color color; + + Particle({ + this.x = 0, + this.y = 0, + this.ax = 0, + this.ay = 0, + this.vx = 0, + this.vy = 0, + this.size = 0, + this.color = Colors.black, + }); + + Particle copyWith( + { double? x, + double? y, + double? ax, + double? ay, + double? vx, + double? vy, + double? size, + Color? color} + ) => + Particle( + x: x ?? this.x, + y: y ?? this.y, + ax: ax ?? this.ax, + ay: ay ?? this.ay, + vx: vx ?? this.vx, + vy: vy ?? this.vy, + size: size ?? this.size, + color: color ?? this.color); +} diff --git a/lib/painter_system/particle/split_img/particle_manage.dart b/lib/painter_system/particle/split_img/particle_manage.dart new file mode 100644 index 0000000..0bb5479 --- /dev/null +++ b/lib/painter_system/particle/split_img/particle_manage.dart @@ -0,0 +1,82 @@ +import 'dart:math'; + +import 'package:flutter/cupertino.dart'; + +import 'particle.dart'; + +/// create by 张风捷特烈 on 2020/11/7 +/// contact me by email 1981462002@qq.com +/// 说明: + +class ParticleManage with ChangeNotifier { + List particles = []; + final VoidCallback? onEnd; + Random random = Random(); + + Size size; + + ParticleManage({this.size=Size.zero,this.onEnd}); + + void setParticles(List particles) { + this.particles = particles; + } + + void addParticle(Particle particle) { + particles.add(particle); + notifyListeners(); + } + + void tick({bool run=true}) { + if(run){ + for (int i = 0; i < particles.length; i++) { + doUpdate(particles[i]); + } + } + if(particles.length!=0){ + notifyListeners(); + } + } + + void doUpdate(Particle p) { + p.vy += p.ay; // y加速度变化 + p.vx += p.ax; // x加速度变化 + p.x += p.vx; + p.y += p.vy; + + if (p.x > size.width) { + particles.remove(p); + } + + if (p.x < 0) { + particles.remove(p); + } + + if (p.y > size.height) { + particles.remove(p); + } + if (p.y < 0) { + particles.remove(p); + } + if(particles.length==0){ + onEnd?.call(); + } + } + + void reset() { + particles.forEach((p) { + p.x = 0; + }); + notifyListeners(); + } + + Color randomRGB({ + int limitR = 0, + int limitG = 0, + int limitB = 0, + }) { + var r = limitR + random.nextInt(256 - limitR); //红值 + var g = limitG + random.nextInt(256 - limitG); //绿值 + var b = limitB + random.nextInt(256 - limitB); //蓝值 + return Color.fromARGB(255, r, g, b); //生成argb模式的颜色 + } +} diff --git a/lib/painter_system/particle/split_img/split_image.dart b/lib/painter_system/particle/split_img/split_image.dart new file mode 100644 index 0000000..4aef913 --- /dev/null +++ b/lib/painter_system/particle/split_img/split_image.dart @@ -0,0 +1,104 @@ + +import 'dart:math'; +import 'dart:typed_data'; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'particle.dart'; +import 'package:image/image.dart' as image; +import 'particle_manage.dart'; +import 'world_render.dart'; + +/// create by 张风捷特烈 on 2020/11/5 +/// contact me by email 1981462002@qq.com +/// 说明: + +class SplitImage extends StatefulWidget { + @override + _SplitImageState createState() => _SplitImageState(); +} + +class _SplitImageState extends State with SingleTickerProviderStateMixin { + late AnimationController _controller; + late ParticleManage pm; + Random random = Random(); + + @override + void initState() { + super.initState(); + pm = ParticleManage( + onEnd: (){ + _controller.stop(); + } + ); + + initParticles(); + + _controller = AnimationController( + duration: const Duration(seconds: 1), + vsync: this, + )..addListener(pm.tick); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + + @override + Widget build(BuildContext context) { + return LayoutBuilder( + builder: (_,constraints){ + pm.size = constraints.biggest; + return Stack( + children: [ + GestureDetector( + onTap: (){ + initParticles(); + _controller.reset(); + _controller.repeat(); + }, + child: CustomPaint( + size: pm.size, + painter: WorldRender(manage: pm), + ), + ), + ], + ); + }, + ); + + } + + void initParticles() async { + pm.particles.clear(); + ByteData data = await rootBundle.load("assets/images/flutter.png"); + List bytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); + image.Image? imageSrc = image.decodeImage(bytes); + + if(imageSrc==null) return; + + double offsetX= (pm.size.width-imageSrc.width)/2; + double offsetY= (pm.size.height-imageSrc.height)/2; + + for (int i = 0; i < imageSrc.width; i++) { + for (int j = 0; j < imageSrc.height; j++) { + if (imageSrc.getPixel(i, j) == 0xff000000) { + Particle particle = Particle( + x: i * 1.0+ offsetX, + y: j * 1.0+ offsetY, + vx: 4 * random.nextDouble() * pow(-1, random.nextInt(20)), + vy: 4 * random.nextDouble() * pow(-1, random.nextInt(20)), + ay: 0.1, + size: 0.5, + color: Colors.blue); //产生粒子---每个粒子拥有随机的一些属性信息 + pm.particles.add(particle); + } + } + } + pm.tick(run: false); + } +} diff --git a/lib/painter_system/particle/split_img/world_render.dart b/lib/painter_system/particle/split_img/world_render.dart new file mode 100644 index 0000000..675fae8 --- /dev/null +++ b/lib/painter_system/particle/split_img/world_render.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; + +import 'particle.dart'; +import 'particle_manage.dart'; + +/// create by 张风捷特烈 on 2020/11/7 +/// contact me by email 1981462002@qq.com +/// 说明: + +class WorldRender extends CustomPainter { + + final ParticleManage manage; + + Paint fillPaint = Paint(); + + Paint stokePaint = Paint() + ..strokeWidth = 0.5 + ..style = PaintingStyle.stroke; + + WorldRender({required this.manage}) : super(repaint: manage); + + @override + void paint(Canvas canvas, Size size) { + manage.particles.forEach((particle) { + drawParticle(canvas, particle); + }); + } + + void drawParticle(Canvas canvas, Particle particle) { + + fillPaint.color = particle.color; + canvas.drawCircle(Offset(particle.x, particle.y), particle.size, fillPaint); + } + + @override + bool shouldRepaint(covariant WorldRender oldDelegate) => + oldDelegate.manage != manage; +} diff --git a/lib/painter_system/picture_frame.dart b/lib/painter_system/picture_frame.dart index 87743b1..c0bc0d3 100644 --- a/lib/painter_system/picture_frame.dart +++ b/lib/painter_system/picture_frame.dart @@ -105,3 +105,72 @@ class FramePainter extends CustomPainter { return false; } } + + +class FrameShower extends StatelessWidget { + final String title; + final String author; + final String srcUrl; + final String info; + final Widget content; + + FrameShower( + {Key? key, + this.title = "", + this.author = "", + this.srcUrl = "", + this.info = "", + required this.content}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return Align( + alignment: Alignment.topCenter, + child: Column( + children: [ + SizedBox( + height: 15, + ), + Text( + title, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + PictureFrame(child: content), + Container( + padding: EdgeInsets.symmetric(horizontal: 12), + child: Row( + children: [ + Text( + "作者: $author ", + style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold), + ), + Spacer(), + Text( + "源码地址 ", + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.blueAccent), + ), + ], + ), + ), + SizedBox( + height: 10, + ), + Container( + padding: EdgeInsets.symmetric(horizontal: 12), + alignment: Alignment.topLeft, + child: Text( + info, + style: TextStyle( + fontSize: 14, + color: Colors.grey, + fontWeight: FontWeight.bold), + )), + ], + ), + ); + } +} \ No newline at end of file diff --git a/lib/painter_system/utils/colors.dart b/lib/painter_system/utils/colors.dart index 1991f28..7af5f8d 100644 --- a/lib/painter_system/utils/colors.dart +++ b/lib/painter_system/utils/colors.dart @@ -1,6 +1,6 @@ import 'dart:ui'; -List colors = [ +const List colors = [ Color(0xff8e43e7), Color(0xffff4f81), Color(0xff1cc7d0), diff --git a/lib/point_system/views/issues_point/issue_item.dart b/lib/point_system/views/issues_point/issue_item.dart index 91cf51c..716dcf8 100644 --- a/lib/point_system/views/issues_point/issue_item.dart +++ b/lib/point_system/views/issues_point/issue_item.dart @@ -15,7 +15,7 @@ import 'package:flutter_unit/components/permanent/color_wrapper.dart'; class IssueItem extends StatelessWidget { final Issue issue; - IssueItem({required this.issue}); + const IssueItem({Key? key, required this.issue}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/point_system/views/issues_point/issues_detail.dart b/lib/point_system/views/issues_point/issues_detail.dart index 5e2cce2..565bce7 100644 --- a/lib/point_system/views/issues_point/issues_detail.dart +++ b/lib/point_system/views/issues_point/issues_detail.dart @@ -15,6 +15,8 @@ import 'package:flutter_unit/components/permanent/panel.dart'; /// 说明: class IssuesDetailPage extends StatelessWidget { + const IssuesDetailPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/point_system/views/issues_point/issues_point_page.dart b/lib/point_system/views/issues_point/issues_point_page.dart index f45c04a..1bb0458 100644 --- a/lib/point_system/views/issues_point/issues_point_page.dart +++ b/lib/point_system/views/issues_point/issues_point_page.dart @@ -18,13 +18,17 @@ import 'repo_widget.dart'; /// 说明: class IssuesPointPage extends StatelessWidget { + const IssuesPointPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Scaffold(body: IssuesPointContent()); + return const Scaffold(body: IssuesPointContent()); } } class IssuesPointContent extends StatefulWidget { + const IssuesPointContent({Key? key}) : super(key: key); + @override _IssuesPointContentState createState() => _IssuesPointContentState(); } diff --git a/lib/point_system/views/issues_point/repo_widget.dart b/lib/point_system/views/issues_point/repo_widget.dart index ac95536..0ba46e4 100644 --- a/lib/point_system/views/issues_point/repo_widget.dart +++ b/lib/point_system/views/issues_point/repo_widget.dart @@ -13,7 +13,7 @@ import 'package:flutter_unit/components/permanent/color_wrapper.dart'; class RepoWidget extends StatelessWidget { final Repository repository; - RepoWidget({required this.repository}); + const RepoWidget({Key? key, required this.repository}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/user_system/component/authentic_widget.dart b/lib/user_system/component/authentic_widget.dart index 055ca96..01b571e 100644 --- a/lib/user_system/component/authentic_widget.dart +++ b/lib/user_system/component/authentic_widget.dart @@ -11,7 +11,9 @@ class AuthenticWidget extends StatelessWidget { final Widget authentic; final Widget noAuthentic; - const AuthenticWidget({required this.authentic, required this.noAuthentic}); + const AuthenticWidget( + {Key? key, required this.authentic, required this.noAuthentic}) + : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/user_system/pages/login/login_form.dart b/lib/user_system/pages/login/login_form.dart index aaa0930..93ce521 100644 --- a/lib/user_system/pages/login/login_form.dart +++ b/lib/user_system/pages/login/login_form.dart @@ -10,6 +10,8 @@ import 'package:flutter_unit/user_system/bloc/login/state.dart'; import 'package:flutter_unit/components/permanent/feedback_widget.dart'; class LoginFrom extends StatefulWidget { + const LoginFrom({Key? key}) : super(key: key); + @override _LoginFromState createState() => _LoginFromState(); } diff --git a/lib/user_system/pages/login/login_page.dart b/lib/user_system/pages/login/login_page.dart index 19b25f3..22d0a54 100644 --- a/lib/user_system/pages/login/login_page.dart +++ b/lib/user_system/pages/login/login_page.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_unit/user_system/pages/register/arc_clipper.dart'; + import 'login_form.dart'; /// create by 张风捷特烈 on 2020/4/24 @@ -7,6 +8,8 @@ import 'login_form.dart'; /// 说明: class LoginPage extends StatelessWidget { + const LoginPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { Size winSize = MediaQuery.of(context).size; @@ -14,24 +17,24 @@ class LoginPage extends StatelessWidget { return Scaffold( body: SingleChildScrollView( child: Wrap(children: [ - Stack(children:[ + Stack(children: [ UnitArcBackground(height: winSize.height * 0.32), Positioned( - top: 20, - child: BackButton(color: Colors.white)), - ]), - Container( - // color: Colors.green, - height: winSize.height * 0.68, - width: MediaQuery.of(context).size.width, - padding: const EdgeInsets.only(left: 20.0, right: 20, top: 20), - child: Stack( - alignment: Alignment.center, - children: [ - LoginFrom(), - ], - )) - ]), - )); + top: 20, + child: BackButton(color: Colors.white)), + ]), + Container( + // color: Colors.green, + height: winSize.height * 0.68, + width: MediaQuery.of(context).size.width, + padding: const EdgeInsets.only(left: 20.0, right: 20, top: 20), + child: Stack( + alignment: Alignment.center, + children: [ + LoginFrom(), + ], + )) + ]), + )); } } diff --git a/lib/user_system/pages/register/arc_clipper.dart b/lib/user_system/pages/register/arc_clipper.dart index b8b9354..393964d 100644 --- a/lib/user_system/pages/register/arc_clipper.dart +++ b/lib/user_system/pages/register/arc_clipper.dart @@ -30,7 +30,8 @@ class ArcBackground extends StatelessWidget { final Widget? child; final ImageProvider image; - ArcBackground({this.child,required this.image}); + const ArcBackground({Key? key, this.child, required this.image}) + : super(key: key); @override Widget build(BuildContext context) { @@ -52,7 +53,7 @@ class ArcBackground extends StatelessWidget { class UnitArcBackground extends StatelessWidget { final double height; - UnitArcBackground({Key? key,required this.height}) : super(key: key); + const UnitArcBackground({Key? key,required this.height}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/user_system/pages/register/register_page.dart b/lib/user_system/pages/register/register_page.dart index 71781ce..056d38f 100644 --- a/lib/user_system/pages/register/register_page.dart +++ b/lib/user_system/pages/register/register_page.dart @@ -20,6 +20,8 @@ import 'send_code.dart'; /// 说明: class RegisterPage extends StatefulWidget { + const RegisterPage({Key? key}) : super(key: key); + @override _RegisterPageState createState() => _RegisterPageState(); } diff --git a/lib/user_system/pages/user/page_item.dart b/lib/user_system/pages/user/page_item.dart index 5b7859a..ee30ff2 100644 --- a/lib/user_system/pages/user/page_item.dart +++ b/lib/user_system/pages/user/page_item.dart @@ -11,7 +11,7 @@ import 'package:flutter_unit/update_part/views/update_red_point.dart'; class MePageItem extends StatelessWidget { final Color color; - MePageItem({this.color = Colors.white}); + const MePageItem({this.color = Colors.white}); @override Widget build(BuildContext context) { diff --git a/lib/user_system/pages/user/unit_drawer_header.dart b/lib/user_system/pages/user/unit_drawer_header.dart index d4733b0..552c5d7 100644 --- a/lib/user_system/pages/user/unit_drawer_header.dart +++ b/lib/user_system/pages/user/unit_drawer_header.dart @@ -8,7 +8,7 @@ class UnitDrawerHeader extends StatelessWidget { final Color color; - UnitDrawerHeader({required this.color}); + const UnitDrawerHeader({Key? key, required this.color}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/widget_system/repositories/bean/category_po.dart b/lib/widget_system/repositories/bean/category_po.dart index 0602228..1d36154 100644 --- a/lib/widget_system/repositories/bean/category_po.dart +++ b/lib/widget_system/repositories/bean/category_po.dart @@ -5,7 +5,7 @@ import 'package:equatable/equatable.dart'; /// 说明: 收藏夹数据库-数据模型 // """ -// CREATE TABLE IF NOT EXISTS widget_category( +// CREATE TABLE IF NOT EXISTS category( // id INTEGER PRIMARY KEY AUTOINCREMENT, // name VARCHAR(64) NOT NULL, // color VARCHAR(9) DEFAULT '#FF2196F3', diff --git a/lib/widget_system/repositories/dao/category_dao.dart b/lib/widget_system/repositories/dao/category_dao.dart index c349b29..07a997b 100644 --- a/lib/widget_system/repositories/dao/category_dao.dart +++ b/lib/widget_system/repositories/dao/category_dao.dart @@ -6,7 +6,7 @@ import '../bean/category_po.dart'; //""" -// CREATE TABLE IF NOT EXISTS widget_category( +// CREATE TABLE IF NOT EXISTS category_widget( // id INTEGER PRIMARY KEY AUTOINCREMENT, // name VARCHAR(64) NOT NULL, // color VARCHAR(9) DEFAULT '#FF2196F3', @@ -131,7 +131,7 @@ class CategoryDao { "WHERE categoryId = ?", [id]); return await db.execute( - "DELETE FROM widget_category " + "DELETE FROM category " "WHERE id = ?", [id]); } diff --git a/lib/widget_system/views/search_view/app_search_bar.dart b/lib/widget_system/views/search_view/app_search_bar.dart index 31dca86..93120a2 100644 --- a/lib/widget_system/views/search_view/app_search_bar.dart +++ b/lib/widget_system/views/search_view/app_search_bar.dart @@ -37,7 +37,6 @@ class _AppSearchBarState extends State { ), onChanged: (str) => BlocProvider.of(context) .add(SearchWidgetEvent(args:SearchArgs(name: str,stars: [1,2,3,4,5]))), - onSubmitted: (str) {//提交后 FocusScope.of(context).requestFocus(FocusNode()); //收起键盘 }, diff --git a/lib/widget_system/views/widget_home_view/home_drawer.dart b/lib/widget_system/views/widget_home_view/home_drawer.dart index 0cc0c63..33a6744 100644 --- a/lib/widget_system/views/widget_home_view/home_drawer.dart +++ b/lib/widget_system/views/widget_home_view/home_drawer.dart @@ -56,9 +56,9 @@ class HomeDrawer extends StatelessWidget { ), title: const Text('Flutter 集录'), children: [ - _buildItem(context, TolyIcon.icon_tag, '属性集录', UnitRouter.attr), - _buildItem(context, Icons.palette, '绘画集录', UnitRouter.galley), - _buildItem(context, Icons.widgets, '布局集录', UnitRouter.layout), + _buildItem(context, TolyIcon.icon_tag, '属性集录', ''), + _buildItem(context, Icons.palette, '绘画集录', ''), + _buildItem(context, Icons.widgets, '布局集录', ''), _buildItem(context, TolyIcon.icon_bug, '要点集录', UnitRouter.issues_point,onTap: (){ BlocProvider.of(context).add(EventLoadPoint()); }), diff --git a/lib/widget_system/widgets/StatefulWidget/AlignTransition/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/AlignTransition/node1_base.dart index 0ed3413..6a692e5 100644 --- a/lib/widget_system/widgets/StatefulWidget/AlignTransition/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/AlignTransition/node1_base.dart @@ -12,6 +12,8 @@ import 'package:flutter/material.dart'; // "【alignment】 : 对齐动画 【Animation】", // } class CustomAlignTransition extends StatefulWidget { + const CustomAlignTransition({Key? key}) : super(key: key); + @override _CustomAlignTransitionState createState() => _CustomAlignTransitionState(); } @@ -22,7 +24,10 @@ class _CustomAlignTransitionState extends State @override void initState() { - _ctrl = AnimationController(vsync: this, duration: Duration(seconds: 1)); + _ctrl = AnimationController( + vsync: this, + duration: const Duration(seconds: 1), + ); _ctrl.forward(); super.initState(); } @@ -43,10 +48,14 @@ class _CustomAlignTransitionState extends State height: 100, child: AlignTransition( alignment: AlignmentTween( - begin: Alignment.topLeft, end: Alignment.bottomRight) - .animate(_ctrl), - child: Container( - child: Icon(Icons.android, color: Colors.green, size: 60)), + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ).animate(_ctrl), + child: const Icon( + Icons.android, + color: Colors.green, + size: 60, + ), ), )); } diff --git a/lib/widget_system/widgets/StatefulWidget/AnimatedAlign/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/AnimatedAlign/node1_base.dart index 8f41a38..689c052 100644 --- a/lib/widget_system/widgets/StatefulWidget/AnimatedAlign/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/AnimatedAlign/node1_base.dart @@ -16,12 +16,14 @@ import 'package:flutter/material.dart'; // "【padding】 : 内边距 【EdgeInsetsGeometry】", // } class CustomAnimatedAlign extends StatefulWidget { + const CustomAnimatedAlign({Key? key}) : super(key: key); + @override _CustomAnimatedAlignState createState() => _CustomAnimatedAlignState(); } class _CustomAnimatedAlignState extends State { - final Alignment start = Alignment(0, 0); + final Alignment start = const Alignment(0, 0); final Alignment end = Alignment.bottomRight; late Alignment _alignment; @@ -42,7 +44,7 @@ class _CustomAnimatedAlignState extends State { width: 200, height: 100, child: AnimatedAlign( - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), curve: Curves.fastOutSlowIn, alignment: _alignment, onEnd: () => print('End'), @@ -51,7 +53,7 @@ class _CustomAnimatedAlignState extends State { width: 80, alignment: Alignment.center, color: Colors.blue, - child: Text( + child: const Text( '张风捷特烈', style: TextStyle(color: Colors.white), ), diff --git a/lib/widget_system/widgets/StatefulWidget/AnimatedBuilder/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/AnimatedBuilder/node1_base.dart index 91c387f..2f61693 100644 --- a/lib/widget_system/widgets/StatefulWidget/AnimatedBuilder/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/AnimatedBuilder/node1_base.dart @@ -18,6 +18,8 @@ import 'package:flutter/material.dart'; // } class AnimatedBuilderDemo extends StatefulWidget { + const AnimatedBuilderDemo({Key? key}) : super(key: key); + @override _AnimatedBuilderDemoState createState() => _AnimatedBuilderDemoState(); } @@ -56,11 +58,14 @@ class _AnimatedBuilderDemoState extends State } Widget buildChild() => Container( - height: 100, + height: 100, width: 100, - decoration: BoxDecoration(color: Colors.orange, shape: BoxShape.circle), + decoration: const BoxDecoration( + color: Colors.orange, + shape: BoxShape.circle, + ), alignment: Alignment.center, - child: Text( + child: const Text( 'Toly', style: TextStyle(fontSize: 40, color: Colors.white), ), diff --git a/lib/widget_system/widgets/StatefulWidget/AnimatedContainer/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/AnimatedContainer/node1_base.dart index db0ab5f..9cdb6e7 100644 --- a/lib/widget_system/widgets/StatefulWidget/AnimatedContainer/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/AnimatedContainer/node1_base.dart @@ -23,6 +23,8 @@ import 'package:flutter/material.dart'; // "【padding】 : 内边距 【EdgeInsetsGeometry】", // } class CustomAnimatedContainer extends StatefulWidget { + const CustomAnimatedContainer({Key? key}) : super(key: key); + @override _CustomAnimatedContainerState createState() => _CustomAnimatedContainerState(); diff --git a/lib/widget_system/widgets/StatefulWidget/AnimatedCrossFade/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/AnimatedCrossFade/node1_base.dart index cc72e64..766d12f 100644 --- a/lib/widget_system/widgets/StatefulWidget/AnimatedCrossFade/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/AnimatedCrossFade/node1_base.dart @@ -16,13 +16,15 @@ import 'package:flutter/material.dart'; // "【duration】 : 时长 【Duration】", // } class CustomAnimatedCrossFade extends StatefulWidget { + const CustomAnimatedCrossFade({Key? key}) : super(key: key); + @override _CustomAnimatedCrossFadeState createState() => _CustomAnimatedCrossFadeState(); } class _CustomAnimatedCrossFadeState extends State { - var _crossFadeState = CrossFadeState.showFirst; + CrossFadeState _crossFadeState = CrossFadeState.showFirst; bool get isFirst => _crossFadeState == CrossFadeState.showFirst; @@ -30,30 +32,27 @@ class _CustomAnimatedCrossFadeState extends State { Widget build(BuildContext context) { return Wrap( children: [ - Container( - child: AnimatedCrossFade( - firstChild: Container( - alignment: Alignment.center, - width: 200, - height: 150, - color: Colors.orange, - child: FlutterLogo(textColor: Colors.blue, size: 100,), - ), - secondChild: Container( - width: 200, - height: 150, - alignment: Alignment.center, - color: Colors.blue, - child: FlutterLogo( - textColor: Colors.white, -// colors: Colors.orange, - size: 100, - style: FlutterLogoStyle.stacked,), - ), - duration: Duration(milliseconds: 600), - - crossFadeState: _crossFadeState, + AnimatedCrossFade( + firstChild: Container( + alignment: Alignment.center, + width: 200, + height: 150, + color: Colors.orange, + child: const FlutterLogo(textColor: Colors.blue, size: 100,), ), + secondChild: Container( + width: 200, + height: 150, + alignment: Alignment.center, + color: Colors.blue, + child: const FlutterLogo( + textColor: Colors.white, +// colors: Colors.orange, + size: 100, + style: FlutterLogoStyle.stacked,), + ), + duration: const Duration(milliseconds: 600), + crossFadeState: _crossFadeState, ), _buildSwitch(), ], diff --git a/lib/widget_system/widgets/StatefulWidget/AnimatedCrossFade/node2_curve.dart b/lib/widget_system/widgets/StatefulWidget/AnimatedCrossFade/node2_curve.dart index e4ac90f..eab9061 100644 --- a/lib/widget_system/widgets/StatefulWidget/AnimatedCrossFade/node2_curve.dart +++ b/lib/widget_system/widgets/StatefulWidget/AnimatedCrossFade/node2_curve.dart @@ -14,6 +14,8 @@ import 'package:flutter/material.dart'; // "【sizeCurve】 : 尺寸变化曲线 【CrossFadeState】", // } class CurveAnimatedCrossFade extends StatefulWidget { + const CurveAnimatedCrossFade({Key? key}) : super(key: key); + @override _CurveAnimatedCrossFadeState createState() => _CurveAnimatedCrossFadeState(); } @@ -27,31 +29,29 @@ class _CurveAnimatedCrossFadeState extends State { Widget build(BuildContext context) { return Wrap( children: [ - Container( - child: AnimatedCrossFade( - firstCurve: Curves.easeInCirc, - secondCurve: Curves.easeInToLinear, - sizeCurve: Curves.bounceOut, - firstChild: Container( - alignment: Alignment.center, - width: 200, - height: 80, - color: Colors.orange , - child: FlutterLogo(textColor: Colors.blue,size: 50,), - ), - secondChild: Container( - width: 200, - height: 150, - alignment: Alignment.center, - color: Colors.blue, - child: FlutterLogo( - textColor: Colors.white, -// colors: Colors.orange, - size: 100,style: FlutterLogoStyle.stacked,), - ), - duration: Duration(milliseconds: 1000), - crossFadeState: _crossFadeState, + AnimatedCrossFade( + firstCurve: Curves.easeInCirc, + secondCurve: Curves.easeInToLinear, + sizeCurve: Curves.bounceOut, + firstChild: Container( + alignment: Alignment.center, + width: 200, + height: 80, + color: Colors.orange , + child: const FlutterLogo(textColor: Colors.blue,size: 50,), ), + secondChild: Container( + width: 200, + height: 150, + alignment: Alignment.center, + color: Colors.blue, + child: const FlutterLogo( + textColor: Colors.white, +// colors: Colors.orange, + size: 100,style: FlutterLogoStyle.stacked,), + ), + duration: const Duration(milliseconds: 1000), + crossFadeState: _crossFadeState, ), _buildSwitch(), ], diff --git a/lib/widget_system/widgets/StatefulWidget/AnimatedDefaultTextStyle/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/AnimatedDefaultTextStyle/node1_base.dart index e65ad07..71ccd18 100644 --- a/lib/widget_system/widgets/StatefulWidget/AnimatedDefaultTextStyle/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/AnimatedDefaultTextStyle/node1_base.dart @@ -19,6 +19,8 @@ import 'package:flutter/material.dart'; // "【style】 : 文字样式 【TextStyle】", // } class CustomAnimatedDefaultTextStyle extends StatefulWidget { + const CustomAnimatedDefaultTextStyle({Key? key}) : super(key: key); + @override _CustomAnimatedDefaultTextStyleState createState() => _CustomAnimatedDefaultTextStyleState(); @@ -26,12 +28,18 @@ class CustomAnimatedDefaultTextStyle extends StatefulWidget { class _CustomAnimatedDefaultTextStyleState extends State { - final TextStyle start = TextStyle(color: Colors.blue, fontSize: 50, shadows: [ - Shadow(offset: Offset(1, 1), color: Colors.black, blurRadius: 3) - ]); - final TextStyle end = TextStyle(color: Colors.white, fontSize: 20, shadows: [ - Shadow(offset: Offset(1, 1), color: Colors.purple, blurRadius: 3) - ]); + final TextStyle start = const TextStyle( + color: Colors.blue, + fontSize: 50, + shadows: [ + Shadow(offset: Offset(1, 1), color: Colors.black, blurRadius: 3) + ]); + final TextStyle end = const TextStyle( + color: Colors.white, + fontSize: 20, + shadows: [ + Shadow(offset: Offset(1, 1), color: Colors.purple, blurRadius: 3) + ]); late TextStyle _style; @@ -56,11 +64,11 @@ class _CustomAnimatedDefaultTextStyleState softWrap: true, maxLines: 1, overflow: TextOverflow.ellipsis, - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), curve: Curves.fastOutSlowIn, style: _style, onEnd: () => print('End'), - child: Text( + child: const Text( '张风捷特烈', style: TextStyle(color: Colors.white), ), diff --git a/lib/widget_system/widgets/StatefulWidget/AnimatedList/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/AnimatedList/node1_base.dart index 928d771..def8bc9 100644 --- a/lib/widget_system/widgets/StatefulWidget/AnimatedList/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/AnimatedList/node1_base.dart @@ -17,6 +17,8 @@ import 'package:flutter/material.dart'; // "【padding】 : 内边距 【EdgeInsetsGeometry】", // } class CustomAnimatedList extends StatefulWidget { + const CustomAnimatedList({Key? key}) : super(key: key); + @override _CustomAnimatedListState createState() => _CustomAnimatedListState(); } @@ -32,7 +34,7 @@ class _CustomAnimatedListState extends State { super.initState(); _list = ListModel( listKey: _listKey, - initialItems: [0, 1, 2, 3], + initialItems: [0, 1, 2, 3], removedItemBuilder: _buildRemovedItem, ); _nextItem = 4; @@ -84,11 +86,11 @@ class _CustomAnimatedListState extends State { child: Column( children: [ _buildBtn(), - Container( + SizedBox( width: MediaQuery.of(context).size.width/2, height: 300, child: AnimatedList( - padding: EdgeInsets.all(10.0), + padding: const EdgeInsets.all(10.0), key: _listKey, initialItemCount: _list.length, itemBuilder: _buildItem, @@ -159,9 +161,7 @@ class CardItem extends StatelessWidget { this.onTap, required this.item, this.selected: false}) - : assert(animation != null), - assert(item != null && item >= 0), - assert(selected != null), + : assert(item >= 0), super(key: key); final Animation animation; final VoidCallback? onTap; @@ -180,7 +180,7 @@ class CardItem extends StatelessWidget { dense: true, title: Text( 'Item $item', - style: TextStyle(color: Colors.white, fontSize: 18), + style: const TextStyle(color: Colors.white, fontSize: 18), ), value: selected, onChanged: (v) { diff --git a/lib/widget_system/widgets/StatefulWidget/AnimatedModalBarrier/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/AnimatedModalBarrier/node1_base.dart index daf4666..99289c4 100644 --- a/lib/widget_system/widgets/StatefulWidget/AnimatedModalBarrier/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/AnimatedModalBarrier/node1_base.dart @@ -14,8 +14,11 @@ import 'package:flutter/material.dart'; // "【color】 : 颜色 【Animation】", // } class AnimatedModalBarrierDemo extends StatefulWidget { + const AnimatedModalBarrierDemo({Key? key}) : super(key: key); + @override - _AnimatedModalBarrierDemoState createState() => _AnimatedModalBarrierDemoState(); + _AnimatedModalBarrierDemoState createState() => + _AnimatedModalBarrierDemoState(); } class _AnimatedModalBarrierDemoState extends State @@ -26,9 +29,14 @@ class _AnimatedModalBarrierDemoState extends State @override void initState() { super.initState(); - _controller = - AnimationController(vsync: this, duration: Duration(seconds: 2))..forward(); - _color = ColorTween(begin: Colors.blue, end: Colors.purple).animate(_controller); + _controller = AnimationController( + vsync: this, + duration: const Duration(seconds: 2), + )..forward(); + _color = ColorTween( + begin: Colors.blue, + end: Colors.purple, + ).animate(_controller); } @override @@ -39,7 +47,7 @@ class _AnimatedModalBarrierDemoState extends State @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: 200, height: 100, child: Stack(alignment: Alignment.center, children: [ @@ -47,7 +55,10 @@ class _AnimatedModalBarrierDemoState extends State dismissible: true, color: _color, ), - Text('点击背景返回',style: TextStyle(color: Colors.white),) + const Text( + '点击背景返回', + style: TextStyle(color: Colors.white), + ) ]), ); } diff --git a/lib/widget_system/widgets/StatefulWidget/AnimatedOpacity/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/AnimatedOpacity/node1_base.dart index 04510c9..f22efe9 100644 --- a/lib/widget_system/widgets/StatefulWidget/AnimatedOpacity/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/AnimatedOpacity/node1_base.dart @@ -15,6 +15,8 @@ import 'package:flutter/material.dart'; // "【opacity】 : 透明度 【double】", // } class CustomAnimatedOpacity extends StatefulWidget { + const CustomAnimatedOpacity({Key? key}) : super(key: key); + @override _CustomAnimatedOpacityState createState() => _CustomAnimatedOpacityState(); } @@ -38,11 +40,11 @@ class _CustomAnimatedOpacityState extends State { width: 200, height: 100, child: AnimatedOpacity( - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), curve: Curves.fastOutSlowIn, opacity: _opacity, onEnd: () => print('End'), - child: Icon(Icons.android, color: Colors.green, size: 60), + child: const Icon(Icons.android, color: Colors.green, size: 60), ), ), ], diff --git a/lib/widget_system/widgets/StatefulWidget/AnimatedPadding/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/AnimatedPadding/node1_base.dart index 20dce39..0fb58e3 100644 --- a/lib/widget_system/widgets/StatefulWidget/AnimatedPadding/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/AnimatedPadding/node1_base.dart @@ -15,13 +15,15 @@ import 'package:flutter/material.dart'; // "【padding】 : 内边距 【EdgeInsetsGeometry】", // } class CustomAnimatedPadding extends StatefulWidget { + const CustomAnimatedPadding({Key? key}) : super(key: key); + @override _CustomAnimatedPaddingState createState() => _CustomAnimatedPaddingState(); } class _CustomAnimatedPaddingState extends State { - final EdgeInsets startPadding = EdgeInsets.all(10); - final EdgeInsets endPadding = EdgeInsets.all(30); + final EdgeInsets startPadding = const EdgeInsets.all(10); + final EdgeInsets endPadding = const EdgeInsets.all(30); late EdgeInsets _padding; @@ -47,14 +49,14 @@ class _CustomAnimatedPaddingState extends State { width: 200, height: 100, child: AnimatedPadding( - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), curve: Curves.fastOutSlowIn, padding: _padding, onEnd: () => print('End'), child: Container( alignment: Alignment.center, color: Colors.blue, - child: Text( + child: const Text( '张风捷特烈', style: TextStyle(color: Colors.white), ), diff --git a/lib/widget_system/widgets/StatefulWidget/AnimatedPhysicalModel/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/AnimatedPhysicalModel/node1_base.dart index 1c17adf..f9e6712 100644 --- a/lib/widget_system/widgets/StatefulWidget/AnimatedPhysicalModel/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/AnimatedPhysicalModel/node1_base.dart @@ -19,6 +19,8 @@ import 'package:flutter/material.dart'; // "【child】 : 子组件 【Widget】", // } class AnimatedPhysicalModelDemo extends StatefulWidget { + const AnimatedPhysicalModelDemo({Key? key}) : super(key: key); + @override _AnimatedPhysicalModelDemoState createState() => _AnimatedPhysicalModelDemoState(); @@ -30,13 +32,13 @@ class _AnimatedPhysicalModelDemoState extends State { @override Widget build(BuildContext context) { return Column( - children: [ + children: [ _buildSwitch(), - Container( + SizedBox( width: 150, height: 150, child: AnimatedPhysicalModel( - duration: Duration(seconds: 2), + duration: const Duration(seconds: 2), curve: Curves.fastOutSlowIn, shadowColor: flag?Colors.orange:Colors.purple, elevation: flag?10:5, @@ -48,22 +50,18 @@ class _AnimatedPhysicalModelDemoState extends State { clipBehavior: Clip.hardEdge, shape: BoxShape.rectangle, color: Colors.deepPurpleAccent, - onEnd: () { - print('----onEnd---'); - }, + onEnd: () => print('----onEnd---'), ), ), ], ); } - Widget _buildSwitch() { - return Switch( + Widget _buildSwitch() => Switch( value: flag, onChanged: (v) { setState(() { flag = v; }); }); - } } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatefulWidget/AnimatedPositioned/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/AnimatedPositioned/node1_base.dart index b10146c..3e1f434 100644 --- a/lib/widget_system/widgets/StatefulWidget/AnimatedPositioned/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/AnimatedPositioned/node1_base.dart @@ -18,16 +18,18 @@ import 'package:flutter/material.dart'; // "【bottom】 : 到父底距离 【double】", // } class CustomAnimatedPositioned extends StatefulWidget { + const CustomAnimatedPositioned({Key? key}) : super(key: key); + @override _CustomAnimatedPositionedState createState() => _CustomAnimatedPositionedState(); } class _CustomAnimatedPositionedState extends State { - final startTop = 0.0; - final endTop = 30.0; + final double startTop = 0.0; + final double endTop = 30.0; - var _top = 0.0; + double _top = 0.0; @override void initState() { @@ -54,20 +56,20 @@ class _CustomAnimatedPositionedState extends State { List _buildChildren() => [ AnimatedPositioned( - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), top: _top, left: _top * 4, - child: Icon( + child: const Icon( Icons.android, color: Colors.green, size: 50, ), ), AnimatedPositioned( - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), top: 50 - _top, left: 150 - _top * 4, - child: Icon( + child: const Icon( Icons.android, color: Colors.red, size: 50, diff --git a/lib/widget_system/widgets/StatefulWidget/AnimatedPositionedDirectional/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/AnimatedPositionedDirectional/node1_base.dart index 2622b28..9b9f320 100644 --- a/lib/widget_system/widgets/StatefulWidget/AnimatedPositionedDirectional/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/AnimatedPositionedDirectional/node1_base.dart @@ -18,6 +18,8 @@ import 'package:flutter/material.dart'; // "【bottom】 : 到父底距离 【double】", // } class CustomAnimatedPositionedDirectional extends StatefulWidget { + const CustomAnimatedPositionedDirectional({Key? key}) : super(key: key); + @override _CustomAnimatedPositionedDirectionalState createState() => _CustomAnimatedPositionedDirectionalState(); @@ -25,10 +27,10 @@ class CustomAnimatedPositionedDirectional extends StatefulWidget { class _CustomAnimatedPositionedDirectionalState extends State { - final startTop = 0.0; - final endTop = 30.0; + final double startTop = 0.0; + final double endTop = 30.0; - var _top = 0.0; + double _top = 0.0; @override void initState() { @@ -55,20 +57,20 @@ class _CustomAnimatedPositionedDirectionalState List _buildChildren() => [ AnimatedPositionedDirectional( - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), top: _top, start: _top * 4, - child: Icon( + child: const Icon( Icons.android, color: Colors.green, size: 50, ), ), AnimatedPositionedDirectional( - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), top: 50 - _top, start: 150 - _top * 4, - child: Icon( + child: const Icon( Icons.android, color: Colors.red, size: 50, diff --git a/lib/widget_system/widgets/StatefulWidget/AnimatedSwitcher/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/AnimatedSwitcher/node1_base.dart index e954841..966043e 100644 --- a/lib/widget_system/widgets/StatefulWidget/AnimatedSwitcher/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/AnimatedSwitcher/node1_base.dart @@ -18,6 +18,8 @@ import 'package:flutter/material.dart'; // } class CustomAnimatedSwitcher extends StatefulWidget { + const CustomAnimatedSwitcher({Key? key}) : super(key: key); + @override _CustomAnimatedSwitcherState createState() => _CustomAnimatedSwitcherState(); } @@ -27,15 +29,13 @@ class _CustomAnimatedSwitcherState extends State { @override Widget build(BuildContext context) { - return Container( - child: Wrap( - crossAxisAlignment: WrapCrossAlignment.center, - children: [ - _buildMinusBtn(), - SizedBox(width:80,child: _buildAnimatedSwitcher(context)), - _buildAddBtn() - ], - ), + return Wrap( + crossAxisAlignment: WrapCrossAlignment.center, + children: [ + _buildMinusBtn(), + SizedBox(width:80,child: _buildAnimatedSwitcher(context)), + _buildAddBtn() + ], ); } @@ -55,34 +55,34 @@ class _CustomAnimatedSwitcherState extends State { Widget _buildMinusBtn() { return MaterialButton( - padding: EdgeInsets.all(0), - textColor: Color(0xffFfffff), + padding: const EdgeInsets.all(0), + textColor: const Color(0xffFfffff), elevation: 3, color: Colors.red, - highlightColor: Color(0xffF88B0A), + highlightColor: const Color(0xffF88B0A), splashColor: Colors.red, - child: Icon( + child: const Icon( Icons.remove, color: Colors.white, ), - shape: CircleBorder( + shape: const CircleBorder( side: BorderSide(width: 2.0, color: Color(0xFFFFDFDFDF)), ), onPressed: () => setState(() => _count -= 1)); } Widget _buildAddBtn() => MaterialButton( - padding: EdgeInsets.all(0), - textColor: Color(0xffFfffff), + padding: const EdgeInsets.all(0), + textColor: const Color(0xffFfffff), elevation: 3, color: Colors.blue, - highlightColor: Color(0xffF88B0A), + highlightColor: const Color(0xffF88B0A), splashColor: Colors.red, - child: Icon( + child: const Icon( Icons.add, color: Colors.white, ), - shape: CircleBorder( + shape: const CircleBorder( side: BorderSide(width: 2.0, color: Color(0xFFFFDFDFDF)), ), onPressed: () => setState(() => _count += 1)); diff --git a/lib/widget_system/widgets/StatefulWidget/AnimatedTheme/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/AnimatedTheme/node1_base.dart index a176fc6..29cc248 100644 --- a/lib/widget_system/widgets/StatefulWidget/AnimatedTheme/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/AnimatedTheme/node1_base.dart @@ -15,6 +15,8 @@ import 'package:flutter/material.dart'; // "【child】 : 子组件 【Widget】", // } class AnimatedThemeDemo extends StatefulWidget { + const AnimatedThemeDemo({Key? key}) : super(key: key); + @override _AnimatedThemeDemoState createState() => _AnimatedThemeDemoState(); } @@ -22,18 +24,22 @@ class AnimatedThemeDemo extends StatefulWidget { class _AnimatedThemeDemoState extends State { ThemeData startThem = ThemeData( primaryColor: Colors.blue, - textTheme: TextTheme( + textTheme: const TextTheme( headline1: TextStyle( - color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold), + color: Colors.white, + fontSize: 24, + fontWeight: FontWeight.bold, + ), )); ThemeData endThem = ThemeData( primaryColor: Colors.red, - textTheme: TextTheme( + textTheme: const TextTheme( headline1: TextStyle( - color: Colors.black, - fontSize: 16, - fontWeight: FontWeight.normal))); + color: Colors.black, + fontSize: 16, + fontWeight: FontWeight.normal, + ))); late ThemeData them; @@ -50,7 +56,7 @@ class _AnimatedThemeDemoState extends State { _buildSwitch(), AnimatedTheme( data: them, - duration: Duration(seconds: 2), + duration: const Duration(seconds: 2), curve: Curves.fastOutSlowIn, onEnd: () { print('----onEnd---'); @@ -74,6 +80,8 @@ class _AnimatedThemeDemoState extends State { } class ChildContent extends StatelessWidget { + const ChildContent({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Container( @@ -81,10 +89,10 @@ class ChildContent extends StatelessWidget { height: 60, alignment: Alignment.center, decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(5)), + borderRadius: const BorderRadius.all(const Radius.circular(5)), color: Theme.of(context).primaryColor, ), - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), child: Text( 'Flutter Unit', style: Theme.of(context).textTheme.headline1, diff --git a/lib/widget_system/widgets/StatefulWidget/AppBar/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/AppBar/node1_base.dart index 0d2228a..08ba7f8 100755 --- a/lib/widget_system/widgets/StatefulWidget/AppBar/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/AppBar/node1_base.dart @@ -20,15 +20,17 @@ import '../PopupMenuButton/node1_base.dart'; // } class CustomAppBar extends StatelessWidget { + const CustomAppBar({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return AppBar( - title: Text('风雅六社'), - leading: BackButton(), + title: const Text('风雅六社'), + leading: const BackButton(), backgroundColor: Colors.amber[500], elevation: 2, centerTitle: true, - shape: RoundedRectangleBorder( + shape: const RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(20), bottomRight: Radius.circular(20), @@ -37,7 +39,7 @@ class CustomAppBar extends StatelessWidget { )), actions: [ IconButton( - icon: Icon(Icons.star), + icon: const Icon(Icons.star), tooltip: 'liked_widget_bloc', onPressed: () { // do nothing diff --git a/lib/widget_system/widgets/StatefulWidget/AppBar/node2_tab.dart b/lib/widget_system/widgets/StatefulWidget/AppBar/node2_tab.dart index dbbfa81..eaafb6b 100755 --- a/lib/widget_system/widgets/StatefulWidget/AppBar/node2_tab.dart +++ b/lib/widget_system/widgets/StatefulWidget/AppBar/node2_tab.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; + import '../PopupMenuButton/node1_base.dart'; /// create by 张风捷特烈 on 2020-03-23 /// contact me by email 1981462002@qq.com @@ -11,13 +12,15 @@ import '../PopupMenuButton/node1_base.dart'; // "【bottom】 : 底部组件 【PreferredSizeWidget】", // } class TabAppBar extends StatefulWidget { + const TabAppBar({Key? key}) : super(key: key); + @override _TabAppBarState createState() => _TabAppBarState(); } class _TabAppBarState extends State with SingleTickerProviderStateMixin { - final tabs = ['风画庭', '雨韵舍', '雷鸣殿', '电疾堂', '霜寒阁', '雪月楼']; + final List tabs = ['风画庭', '雨韵舍', '雷鸣殿', '电疾堂', '霜寒阁', '雪月楼']; late TabController _tabController; @override @@ -38,7 +41,7 @@ class _TabAppBarState extends State children: [ Container( height: 180, - decoration: BoxDecoration( + decoration: const BoxDecoration( image: DecorationImage( image: AssetImage( "assets/images/sabar.webp", @@ -47,25 +50,27 @@ class _TabAppBarState extends State child: _buildAppBar(), ), Container( - height: 150, color: Color(0xff916BF0), child: _buildTableBarView()) + height: 150, + color: const Color(0xff916BF0), + child: _buildTableBarView()) ], ); } Widget _buildAppBar() => AppBar( - title: Text('风雅六社'), + title: const Text('风雅六社'), elevation: 1, - leading: BackButton(), + leading: const BackButton(), backgroundColor: Colors.amber[500]!.withAlpha(33), centerTitle: true, - shape: RoundedRectangleBorder( + shape: const RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20), )), actions: [ IconButton( - icon: Icon(Icons.star), + icon: const Icon(Icons.star), tooltip: 'liked_widget_bloc', onPressed: () { // do nothing @@ -85,8 +90,8 @@ class _TabAppBarState extends State children: tabs .map((e) => Center( child: Text( - e, - style: TextStyle(color: Colors.white, fontSize: 20), + e, + style: const TextStyle(color: Colors.white, fontSize: 20), ))) .toList()); } diff --git a/lib/widget_system/widgets/StatefulWidget/AutomaticKeepAlive/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/AutomaticKeepAlive/node1_base.dart index 594aed6..2af44f5 100644 --- a/lib/widget_system/widgets/StatefulWidget/AutomaticKeepAlive/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/AutomaticKeepAlive/node1_base.dart @@ -15,6 +15,7 @@ import 'package:flutter/material.dart'; // } class AutomaticKeepAliveDemo extends StatelessWidget { + AutomaticKeepAliveDemo({Key? key}) : super(key: key); final List data = [ Colors.purple[50]!, @@ -41,7 +42,7 @@ class AutomaticKeepAliveDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 300, child: ListView.builder( itemCount: data.length, @@ -58,7 +59,8 @@ class ColorBox extends StatefulWidget { final Color color; final int index; - ColorBox({Key? key,required this.color,required this.index}) : super(key: key); + const ColorBox({Key? key, required this.color, required this.index}) + : super(key: key); @override _ColorBoxState createState() => _ColorBoxState(); @@ -83,26 +85,31 @@ class _ColorBoxState extends State with AutomaticKeepAliveClientMixin @override Widget build(BuildContext context) { super.build(context); - return Container( alignment: Alignment.center, height: 50, color: widget.color, child: Row( children: [ - SizedBox(width: 60,), + const SizedBox( + width: 60, + ), Checkbox( value: _checked, onChanged: (bool? v) { setState(() { - _checked = v??false; + _checked = v ?? false; }); }, ), Text( "index ${widget.index}: ${colorString(widget.color)}", - style: TextStyle(color: Colors.white, shadows: [ - Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) + style: const TextStyle(color: Colors.white, shadows: [ + Shadow( + color: Colors.black, + offset: Offset(.5, .5), + blurRadius: 2, + ) ]), ), ], diff --git a/lib/widget_system/widgets/StatefulWidget/BottomAppBar/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/BottomAppBar/node1_base.dart index 1cfcb9f..c9aebbe 100755 --- a/lib/widget_system/widgets/StatefulWidget/BottomAppBar/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/BottomAppBar/node1_base.dart @@ -16,31 +16,34 @@ import 'package:flutter/material.dart'; // "【child】 : 孩子 【Widget】", // } class CustomBottomAppBar extends StatefulWidget { + const CustomBottomAppBar({Key? key}) : super(key: key); + @override _CustomBottomAppBarState createState() => _CustomBottomAppBarState(); } class _CustomBottomAppBarState extends State { - var _position = 0; - var _location = FloatingActionButtonLocation.centerDocked; - final iconsMap = { + int _position = 0; + FloatingActionButtonLocation _location = + FloatingActionButtonLocation.centerDocked; + final Map iconsMap = { "图鉴": Icons.home, "动态": Icons.toys, "喜欢": Icons.favorite, "手册": Icons.class_, }; - var activeColor = Colors.blue.withAlpha(240); + Color activeColor = Colors.blue.withAlpha(240); @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: MediaQuery.of(context).size.width, height: 180, child: Scaffold( backgroundColor: Colors.purple.withAlpha(22), floatingActionButton: FloatingActionButton( onPressed: () => Navigator.of(context).pushNamed('AboutMePage'), - child: Icon(Icons.add), + child: const Icon(Icons.add), ), bottomNavigationBar: _buildBottomAppBar(), floatingActionButtonLocation: _location, @@ -52,13 +55,13 @@ class _CustomBottomAppBarState extends State { Widget _buildBottomAppBar() { return BottomAppBar( elevation: 1, - shape: CircularNotchedRectangle(), + shape: const CircularNotchedRectangle(), notchMargin: 5, color: Colors.red, child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: info.asMap().keys.map((i) => _buildChild(i)).toList() - ..insertAll(isCenter ? 2 : 4, [SizedBox(width: 30)])), + ..insertAll(isCenter ? 2 : 4, [const SizedBox(width: 30)])), ); } @@ -70,7 +73,7 @@ class _CustomBottomAppBarState extends State { children: [ Text( '当前页索引:$_position', - style: TextStyle(color: Colors.blue, fontSize: 18), + style: const TextStyle(color: Colors.blue, fontSize: 18), ), Switch( value: isCenter, @@ -91,7 +94,7 @@ class _CustomBottomAppBarState extends State { bool get isCenter => _location == FloatingActionButtonLocation.centerDocked; Widget _buildChild(int i) { - var active = i == _position; + bool active = i == _position; return Padding( padding: const EdgeInsets.all(8.0), child: GestureDetector( diff --git a/lib/widget_system/widgets/StatefulWidget/BottomNavigationBar/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/BottomNavigationBar/node1_base.dart index 5b4138f..4d70621 100755 --- a/lib/widget_system/widgets/StatefulWidget/BottomNavigationBar/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/BottomNavigationBar/node1_base.dart @@ -21,21 +21,22 @@ import 'package:flutter/material.dart'; // "【onTap】 : 点击事件 【Function(int)】", // } class CustomBottomNavigationBar extends StatefulWidget { + const CustomBottomNavigationBar({Key? key}) : super(key: key); + @override _CustomBottomNavigationBarState createState() => _CustomBottomNavigationBarState(); } class _CustomBottomNavigationBarState extends State { - var _position = 0; + int _position = 0; BottomNavigationBarType _type = BottomNavigationBarType.shifting; - final iconsMap = { - //底栏图标 + final Map iconsMap = { //底栏图标 "图鉴": Icons.home, "动态": Icons.toys, "喜欢": Icons.favorite, "手册": Icons.class_, "我的": Icons.account_circle, }; - final _colors = [ + final List _colors = [ Colors.red, Colors.yellow, Colors.blue, @@ -65,7 +66,7 @@ class _CustomBottomNavigationBarState extends State { fixedColor: isShifting ? Colors.white : _colors[_position], backgroundColor: Colors.white, iconSize: 25, - selectedLabelStyle: TextStyle(fontWeight: FontWeight.bold), + selectedLabelStyle: const TextStyle(fontWeight: FontWeight.bold), showUnselectedLabels: false, showSelectedLabels: true, items: iconsMap.keys @@ -83,7 +84,7 @@ class _CustomBottomNavigationBarState extends State { children: [ Text( _type.toString(), - style: TextStyle(fontWeight: FontWeight.bold, color: Colors.blue), + style: const TextStyle(fontWeight: FontWeight.bold, color: Colors.blue), ), Switch( value: _type == BottomNavigationBarType.shifting, diff --git a/lib/widget_system/widgets/StatefulWidget/BottomNavigationBar/node2_page.dart b/lib/widget_system/widgets/StatefulWidget/BottomNavigationBar/node2_page.dart index dbe6fc7..c1b4e46 100755 --- a/lib/widget_system/widgets/StatefulWidget/BottomNavigationBar/node2_page.dart +++ b/lib/widget_system/widgets/StatefulWidget/BottomNavigationBar/node2_page.dart @@ -10,6 +10,8 @@ import 'package:flutter/material.dart'; // "在onTap时进行使用控制器进行切页", // } class BottomNavigationBarWithPageView extends StatefulWidget { + const BottomNavigationBarWithPageView({Key? key}) : super(key: key); + @override _BottomNavigationBarWithPageViewState createState() => _BottomNavigationBarWithPageViewState(); @@ -17,14 +19,14 @@ class BottomNavigationBarWithPageView extends StatefulWidget { class _BottomNavigationBarWithPageViewState extends State { - var _position = 0; - final iconsMap = { + int _position = 0; + final Map iconsMap = { //底栏图标 "图鉴": Icons.home, "动态": Icons.toys, "喜欢": Icons.favorite, "手册": Icons.class_, "我的": Icons.account_circle, }; - final _colors = [ + final List _colors = [ Colors.red, Colors.yellow, Colors.blue, @@ -49,28 +51,29 @@ class _BottomNavigationBarWithPageViewState @override Widget build(BuildContext context) { - return Container( - child: Column( - children: [ - Container( - color: Colors.orange.withAlpha(88), - width: MediaQuery.of(context).size.width, - height: 150, - child: PageView( - controller: _controller, - children: iconsMap.keys - .map((e) => Center( - child: Text( - e, - style: TextStyle(color: Colors.white, fontSize: 20), + return Column( + children: [ + Container( + color: Colors.orange.withAlpha(88), + width: MediaQuery.of(context).size.width, + height: 150, + child: PageView( + controller: _controller, + children: iconsMap.keys + .map((e) => Center( + child: Text( + e, + style: const TextStyle( + color: Colors.white, + fontSize: 20, ), - )) - .toList(), - ), + ), + )) + .toList(), ), - _buildBottomNavigationBar() - ], - ), + ), + _buildBottomNavigationBar() + ], ); } @@ -85,7 +88,7 @@ class _BottomNavigationBarWithPageViewState type: BottomNavigationBarType.shifting, fixedColor: Colors.white, iconSize: 25, - selectedLabelStyle: TextStyle(fontWeight: FontWeight.bold), + selectedLabelStyle: const TextStyle(fontWeight: FontWeight.bold), showUnselectedLabels: false, showSelectedLabels: true, items: iconsMap.keys diff --git a/lib/widget_system/widgets/StatefulWidget/Checkbox/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/Checkbox/node1_base.dart index 40342d0..9ef6fab 100644 --- a/lib/widget_system/widgets/StatefulWidget/Checkbox/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/Checkbox/node1_base.dart @@ -15,21 +15,27 @@ import 'package:flutter/material.dart'; // } class CustomCheckbox extends StatefulWidget { + const CustomCheckbox({Key? key}) : super(key: key); + @override _CustomCheckboxState createState() => _CustomCheckboxState(); } class _CustomCheckboxState extends State { bool _checked = false; - final colors = [Colors.red, Colors.yellow, Colors.blue, Colors.green]; + final List colors = [ + Colors.red, + Colors.yellow, + Colors.blue, + Colors.green + ]; @override Widget build(BuildContext context) { return Wrap( spacing: 10, children: colors - .map((e) => - Checkbox( + .map((e) => Checkbox( value: _checked, checkColor: Colors.white, activeColor: e, diff --git a/lib/widget_system/widgets/StatefulWidget/Checkbox/node2_tristate.dart b/lib/widget_system/widgets/StatefulWidget/Checkbox/node2_tristate.dart index f32ab27..5ed1547 100644 --- a/lib/widget_system/widgets/StatefulWidget/Checkbox/node2_tristate.dart +++ b/lib/widget_system/widgets/StatefulWidget/Checkbox/node2_tristate.dart @@ -15,6 +15,8 @@ import 'package:flutter/material.dart'; // " onChanged时,回调true、null、false三种状态" // } class TristateCheckBok extends StatefulWidget { + const TristateCheckBok({Key? key}) : super(key: key); + @override _TristateCheckBokState createState() => _TristateCheckBokState(); } diff --git a/lib/widget_system/widgets/StatefulWidget/CircularProgressIndicator/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CircularProgressIndicator/node1_base.dart index 7068f72..302ffe7 100644 --- a/lib/widget_system/widgets/StatefulWidget/CircularProgressIndicator/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CircularProgressIndicator/node1_base.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; // "【strokeWidth】 : 线宽 【double】", // } class CustomCircularProgressIndicator extends StatefulWidget { + const CustomCircularProgressIndicator({Key? key}) : super(key: key); + @override _CustomCircularProgressIndicatorState createState() => _CustomCircularProgressIndicatorState(); @@ -28,13 +30,13 @@ class _CustomCircularProgressIndicatorState return Wrap( spacing: 10, - children:data.map((e)=>Container( + children:data.map((e)=>SizedBox( width: 50, height: 50, child: CircularProgressIndicator( value: e, backgroundColor: Colors.grey.withAlpha(33), - valueColor: AlwaysStoppedAnimation(Colors.orange), + valueColor: const AlwaysStoppedAnimation(Colors.orange), strokeWidth: 5, ), )).toList(), diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoActivityIndicator/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoActivityIndicator/node1_base.dart index 5a2d48f..022fb9e 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoActivityIndicator/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoActivityIndicator/node1_base.dart @@ -12,13 +12,15 @@ import 'package:flutter/material.dart'; // "【radius】 : 半径 【double】", // } class CustomCupertinoActivityIndicator extends StatelessWidget { + const CustomCupertinoActivityIndicator({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Wrap( spacing: 20, - children: [ + children: const [ CupertinoActivityIndicator( animating: true, radius: 25, diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoApp/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoApp/node1_base.dart index 7b6aa51..f9e140f 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoApp/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoApp/node1_base.dart @@ -15,12 +15,14 @@ import 'package:flutter/cupertino.dart'; // "【home】 : 主页 【Widget】", // } class CustomCupertinoApp extends StatelessWidget { + const CustomCupertinoApp({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height - 200, - child: CupertinoApp( + child: const CupertinoApp( title: 'Flutter Demo', theme: CupertinoThemeData( primaryColor: CupertinoColors.white, diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoButton/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoButton/node1_base.dart index 7f2e07d..0958538 100755 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoButton/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoButton/node1_base.dart @@ -17,6 +17,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class CustomCupertinoButton extends StatelessWidget { + CustomCupertinoButton({Key? key}) : super(key: key); final Map data = { CupertinoColors.activeBlue:4.0, @@ -24,9 +25,9 @@ class CustomCupertinoButton extends StatelessWidget { CupertinoColors.activeOrange:8.0, }; + @override Widget build(BuildContext context) { - return Wrap( spacing: 20, children:data.keys.map((e)=> CupertinoButton( @@ -35,7 +36,7 @@ class CustomCupertinoButton extends StatelessWidget { color: e, pressedOpacity: 0.4, borderRadius: BorderRadius.all(Radius.circular(data[e]!)), - child: Text("iOS"), + child: const Text("iOS"), )).toList() ); } diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoContextMenu/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoContextMenu/node1_base.dart index 0c9f7a4..b22a4c2 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoContextMenu/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoContextMenu/node1_base.dart @@ -15,34 +15,37 @@ import 'package:flutter/material.dart'; // "【previewBuilder】 : 动画构造器 【ContextMenuPreviewBuilder】", // } class CustomCupertinoContextMenu extends StatelessWidget { + const CustomCupertinoContextMenu({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( - child: _buildCupertinoContextMenu(context), + return SizedBox( + width: 100, + height: 100, + child: DecoratedBox( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/images/sabar_bar.webp'), + fit: BoxFit.cover), + borderRadius: BorderRadius.all(Radius.circular(50))), + child: _buildCupertinoContextMenu(context)), ); } - final info= ['保存图片','立刻呼叫','添加到收藏夹']; + final List info = const ['保存图片', '立刻呼叫', '添加到收藏夹']; - Widget _buildCupertinoContextMenu(context) => Container( - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage('assets/images/sabar_bar.webp'), - fit: BoxFit.cover), - borderRadius: BorderRadius.all(Radius.circular(50))), - width: 100, - height: 100, - child: CupertinoContextMenu( - child: Container( - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage('assets/images/sabar_bar.webp'), - fit: BoxFit.cover), - borderRadius: BorderRadius.all(Radius.circular(50))), - ), - actions: info.map((e)=>CupertinoContextMenuAction( - child: Center(child: Text(e)), - onPressed: () => Navigator.pop(context), - )).toList()) - ); + Widget _buildCupertinoContextMenu(context) => CupertinoContextMenu( + child: Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/images/sabar_bar.webp'), + fit: BoxFit.cover), + borderRadius: BorderRadius.all(Radius.circular(50))), + ), + actions: info + .map((e) => CupertinoContextMenuAction( + child: Center(child: Text(e)), + onPressed: () => Navigator.pop(context), + )) + .toList()); } diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoContextMenuAction/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoContextMenuAction/node1_base.dart index e6770c5..f815a28 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoContextMenuAction/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoContextMenuAction/node1_base.dart @@ -15,27 +15,29 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class CustomCupertinoContextMenuAction extends StatelessWidget { + const CustomCupertinoContextMenuAction({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Column( children: [ Container( width: 200, - margin: EdgeInsets.all(5), + margin: const EdgeInsets.all(5), child: CupertinoContextMenuAction( trailingIcon: CupertinoIcons.settings, isDefaultAction: true, onPressed: () => Navigator.of(context).pushNamed('AboutMePage'), - child: Text('张风捷特烈')), + child: const Text('张风捷特烈')), ), Container( width: 200, - margin: EdgeInsets.all(5), + margin: const EdgeInsets.all(5), child: CupertinoContextMenuAction( trailingIcon: CupertinoIcons.home, isDefaultAction: false, onPressed: () => Navigator.of(context).pushNamed('AboutMePage'), - child: Text('百里·巫缨')), + child: const Text('百里·巫缨')), ), ], ); diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoDatePicker/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoDatePicker/node1_base.dart index 25a87df..bcad7d5 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoDatePicker/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoDatePicker/node1_base.dart @@ -19,6 +19,8 @@ import 'package:flutter/material.dart'; // "【mode】 : 模式*3 【CupertinoDatePickerMode】", // } class CustomCupertinoDatePicker extends StatefulWidget { + const CustomCupertinoDatePicker({Key? key}) : super(key: key); + @override _CustomCupertinoDatePickerState createState() => _CustomCupertinoDatePickerState(); @@ -33,7 +35,7 @@ class _CustomCupertinoDatePickerState extends State { children: [ Text( '当前日期:${_date.toIso8601String()}', - style: TextStyle(color: Colors.grey, fontSize: 16), + style: const TextStyle(color: Colors.grey, fontSize: 16), ), _buildInfoTitle('CupertinoDatePickerMode.dateAndTime'), buildPicker(CupertinoDatePickerMode.dateAndTime), @@ -47,7 +49,7 @@ class _CustomCupertinoDatePickerState extends State { Container buildPicker(CupertinoDatePickerMode mode) { return Container( - margin: EdgeInsets.all(10), + margin: const EdgeInsets.all(10), height: 150, child: CupertinoDatePicker( mode: mode, @@ -72,7 +74,7 @@ class _CustomCupertinoDatePickerState extends State { padding: const EdgeInsets.only(left: 20,top: 20,bottom: 5), child: Text( info, - style: TextStyle(color: Colors.blue, fontSize: 16,fontWeight: FontWeight.bold), + style: const TextStyle(color: Colors.blue, fontSize: 16,fontWeight: FontWeight.bold), ), ); } diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoNavigationBar/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoNavigationBar/node1_base.dart index e259daa..ee39ef3 100755 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoNavigationBar/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoNavigationBar/node1_base.dart @@ -16,22 +16,24 @@ import 'package:flutter/material.dart'; // "【border】 : 边线 【Border】", // } class CustomCupertinoNavigationBar extends StatelessWidget { + const CustomCupertinoNavigationBar({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return CupertinoNavigationBar( - leading: Icon( + leading: const Icon( CupertinoIcons.back, size: 25, color: Colors.blue, ), - middle: Text("风雪雅舍"), + middle: const Text("风雪雅舍"), trailing: Image.asset( "assets/images/icon_head.webp", width: 25.0, height: 25.0, ), - backgroundColor: Color(0xfff1f1f1), - padding: EdgeInsetsDirectional.only(start: 10,end: 20), + backgroundColor: const Color(0xfff1f1f1), + padding: const EdgeInsetsDirectional.only(start: 10,end: 20), border: Border.all(color: Colors.transparent), ); } diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoPageScaffold/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoPageScaffold/node1_base.dart index d757029..54ad2ec 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoPageScaffold/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoPageScaffold/node1_base.dart @@ -13,12 +13,14 @@ import 'package:flutter/cupertino.dart'; // "【navigationBar】 : 头部 【ObstructingPreferredSizeWidget】", // } class CustomCupertinoPageScaffold extends StatelessWidget { + const CustomCupertinoPageScaffold({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height - 300, - child: CupertinoPageScaffold( + child: const CupertinoPageScaffold( navigationBar: CupertinoNavigationBar( leading: Icon(CupertinoIcons.reply), trailing: Icon(CupertinoIcons.share), diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoPicker/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoPicker/node1_base.dart index ac70297..20bcb53 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoPicker/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoPicker/node1_base.dart @@ -18,7 +18,9 @@ import 'package:flutter/cupertino.dart'; // "【onSelectedItemChanged】 : 选中事件 【Function(int)】", // } class CustomCupertinoPicker extends StatelessWidget { - final names = [ + const CustomCupertinoPicker({Key? key}) : super(key: key); + + final List names = const[ 'Java', 'Kotlin', 'Dart', @@ -31,9 +33,10 @@ class CustomCupertinoPicker extends StatelessWidget { "Object-c" ]; + @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 150, child: CupertinoPicker( backgroundColor: CupertinoColors.systemGrey.withAlpha(33), diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoScrollbar/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoScrollbar/node1_base.dart index b2c5fd1..e5a3328 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoScrollbar/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoScrollbar/node1_base.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; // "【controller】 : 控制器 【ScrollController】", // } class CustomCupertinoScrollbar extends StatelessWidget { + CustomCupertinoScrollbar({Key? key}) : super(key: key); + final List data = [ Colors.purple[50]!, Colors.purple[100]!, @@ -26,29 +28,32 @@ class CustomCupertinoScrollbar extends StatelessWidget { Colors.purple[900]!, ]; + TextStyle get textStyle => const TextStyle(color: Colors.white, shadows: [ + Shadow( + color: Colors.black, + offset: Offset(.5, .5), + blurRadius: 2, + ) + ]); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, child: CupertinoScrollbar( child: ListView( - padding: EdgeInsets.symmetric(horizontal: 5), + padding: const EdgeInsets.symmetric(horizontal: 5), children: data .map((color) => Container( - alignment: Alignment.center, - width: 100, - height: 50, - color: color, - child: Text( - colorString(color), - style: TextStyle(color: Colors.white, shadows: [ - Shadow( - color: Colors.black, - offset: Offset(.5, .5), - blurRadius: 2) - ]), - ), - )) + alignment: Alignment.center, + width: 100, + height: 50, + color: color, + child: Text( + colorString(color), + style: textStyle, + ), + )) .toList(), ), ), diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoSegmentedControl/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoSegmentedControl/node1_base.dart index 59ef2c9..cda3f98 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoSegmentedControl/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoSegmentedControl/node1_base.dart @@ -16,6 +16,8 @@ import 'package:flutter/material.dart'; // "【padding】 : 内边距 【EdgeInsetsGeometry】", // } class CupertinoSegmentedControlDemo extends StatefulWidget { + const CupertinoSegmentedControlDemo({Key? key}) : super(key: key); + @override _CupertinoSegmentedControlDemoState createState() => _CupertinoSegmentedControlDemoState(); @@ -23,24 +25,22 @@ class CupertinoSegmentedControlDemo extends StatefulWidget { class _CupertinoSegmentedControlDemoState extends State { - var _value = 1; + int _value = 1; @override Widget build(BuildContext context) { - return Container( - child: CupertinoSegmentedControl( - groupValue: _value, - onValueChanged: _onValueChanged, - padding: EdgeInsets.only(top: 20), - children: { - 1: Padding( - padding: EdgeInsets.only(left: 20, right: 20), - child: Text("混沌战士"), - ), - 2: Text("青眼白龙"), - 3: Text("黑魔术士"), - }, - ), + return CupertinoSegmentedControl( + groupValue: _value, + onValueChanged: _onValueChanged, + padding: const EdgeInsets.only(top: 20), + children: const { + 1: Padding( + padding: EdgeInsets.only(left: 20, right: 20), + child: Text("混沌战士"), + ), + 2: Text("青眼白龙"), + 3: Text("黑魔术士"), + }, ); } diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoSegmentedControl/node2_color.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoSegmentedControl/node2_color.dart index cf71d0a..db59add 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoSegmentedControl/node2_color.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoSegmentedControl/node2_color.dart @@ -16,6 +16,8 @@ import 'package:flutter/material.dart'; // "【borderColor】 : 边线色 【Color】", // } class CupertinoSegmentedControlColor extends StatefulWidget { + const CupertinoSegmentedControlColor({Key? key}) : super(key: key); + @override _CupertinoSegmentedControlColorState createState() => _CupertinoSegmentedControlColorState(); @@ -23,28 +25,26 @@ class CupertinoSegmentedControlColor extends StatefulWidget { class _CupertinoSegmentedControlColorState extends State { - var _value = 1; + int _value = 1; @override Widget build(BuildContext context) { - return Container( - child: CupertinoSegmentedControl( - unselectedColor: Colors.yellow, - selectedColor: Colors.green, - pressedColor: Colors.blue, - borderColor: Colors.red, - groupValue: _value, - onValueChanged: _onValueChanged, - padding: EdgeInsets.only(top: 20), - children: { - 1: Padding( - padding: EdgeInsets.only(left: 20, right: 20), - child: Text("混沌战士"), - ), - 2: Text("青眼白龙"), - 3: Text("黑魔术士"), - }, - ), + return CupertinoSegmentedControl( + unselectedColor: Colors.yellow, + selectedColor: Colors.green, + pressedColor: Colors.blue, + borderColor: Colors.red, + groupValue: _value, + onValueChanged: _onValueChanged, + padding: const EdgeInsets.only(top: 20), + children: const { + 1: Padding( + padding: EdgeInsets.only(left: 20, right: 20), + child: Text("混沌战士"), + ), + 2: Text("青眼白龙"), + 3: Text("黑魔术士"), + }, ); } diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoSlider/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoSlider/node1_base.dart index 2d6f0f6..fc08892 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoSlider/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoSlider/node1_base.dart @@ -19,6 +19,8 @@ import 'package:flutter/material.dart'; // "【onChanged】 : 改变时回调 【Function(double)】", // } class CustomCupertinoSlider extends StatefulWidget { + const CustomCupertinoSlider({Key? key}) : super(key: key); + @override _CustomCupertinoSliderState createState() => _CustomCupertinoSliderState(); } @@ -30,7 +32,6 @@ class _CustomCupertinoSliderState extends State { Widget build(BuildContext context) { return Column( mainAxisSize: MainAxisSize.min, - children: [ Text('当前值:${_value.toStringAsFixed(1)}'), CupertinoSlider( @@ -40,12 +41,8 @@ class _CustomCupertinoSliderState extends State { max: 360.0, activeColor: Colors.green, thumbColor: Colors.white, - onChangeStart: (value) { - print('开始滑动:$value'); - }, - onChangeEnd: (value) { - print('滑动结束:$value'); - }, + onChangeStart: (value) => print('开始滑动:$value'), + onChangeEnd: (value) => print('滑动结束:$value'), onChanged: (value) { setState(() { _value = value; diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoSlidingSegmentedControl/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoSlidingSegmentedControl/node1_base.dart index 410ce82..ca98d29 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoSlidingSegmentedControl/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoSlidingSegmentedControl/node1_base.dart @@ -17,6 +17,8 @@ import 'package:flutter/material.dart'; // "【padding】 : 内边距 【EdgeInsetsGeometry】", // } class CupertinoSlidingSegmentedControlDemo extends StatefulWidget { + const CupertinoSlidingSegmentedControlDemo({Key? key}) : super(key: key); + @override _CupertinoSlidingSegmentedControlDemoState createState() => _CupertinoSlidingSegmentedControlDemoState(); @@ -24,26 +26,24 @@ class CupertinoSlidingSegmentedControlDemo extends StatefulWidget { class _CupertinoSlidingSegmentedControlDemoState extends State { - var _value = 1; + int _value = 1; @override Widget build(BuildContext context) { - return Container( - child: CupertinoSlidingSegmentedControl( - groupValue: _value, - onValueChanged: _onValueChanged, - thumbColor: Colors.amberAccent, - backgroundColor: Colors.green.withAlpha(99), - padding: EdgeInsets.all(5), - children: { - 1: Padding( - padding: EdgeInsets.only(left: 20, right: 20), - child: Text("混沌战士"), - ), - 2: Text("青眼白龙"), - 3: Text("黑魔导"), - }, - ), + return CupertinoSlidingSegmentedControl( + groupValue: _value, + onValueChanged: _onValueChanged, + thumbColor: Colors.amberAccent, + backgroundColor: Colors.green.withAlpha(99), + padding: const EdgeInsets.all(5), + children: const { + 1: Padding( + padding: EdgeInsets.only(left: 20, right: 20), + child: Text("混沌战士"), + ), + 2: Text("青眼白龙"), + 3: Text("黑魔导"), + }, ); } diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoSwitch/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoSwitch/node1_base.dart index ec5d4d9..2a72e9c 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoSwitch/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoSwitch/node1_base.dart @@ -13,12 +13,19 @@ import 'package:flutter/material.dart'; // "【onChanged】 : 切换回调 【Function(double)】", // } class CustomCupertinoSwitch extends StatefulWidget { + const CustomCupertinoSwitch({Key? key}) : super(key: key); + @override _CustomCupertinoSwitchState createState() => _CustomCupertinoSwitchState(); } class _CustomCupertinoSwitchState extends State { - final colors = [Colors.red, Colors.yellow, Colors.blue, Colors.green]; + final List colors = [ + Colors.red, + Colors.yellow, + Colors.blue, + Colors.green + ]; bool _checked = false; @@ -28,12 +35,11 @@ class _CustomCupertinoSwitchState extends State { spacing: 10, children: colors .map((e) => CupertinoSwitch( - value: _checked, - activeColor: e, + value: _checked, + activeColor: e, onChanged: (v) { setState(() => _checked = v); - })) - .toList(), + })).toList(), ); } } diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoTabBar/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoTabBar/node1_base.dart index 36b5aba..218c5c7 100755 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoTabBar/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoTabBar/node1_base.dart @@ -18,13 +18,15 @@ import 'package:flutter/material.dart'; // "【onTap】 : 点击事件 【Function(int)】", // } class CustomCupertinoTabBar extends StatefulWidget { + const CustomCupertinoTabBar({Key? key}) : super(key: key); + @override _CustomCupertinoTabBarState createState() => _CustomCupertinoTabBarState(); } class _CustomCupertinoTabBarState extends State { - var _position = 0; - final iconsMap = { + int _position = 0; + final Map iconsMap = { //底栏图标 "图鉴": Icons.home, "动态": Icons.toys, "喜欢": Icons.favorite, "手册": Icons.class_, @@ -54,8 +56,8 @@ class _CustomCupertinoTabBarState extends State { )) .toList(), activeColor: Colors.blue, - inactiveColor: Color(0xff333333), - backgroundColor: Color(0xfff1f1f1), + inactiveColor: const Color(0xff333333), + backgroundColor: const Color(0xfff1f1f1), iconSize: 25.0, ); } @@ -65,10 +67,10 @@ class _CustomCupertinoTabBarState extends State { alignment: Alignment.center, width: MediaQuery.of(context).size.width, height: 150, - color: Color(0xffE7F3FC), + color: const Color(0xffE7F3FC), child: Text( iconsMap.keys.toList()[_position], - style: TextStyle(color: Colors.blue, fontSize: 24), + style: const TextStyle(color: Colors.blue, fontSize: 24), ), ); } diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoTabScaffold/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoTabScaffold/node1_base.dart index 7619a16..715b0fd 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoTabScaffold/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoTabScaffold/node1_base.dart @@ -16,6 +16,8 @@ import 'package:flutter/material.dart'; // "【tabBuilder】 : 页面构造器 【IndexedWidgetBuilder】", // } class CustomCupertinoTabScaffold extends StatefulWidget { + const CustomCupertinoTabScaffold({Key? key}) : super(key: key); + @override _CustomCupertinoTabScaffoldState createState() => _CustomCupertinoTabScaffoldState(); @@ -23,8 +25,8 @@ class CustomCupertinoTabScaffold extends StatefulWidget { class _CustomCupertinoTabScaffoldState extends State { - var _position = 0; - final iconsMap = { + int _position = 0; + final Map iconsMap = { //底栏图标 "图鉴": Icons.home, "动态": Icons.toys, "喜欢": Icons.favorite, "手册": Icons.class_, @@ -33,7 +35,7 @@ class _CustomCupertinoTabScaffoldState @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height - 300, child: CupertinoTabScaffold( @@ -55,8 +57,8 @@ class _CustomCupertinoTabScaffoldState )) .toList(), activeColor: Colors.blue, - inactiveColor: Color(0xff333333), - backgroundColor: Color(0xfff1f1f1), + inactiveColor: const Color(0xff333333), + backgroundColor: const Color(0xfff1f1f1), iconSize: 25.0, ); diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoTabView/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoTabView/node1_base.dart index bb2e7d0..796c413 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoTabView/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoTabView/node1_base.dart @@ -16,10 +16,12 @@ import 'package:flutter/material.dart'; // } class CupertinoTabViewDemo extends StatelessWidget { + const CupertinoTabViewDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Container( - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), child: ElevatedButton( onPressed: () { Navigator.push( @@ -28,7 +30,7 @@ class CupertinoTabViewDemo extends StatelessWidget { builder: (context) => CupertinoTabViewPage()), ); }, - child: Text("进入 CupertinoTabView 测试页"), + child: const Text("进入 CupertinoTabView 测试页"), ), ); } @@ -36,10 +38,12 @@ class CupertinoTabViewDemo extends StatelessWidget { class CupertinoTabViewPage extends StatelessWidget { + const CupertinoTabViewPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 300, child: CupertinoTabView( routes: { @@ -52,10 +56,12 @@ class CupertinoTabViewPage extends StatelessWidget { } class DetailPage extends StatelessWidget { + const DetailPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( + navigationBar: const CupertinoNavigationBar( middle: Text('我是详情页'), ), child: Center( @@ -78,28 +84,28 @@ class _HomePage extends StatelessWidget { @override Widget build(BuildContext context) { return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( + navigationBar: const CupertinoNavigationBar( middle: Text('我是主页'), ), child: Center(child: Column( children: [ - Spacer(), + const Spacer(), Material(child: Padding( padding: const EdgeInsets.only(left:18.0,right: 18,bottom: 20), child: Text(info), )), CupertinoButton( - padding: EdgeInsets.only(left: 10,right: 10), + padding: const EdgeInsets.only(left: 10,right: 10), color: Colors.blue, onPressed: () { Navigator.pushNamed( context, "/test_detail" ); }, - child: Text("进入详情页"), + child: const Text("进入详情页"), ), - Spacer(), + const Spacer(), ], )), ); diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoTextField/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoTextField/node1_base.dart index c84de5f..2b8eba3 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoTextField/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoTextField/node1_base.dart @@ -18,32 +18,32 @@ import 'package:flutter/material.dart'; // "【onSubmitted】: 提交监听 【ValueChanged】", // } class CupertinoTextFieldDemo extends StatefulWidget { + const CupertinoTextFieldDemo({Key? key}) : super(key: key); + @override _CupertinoTextFieldDemoState createState() => _CupertinoTextFieldDemoState(); } class _CupertinoTextFieldDemoState extends State { - var _value = ''; - var _color =Colors.black; + String _value = ''; + Color _color =Colors.black; @override Widget build(BuildContext context) { - return Container( - child: Column( - children: [ - Text('输入了:$_value',style: TextStyle(color: _color),), - CupertinoTextField( - placeholder: 'Input Name', - showCursor: true, - minLines: 1, - maxLines: 4, - padding: EdgeInsets.all(8), - onChanged: _onChanged, - onTap: _onTap, - onSubmitted: _onSubmitted, - ), - ], - ), + return Column( + children: [ + Text('输入了:$_value',style: TextStyle(color: _color),), + CupertinoTextField( + placeholder: 'Input Name', + showCursor: true, + minLines: 1, + maxLines: 4, + padding: const EdgeInsets.all(8), + onChanged: _onChanged, + onTap: _onTap, + onSubmitted: _onSubmitted, + ), + ], ); } diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoTextField/node2_style.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoTextField/node2_style.dart index 5e88485..4d30c68 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoTextField/node2_style.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoTextField/node2_style.dart @@ -19,23 +19,22 @@ import 'package:flutter/material.dart'; // "【readOnly】: 是否只读 【bool】", // } class CupertinoTextFieldStyle extends StatelessWidget { + const CupertinoTextFieldStyle({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( - child: - CupertinoTextField( - style: TextStyle(color: Colors.blue), - prefix: Icon(CupertinoIcons.add), - prefixMode: OverlayVisibilityMode.notEditing, - suffix: Icon(CupertinoIcons.clear), - suffixMode: OverlayVisibilityMode.editing, - cursorColor: Colors.purple, - cursorWidth: 4, - cursorRadius: Radius.circular(2), - readOnly: false, - placeholder: '输入用户名', - ) + return const CupertinoTextField( + style: TextStyle(color: Colors.blue), + prefix: Icon(CupertinoIcons.add), + prefixMode: OverlayVisibilityMode.notEditing, + suffix: Icon(CupertinoIcons.clear), + suffixMode: OverlayVisibilityMode.editing, + cursorColor: Colors.purple, + cursorWidth: 4, + cursorRadius: Radius.circular(2), + readOnly: false, + placeholder: '输入用户名', ); } } diff --git a/lib/widget_system/widgets/StatefulWidget/CupertinoTimerPicker/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/CupertinoTimerPicker/node1_base.dart index 0b6934b..c6f39da 100644 --- a/lib/widget_system/widgets/StatefulWidget/CupertinoTimerPicker/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/CupertinoTimerPicker/node1_base.dart @@ -17,6 +17,8 @@ import 'package:flutter/material.dart'; // "【mode】 : 模式*3 【CupertinoTimerPickerMode】", // } class CustomCupertinoTimerPicker extends StatefulWidget { + const CustomCupertinoTimerPicker({Key? key}) : super(key: key); + @override _CustomCupertinoTimerPickerState createState() => _CustomCupertinoTimerPickerState(); @@ -24,7 +26,7 @@ class CustomCupertinoTimerPicker extends StatefulWidget { class _CustomCupertinoTimerPickerState extends State { - Duration _date = Duration(seconds: 30); + Duration _date = const Duration(seconds: 30); @override Widget build(BuildContext context) { @@ -32,7 +34,7 @@ class _CustomCupertinoTimerPickerState children: [ Text( '当前时间:${_date.toString()}', - style: TextStyle(color: Colors.grey, fontSize: 16), + style: const TextStyle(color: Colors.grey, fontSize: 16), ), _buildInfoTitle('CupertinoTimerPickerMode.hms'), buildPicker(CupertinoTimerPickerMode.hms), @@ -49,7 +51,7 @@ class _CustomCupertinoTimerPickerState padding: const EdgeInsets.only(left: 20, top: 20, bottom: 5), child: Text( info, - style: TextStyle( + style: const TextStyle( color: Colors.blue, fontSize: 16, fontWeight: FontWeight.bold), ), ); @@ -57,11 +59,11 @@ class _CustomCupertinoTimerPickerState Widget buildPicker(CupertinoTimerPickerMode mode) { return Container( - margin: EdgeInsets.all(10), + margin: const EdgeInsets.all(10), height: 150, child: CupertinoTimerPicker( mode: mode, - initialTimerDuration: Duration(seconds: 30), + initialTimerDuration: const Duration(seconds: 30), onTimerDurationChanged: (date) { print(date); setState(() => _date = date); diff --git a/lib/widget_system/widgets/StatefulWidget/DecoratedBoxTransition/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/DecoratedBoxTransition/node1_base.dart index 2087bf9..cb51dae 100644 --- a/lib/widget_system/widgets/StatefulWidget/DecoratedBoxTransition/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/DecoratedBoxTransition/node1_base.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; // "【decoration】 : 动画 【Animation】", // } class CustomDecoratedBoxTransition extends StatefulWidget { + const CustomDecoratedBoxTransition({Key? key}) : super(key: key); + @override _CustomDecoratedBoxTransitionState createState() => _CustomDecoratedBoxTransitionState(); @@ -25,7 +27,10 @@ class _CustomDecoratedBoxTransitionState @override void initState() { - _ctrl = AnimationController(vsync: this, duration: Duration(seconds: 1)); + _ctrl = AnimationController( + vsync: this, + duration: const Duration(seconds: 1), + ); _ctrl.forward(); super.initState(); } @@ -40,13 +45,13 @@ class _CustomDecoratedBoxTransitionState Widget build(BuildContext context) { return GestureDetector( onTap: () => _ctrl.forward(from: 0), - child: Container( + child: SizedBox( width: 200, height: 100, child: DecoratedBoxTransition( position: DecorationPosition.background, decoration: DecorationTween( - begin: BoxDecoration( + begin: const BoxDecoration( color: Colors.greenAccent, borderRadius: BorderRadius.all(Radius.circular(50)), boxShadow: [ @@ -56,7 +61,7 @@ class _CustomDecoratedBoxTransitionState blurRadius: 3, spreadRadius: 1) ]), - end: BoxDecoration( + end: const BoxDecoration( color: Colors.orange, borderRadius: BorderRadius.all(Radius.circular(10)), boxShadow: [ @@ -66,8 +71,7 @@ class _CustomDecoratedBoxTransitionState blurRadius: 1, spreadRadius: 0) ])).animate(_ctrl), - child: Container( - child: Icon(Icons.android, color: Colors.white, size: 60)), + child: const Icon(Icons.android, color: Colors.white, size: 60), ), )); } diff --git a/lib/widget_system/widgets/StatefulWidget/DefaultTabController/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/DefaultTabController/node1_base.dart index dc6911f..6b9571f 100644 --- a/lib/widget_system/widgets/StatefulWidget/DefaultTabController/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/DefaultTabController/node1_base.dart @@ -15,21 +15,23 @@ import 'package:flutter/material.dart'; // } class DefaultTabControllerDemo extends StatelessWidget { - final List tabs = [ + final List tabs = const [ Tab(text: '青眼白龙'), Tab(text: '黑魔术师'), Tab(text: '混沌战士'), ]; + const DefaultTabControllerDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 300, child: DefaultTabController( length: tabs.length, child: Scaffold( appBar: AppBar( - title: Text("DefaultTabController"), + title: const Text("DefaultTabController"), bottom: TabBar( tabs: tabs, ), diff --git a/lib/widget_system/widgets/StatefulWidget/DefaultTextStyleTransition/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/DefaultTextStyleTransition/node1_base.dart index 1d9260c..4e9ae8d 100644 --- a/lib/widget_system/widgets/StatefulWidget/DefaultTextStyleTransition/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/DefaultTextStyleTransition/node1_base.dart @@ -16,6 +16,8 @@ import 'package:flutter/material.dart'; // "【style】 : 动画 【Animation】", // } class CustomDefaultTextStyleTransition extends StatefulWidget { + const CustomDefaultTextStyleTransition({Key? key}) : super(key: key); + @override _CustomDefaultTextStyleTransitionState createState() => _CustomDefaultTextStyleTransitionState(); @@ -28,7 +30,10 @@ class _CustomDefaultTextStyleTransitionState @override void initState() { - _ctrl = AnimationController(vsync: this, duration: Duration(seconds: 1)); + _ctrl = AnimationController( + vsync: this, + duration: const Duration(seconds: 1), + ); _ctrl.forward(); super.initState(); } @@ -58,15 +63,25 @@ class _CustomDefaultTextStyleTransitionState maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyleTween( - begin: TextStyle(color: Colors.blue, fontSize: 50, shadows: [ - Shadow( - offset: Offset(1, 1), color: Colors.black, blurRadius: 3) - ]), - end: TextStyle(color: Colors.white, fontSize: 20, shadows: [ - Shadow( - offset: Offset(1, 1), color: Colors.purple, blurRadius: 3) - ])).animate(_ctrl), - child: Text('张风捷特烈'), + begin: const TextStyle( + color: Colors.blue, + fontSize: 50, + shadows: [ + Shadow( + offset: Offset(1, 1), + color: Colors.black, + blurRadius: 3) + ]), + end: const TextStyle( + color: Colors.white, + fontSize: 20, + shadows: [ + const Shadow( + offset: Offset(1, 1), + color: Colors.purple, + blurRadius: 3) + ])).animate(_ctrl), + child: const Text('张风捷特烈'), ), )); } diff --git a/lib/widget_system/widgets/StatefulWidget/Dismissible/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/Dismissible/node1_base.dart index 18dbce6..892421b 100644 --- a/lib/widget_system/widgets/StatefulWidget/Dismissible/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/Dismissible/node1_base.dart @@ -18,6 +18,8 @@ import 'package:flutter/material.dart'; // "【onDismissed】 : 消失回调 【DismissDirectionCallback】\n", // } class CustomDismissible extends StatefulWidget { + const CustomDismissible({Key? key}) : super(key: key); + @override _CustomDismissibleState createState() => _CustomDismissibleState(); } @@ -38,10 +40,10 @@ class _CustomDismissibleState extends State { @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, child: ListView( - padding: EdgeInsets.symmetric(horizontal: 5), + padding: const EdgeInsets.symmetric(horizontal: 5), children: data.map((color) => _buildItem(color)).toList(), ), ); @@ -51,15 +53,15 @@ class _CustomDismissibleState extends State { return Dismissible( background: Container( color: Colors.green, - alignment: Alignment(-0.9, 0), - child: Icon( + alignment: const Alignment(-0.9, 0), + child: const Icon( Icons.check, color: Colors.white, ), ), secondaryBackground: Container( - alignment: Alignment(0.9, 0), - child: Icon( + alignment: const Alignment(0.9, 0), + child: const Icon( Icons.close, color: Colors.white, ), @@ -82,8 +84,12 @@ class _CustomDismissibleState extends State { color: color, child: Text( colorString(color), - style: TextStyle(color: Colors.white, shadows: [ - Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) + style: const TextStyle(color: Colors.white, shadows: [ + Shadow( + color: Colors.black, + offset: Offset(.5, .5), + blurRadius: 2, + ) ]), ), ), diff --git a/lib/widget_system/widgets/StatefulWidget/Dismissible/node2_direction.dart b/lib/widget_system/widgets/StatefulWidget/Dismissible/node2_direction.dart index 5441f28..8339bed 100644 --- a/lib/widget_system/widgets/StatefulWidget/Dismissible/node2_direction.dart +++ b/lib/widget_system/widgets/StatefulWidget/Dismissible/node2_direction.dart @@ -15,8 +15,11 @@ import 'package:flutter/material.dart'; // "【crossAxisEndOffset】 : 偏移 【double】\n", // } class DirectionDismissible extends StatefulWidget { + const DirectionDismissible({Key? key}) : super(key: key); + @override - _CustomDirectionDismissibleState createState() => _CustomDirectionDismissibleState(); + _CustomDirectionDismissibleState createState() => + _CustomDirectionDismissibleState(); } class _CustomDirectionDismissibleState extends State { @@ -35,11 +38,11 @@ class _CustomDirectionDismissibleState extends State { @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, child: ListView( scrollDirection: Axis.horizontal, - padding: EdgeInsets.symmetric(horizontal: 5), + padding: const EdgeInsets.symmetric(horizontal: 5), children: data.map((color) => _buildItem(color)).toList(), ), ); @@ -50,16 +53,22 @@ class _CustomDirectionDismissibleState extends State { direction: DismissDirection.vertical, background: Container( color: Colors.green, - alignment: Alignment( 0,-0.9,), - child: Icon( + alignment: const Alignment( + 0, + -0.9, + ), + child: const Icon( Icons.check, color: Colors.white, ), ), crossAxisEndOffset: 0.5, secondaryBackground: Container( - alignment: Alignment( 0,0.9,), - child: Icon( + alignment: const Alignment( + 0, + 0.9, + ), + child: const Icon( Icons.close, color: Colors.white, ), @@ -83,8 +92,12 @@ class _CustomDirectionDismissibleState extends State { color: color, child: Text( colorString(color), - style: TextStyle(color: Colors.white, shadows: [ - Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) + style: const TextStyle(color: Colors.white, shadows: [ + Shadow( + color: Colors.black, + offset: Offset(.5, .5), + blurRadius: 2, + ) ]), ), ), diff --git a/lib/widget_system/widgets/StatefulWidget/DragTarget/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/DragTarget/node1_base.dart index 715f36c..41a1aa1 100644 --- a/lib/widget_system/widgets/StatefulWidget/DragTarget/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/DragTarget/node1_base.dart @@ -16,6 +16,8 @@ import 'package:flutter/material.dart'; // } class CustomDragTarget extends StatefulWidget { + const CustomDragTarget({Key? key}) : super(key: key); + @override _CustomDragTargetState createState() => _CustomDragTargetState(); } @@ -26,42 +28,37 @@ class _CustomDragTargetState extends State { @override Widget build(BuildContext context) { - return Container( - child: Column( - children: [ - Wrap( - children: _buildColors(), - spacing: 10, - ), - SizedBox(height: 20,), - _buildDragTarget() - ], - ), + return Column( + children: [ + Wrap(children: _buildColors(), spacing: 10), + const SizedBox(height: 20), + _buildDragTarget() + ], ); } - List _buildColors() { - var colors = [ - Colors.red, - Colors.yellow, - Colors.blue, - Colors.green, - Colors.orange, - Colors.purple, - Colors.cyanAccent - ]; - return colors - .map( - (e) => Draggable( - child: Container( - width: 30, - height: 30, - alignment: Alignment.center, - child: Text( - colors.indexOf(e).toString(), - style: TextStyle( - color: Colors.white, fontWeight: FontWeight.bold), - ), + final List colors = const [ + Colors.red, + Colors.yellow, + Colors.blue, + Colors.green, + Colors.orange, + Colors.purple, + Colors.cyanAccent + ]; + + List _buildColors() => colors + .map( + (e) => Draggable( + child: Container( + width: 30, + height: 30, + alignment: Alignment.center, + child: Text( + colors.indexOf(e).toString(), + style: const TextStyle( + color: Colors.white, fontWeight: FontWeight.bold), + ), decoration: BoxDecoration(color: e, shape: BoxShape.circle), ), data: e, @@ -70,9 +67,7 @@ class _CustomDragTargetState extends State { height: 25, decoration: BoxDecoration(color: e, shape: BoxShape.circle), )), - ) - .toList(); - } + ).toList(); Widget _buildDragTarget() { return DragTarget( @@ -95,7 +90,7 @@ class _CustomDragTargetState extends State { child: Center( child: Text( _info, - style: TextStyle(color: Colors.white), + style: const TextStyle(color: Colors.white), ), ))); } diff --git a/lib/widget_system/widgets/StatefulWidget/Draggable/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/Draggable/node1_base.dart index 0742f79..98da975 100644 --- a/lib/widget_system/widgets/StatefulWidget/Draggable/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/Draggable/node1_base.dart @@ -14,9 +14,11 @@ import 'package:flutter/material.dart'; // "【axis】 : 拖动的轴 【Axis】", // } class CustomDraggable extends StatelessWidget { + const CustomDraggable({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - var axis = [null, Axis.vertical, Axis.horizontal]; + List axis = [null, Axis.vertical, Axis.horizontal]; return Wrap( spacing: 30, children: axis @@ -26,16 +28,20 @@ class CustomDraggable extends StatelessWidget { width: 30, height: 30, alignment: Alignment.center, - decoration: BoxDecoration( - color: Colors.blue, shape: BoxShape.circle), + decoration: const BoxDecoration( + color: Colors.blue, + shape: BoxShape.circle, + ), ), - feedback: Container( - width: 30, + feedback: Container( + width: 30, height: 30, - decoration: BoxDecoration( - color: Colors.red, shape: BoxShape.circle), + decoration: const BoxDecoration( + color: Colors.red, + shape: BoxShape.circle, + ), ), - )) + )) .toList()); } } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatefulWidget/Draggable/node2_data.dart b/lib/widget_system/widgets/StatefulWidget/Draggable/node2_data.dart index c9400cd..907f458 100644 --- a/lib/widget_system/widgets/StatefulWidget/Draggable/node2_data.dart +++ b/lib/widget_system/widgets/StatefulWidget/Draggable/node2_data.dart @@ -17,6 +17,8 @@ import 'package:flutter/material.dart'; // } class DraggablePage extends StatefulWidget { + const DraggablePage({Key? key}) : super(key: key); + @override _DraggablePageState createState() => _DraggablePageState(); } @@ -27,47 +29,45 @@ class _DraggablePageState extends State { @override Widget build(BuildContext context) { - return Container( - child: Column( - children: [ - Wrap( - children: _buildColors(), - spacing: 10, - ), - SizedBox( - height: 20, - ), - _buildDragTarget() - ], - ), + return Column( + children: [ + Wrap( + children: _buildColors(), + spacing: 10, + ), + const SizedBox( + height: 20, + ), + _buildDragTarget() + ], ); } - List _buildColors() { - var colors = [ - Colors.red, - Colors.yellow, - Colors.blue, - Colors.green, - Colors.orange, - Colors.purple, - Colors.cyanAccent - ]; - return colors - .map( - (e) => Draggable( - onDragStarted: () => setState(() => _info = '开始拖拽'), - onDragEnd: (d) => setState(() => _info = '结束拖拽'), - onDragCompleted: () => _info = '拖拽完成', - onDraggableCanceled: (v, o) => _info = '拖拽取消', - child: Container( - width: 30, - height: 30, - alignment: Alignment.center, - child: Text( + List colors = [ + Colors.red, + Colors.yellow, + Colors.blue, + Colors.green, + Colors.orange, + Colors.purple, + Colors.cyanAccent + ]; + + List _buildColors() => colors + .map( + (e) => Draggable( + onDragStarted: () => setState(() => _info = '开始拖拽'), + onDragEnd: (d) => setState(() => _info = '结束拖拽'), + onDragCompleted: () => _info = '拖拽完成', + onDraggableCanceled: (v, o) => _info = '拖拽取消', + child: Container( + width: 30, + height: 30, + alignment: Alignment.center, + child: Text( colors.indexOf(e).toString(), - style: TextStyle( - color: Colors.white, fontWeight: FontWeight.bold), + style: const TextStyle( + color: Colors.white, fontWeight: FontWeight.bold,), ), decoration: BoxDecoration(color: e, shape: BoxShape.circle), ), @@ -79,7 +79,6 @@ class _DraggablePageState extends State { )), ) .toList(); - } Widget _buildDragTarget() { return DragTarget( @@ -101,7 +100,7 @@ class _DraggablePageState extends State { child: Center( child: Text( _info, - style: TextStyle(color: Colors.white), + style: const TextStyle(color: Colors.white), ), ))); } diff --git a/lib/widget_system/widgets/StatefulWidget/Draggable/node3_use.dart b/lib/widget_system/widgets/StatefulWidget/Draggable/node3_use.dart index 2608cf7..ef946da 100644 --- a/lib/widget_system/widgets/StatefulWidget/Draggable/node3_use.dart +++ b/lib/widget_system/widgets/StatefulWidget/Draggable/node3_use.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; // } class DeleteDraggable extends StatefulWidget { + const DeleteDraggable({Key? key}) : super(key: key); + @override _DeleteDraggableState createState() => _DeleteDraggableState(); } @@ -30,19 +32,12 @@ class _DeleteDraggableState extends State { @override Widget build(BuildContext context) { - return Container( - child: Column( - children: [ - Wrap( - children: _buildColors(), - spacing: 10, - ), - SizedBox( - height: 20, - ), - _buildDragTarget() - ], - ), + return Column( + children: [ + Wrap(children: _buildColors(), spacing: 10), + const SizedBox(height: 20), + _buildDragTarget() + ], ); } @@ -58,8 +53,8 @@ class _DeleteDraggableState extends State { width: 50.0, height: 50.0, decoration: - BoxDecoration(color: Colors.red, shape: BoxShape.circle), - child: Center( + const BoxDecoration(color: Colors.red, shape: BoxShape.circle), + child: const Center( child: Icon(Icons.delete_sweep, color: Colors.white), ))); } @@ -69,15 +64,15 @@ class _DeleteDraggableState extends State { (e) => Draggable( child: Container( width: 30, - height: 30, - alignment: Alignment.center, - child: Text( - colors.indexOf(e).toString(), - style: - TextStyle(color: Colors.white, fontWeight: FontWeight.bold), - ), - decoration: BoxDecoration(color: e, shape: BoxShape.circle), - ), + height: 30, + alignment: Alignment.center, + child: Text( + colors.indexOf(e).toString(), + style: const TextStyle( + color: Colors.white, fontWeight: FontWeight.bold), + ), + decoration: BoxDecoration(color: e, shape: BoxShape.circle), + ), data: colors.indexOf(e), feedback: Container( width: 25, diff --git a/lib/widget_system/widgets/StatefulWidget/DraggableScrollableSheet/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/DraggableScrollableSheet/node1_base.dart index de5eea3..80b07fe 100644 --- a/lib/widget_system/widgets/StatefulWidget/DraggableScrollableSheet/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/DraggableScrollableSheet/node1_base.dart @@ -17,10 +17,12 @@ import 'package:flutter/material.dart'; // } class DraggableScrollableSheetDemo extends StatelessWidget { + const DraggableScrollableSheetDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( - padding: EdgeInsets.all(10), + return Padding( + padding: const EdgeInsets.all(10), child: ElevatedButton( onPressed: () { Navigator.push( @@ -29,13 +31,15 @@ class DraggableScrollableSheetDemo extends StatelessWidget { builder: (context) => DraggableScrollableSheetPage()), ); }, - child: Text("进入 DraggableScrollableSheet 测试页"), + child: const Text("进入 DraggableScrollableSheet 测试页"), ), ); } } class DraggableScrollableSheetPage extends StatelessWidget { + DraggableScrollableSheetPage({Key? key}) : super(key: key); + final List data = [ Colors.orange[50]!, Colors.orange[100]!, @@ -63,21 +67,21 @@ class DraggableScrollableSheetPage extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text("DraggableScrollableSheet"), + title: const Text("DraggableScrollableSheet"), ), body: SizedBox.expand( child: DraggableScrollableSheet( - initialChildSize: 0.3, - minChildSize: 0.2, - maxChildSize: 0.5, - expand: true, - builder: (BuildContext context, ScrollController scrollController)=> - ListView.builder( - controller: scrollController, - itemCount: data.length, - itemBuilder: buildColorItem, - ), - )), + initialChildSize: 0.3, + minChildSize: 0.2, + maxChildSize: 0.5, + expand: true, + builder: (BuildContext context, ScrollController scrollController)=> + ListView.builder( + controller: scrollController, + itemCount: data.length, + itemBuilder: buildColorItem, + ), + )), ); } @@ -88,8 +92,12 @@ class DraggableScrollableSheetPage extends StatelessWidget { color: data[index], child: Text( colorString(data[index]), - style: TextStyle(color: Colors.white, shadows: [ - Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) + style: const TextStyle(color: Colors.white, shadows: [ + Shadow( + color: Colors.black, + offset: Offset(.5, .5), + blurRadius: 2, + ) ]), ), ); diff --git a/lib/widget_system/widgets/StatefulWidget/DrawerController/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/DrawerController/node1_base.dart index 06653af..fea8d3e 100644 --- a/lib/widget_system/widgets/StatefulWidget/DrawerController/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/DrawerController/node1_base.dart @@ -18,6 +18,8 @@ import 'package:flutter/material.dart'; // } class DrawerControllerDemo extends StatefulWidget { + const DrawerControllerDemo({Key? key}) : super(key: key); + @override _DrawerControllerDemoState createState() => _DrawerControllerDemoState(); } @@ -30,37 +32,35 @@ class _DrawerControllerDemoState extends State { @override Widget build(BuildContext context) { - return Container( - child: Column( - children: [ - ElevatedButton( - onPressed: toggleDrawer, - child: Text("显隐 Drawer"), - ), - Container( - height: 200, - child: DrawerController( - scrimColor: Colors.blue.withAlpha(88), - enableOpenDragGesture: true, - key: _drawerKey, - alignment: DrawerAlignment.start, - drawerCallback: (value) { - _open = value; - }, - child: Drawer( - child: Container( - alignment: Alignment.center, - color: Colors.red, - child: Text( - "I am Drawer!", - style: TextStyle(color: Colors.white, fontSize: 18), - ), + return Column( + children: [ + ElevatedButton( + onPressed: toggleDrawer, + child: const Text("显隐 Drawer"), + ), + SizedBox( + height: 200, + child: DrawerController( + scrimColor: Colors.blue.withAlpha(88), + enableOpenDragGesture: true, + key: _drawerKey, + alignment: DrawerAlignment.start, + drawerCallback: (value) { + _open = value; + }, + child: Drawer( + child: Container( + alignment: Alignment.center, + color: Colors.red, + child: const Text( + "I am Drawer!", + style: TextStyle(color: Colors.white, fontSize: 18), ), ), ), ), - ], - ), + ), + ], ); } diff --git a/lib/widget_system/widgets/StatefulWidget/DropdownButton/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/DropdownButton/node1_base.dart index 87842db..3f5b6b3 100644 --- a/lib/widget_system/widgets/StatefulWidget/DropdownButton/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/DropdownButton/node1_base.dart @@ -17,21 +17,28 @@ import 'package:flutter/material.dart'; // "【backgroundColor】 : 背景色 【Color】", // } class CustomDropDownButton extends StatefulWidget { + const CustomDropDownButton({Key? key}) : super(key: key); + @override _CustomDropDownButtonState createState() => _CustomDropDownButtonState(); } class _CustomDropDownButtonState extends State { Color _color = Colors.red; - final _colors = [Colors.red, Colors.yellow, Colors.blue, Colors.green]; - final _info = ["红色", "黄色", "蓝色", "绿色"]; + final List _colors = const [ + Colors.red, + Colors.yellow, + Colors.blue, + Colors.green + ]; + final List _info = const ["红色", "黄色", "蓝色", "绿色"]; @override Widget build(BuildContext context) { return Wrap( children: [ Container( - margin: EdgeInsets.symmetric(horizontal: 20), + margin: const EdgeInsets.symmetric(horizontal: 20), width: 50, height: 50, color: _color, diff --git a/lib/widget_system/widgets/StatefulWidget/DropdownButton/node2_style.dart b/lib/widget_system/widgets/StatefulWidget/DropdownButton/node2_style.dart index d5769de..a50b484 100644 --- a/lib/widget_system/widgets/StatefulWidget/DropdownButton/node2_style.dart +++ b/lib/widget_system/widgets/StatefulWidget/DropdownButton/node2_style.dart @@ -20,9 +20,15 @@ class StyleDropDownButton extends StatefulWidget { } class _StyleDropDownButtonState extends State { - Color _color = Colors.red ; - final List _colors = [Colors.red, Colors.yellow, Colors.blue, Colors.green]; - final List _info = ["红色", "黄色", "蓝色", "绿色"]; + Color _color = Colors.red; + + final List _colors = const [ + Colors.red, + Colors.yellow, + Colors.blue, + Colors.green + ]; + final List _info = const ["红色", "黄色", "蓝色", "绿色"]; @override Widget build(BuildContext context) { @@ -30,7 +36,7 @@ class _StyleDropDownButtonState extends State { crossAxisAlignment: WrapCrossAlignment.center, children: [ Container( - margin: EdgeInsets.symmetric(horizontal: 20), + margin: const EdgeInsets.symmetric(horizontal: 20), width: 50, height: 50, color: _color, diff --git a/lib/widget_system/widgets/StatefulWidget/DropdownButtonFormField/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/DropdownButtonFormField/node1_base.dart index 595da84..8785f98 100644 --- a/lib/widget_system/widgets/StatefulWidget/DropdownButtonFormField/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/DropdownButtonFormField/node1_base.dart @@ -18,26 +18,29 @@ import 'package:flutter/material.dart'; // } class DropdownButtonFormFieldDemo extends StatefulWidget { + const DropdownButtonFormFieldDemo({Key? key}) : super(key: key); + @override - _DropdownButtonFormFieldDemoState createState() => _DropdownButtonFormFieldDemoState(); + _DropdownButtonFormFieldDemoState createState() => + _DropdownButtonFormFieldDemoState(); } class _DropdownButtonFormFieldDemoState extends State { Color _color = Colors.blue; - final List _colors = [ + final List _colors = const [ Colors.red, Colors.yellow, Colors.blue, Colors.green ]; - final List _info = ["红色", "黄色", "蓝色", "绿色"]; + final List _info = const ["红色", "黄色", "蓝色", "绿色"]; @override Widget build(BuildContext context) { return Wrap( children: [ Container( - margin: EdgeInsets.symmetric(horizontal: 20), + margin: const EdgeInsets.symmetric(horizontal: 20), width: 50, height: 50, color: _color, @@ -48,7 +51,7 @@ class _DropdownButtonFormFieldDemoState extends State( value: _color, elevation: 1, - hint: Text('选择颜色',style: TextStyle(fontSize: 12),), + hint: const Text('选择颜色',style: TextStyle(fontSize: 12),), icon: Icon( Icons.expand_more, size: 20, diff --git a/lib/widget_system/widgets/StatefulWidget/EditableText/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/EditableText/node1_base.dart index d7b3b51..8fa16f5 100644 --- a/lib/widget_system/widgets/StatefulWidget/EditableText/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/EditableText/node1_base.dart @@ -17,24 +17,27 @@ import 'package:flutter/material.dart'; // } class EditableTextDemo extends StatefulWidget { + const EditableTextDemo({Key? key}) : super(key: key); + @override _EditableTextDemoState createState() => _EditableTextDemoState(); } class _EditableTextDemoState extends State { - final _ctrl = TextEditingController(text:'Hello Flutter Unit!'); - final _node = FocusNode(); + final TextEditingController _ctrl = + TextEditingController(text: 'Hello Flutter Unit!'); + final FocusNode _node = FocusNode(); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.all(8.0), child: EditableText( - controller: _ctrl, - focusNode: _node, - style: TextStyle(fontSize: 16,color: Colors.blue), - cursorColor: Colors.blue, - backgroundCursorColor: Colors.orange, + controller: _ctrl, + focusNode: _node, + style: const TextStyle(fontSize: 16, color: Colors.blue), + cursorColor: Colors.blue, + backgroundCursorColor: Colors.orange, ), ); } diff --git a/lib/widget_system/widgets/StatefulWidget/ElevatedButton/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/ElevatedButton/node1_base.dart index 6a13290..31ff221 100644 --- a/lib/widget_system/widgets/StatefulWidget/ElevatedButton/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/ElevatedButton/node1_base.dart @@ -14,6 +14,8 @@ import 'package:flutter/material.dart'; // } class ElevatedButtonDemo extends StatelessWidget { + const ElevatedButtonDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Container( @@ -23,11 +25,11 @@ class ElevatedButtonDemo extends StatelessWidget { spacing: 20, children: [ ElevatedButton( - child: Text('ElevatedButton'), + child: const Text('ElevatedButton'), onPressed: _onPressed, onLongPress: _onLongPress, ), - ElevatedButton( + const ElevatedButton( child: Text('禁用按钮'), onPressed: null, onLongPress: null, @@ -36,7 +38,7 @@ class ElevatedButtonDemo extends StatelessWidget { )); } - _onPressed() {} + void _onPressed() {} - _onLongPress() {} + void _onLongPress() {} } diff --git a/lib/widget_system/widgets/StatefulWidget/ElevatedButton/node2_style.dart b/lib/widget_system/widgets/StatefulWidget/ElevatedButton/node2_style.dart index d4d6100..ab5fc69 100644 --- a/lib/widget_system/widgets/StatefulWidget/ElevatedButton/node2_style.dart +++ b/lib/widget_system/widgets/StatefulWidget/ElevatedButton/node2_style.dart @@ -15,6 +15,8 @@ import 'package:flutter/material.dart'; // } class ElevatedButtonStyleDemo extends StatelessWidget { + const ElevatedButtonStyleDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Container( @@ -28,7 +30,7 @@ class ElevatedButtonStyleDemo extends StatelessWidget { primary: Colors.white, elevation: 2, shadowColor: Colors.orangeAccent), - child: Text('ElevatedButton样式'), + child: const Text('ElevatedButton样式'), onPressed: _onPressed, onLongPress: _onLongPress, ), @@ -36,13 +38,13 @@ class ElevatedButtonStyleDemo extends StatelessWidget { style: TextButton.styleFrom( backgroundColor: Colors.white, primary: Colors.black, - side: BorderSide(color: Colors.blue,width: 1), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(10)) + side: const BorderSide(color: Colors.blue,width: 1), + shape: const RoundedRectangleBorder( + borderRadius: const BorderRadius.all(Radius.circular(10)) ), // elevation: 2, shadowColor: Colors.orangeAccent), - child: Text('ElevatedButton边线'), + child: const Text('ElevatedButton边线'), autofocus: false, onPressed: _onPressed, onLongPress: _onLongPress, @@ -52,7 +54,7 @@ class ElevatedButtonStyleDemo extends StatelessWidget { ); } - _onPressed() {} + void _onPressed() {} - _onLongPress() {} + void _onLongPress() {} } diff --git a/lib/widget_system/widgets/StatefulWidget/ExpandIcon/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/ExpandIcon/node1_base.dart index a3fcb5b..a90eefc 100644 --- a/lib/widget_system/widgets/StatefulWidget/ExpandIcon/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/ExpandIcon/node1_base.dart @@ -15,18 +15,20 @@ import 'package:flutter/material.dart'; // "【onPressed】 : 点击事件 【Function(bool)】", // } class CustomExpandIcon extends StatefulWidget { + const CustomExpandIcon({Key? key}) : super(key: key); + @override _CustomExpandIconState createState() => _CustomExpandIconState(); } class _CustomExpandIconState extends State { - var _closed = true; + bool _closed = true; @override Widget build(BuildContext context) { return ExpandIcon( isExpanded: _closed, - padding: EdgeInsets.all(5), + padding: const EdgeInsets.all(5), size: 30, color: Colors.blue, expandedColor: Colors.orangeAccent, diff --git a/lib/widget_system/widgets/StatefulWidget/ExpansionPanelList/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/ExpansionPanelList/node1_base.dart index a2c6337..3faf35a 100644 --- a/lib/widget_system/widgets/StatefulWidget/ExpansionPanelList/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/ExpansionPanelList/node1_base.dart @@ -14,6 +14,8 @@ import 'package:flutter/material.dart'; // "【onPressed】 : 点击事件 【Function()】", // } class CustomExpansionPanelList extends StatefulWidget { + const CustomExpansionPanelList({Key? key}) : super(key: key); + @override _CustomExpansionPanelListState createState() => _CustomExpansionPanelListState(); @@ -36,13 +38,13 @@ class _CustomExpansionPanelListState extends State { @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: 300, child: ExpansionPanelList( children: data.map((color) => _buildItem(color)).toList(), - animationDuration: Duration(milliseconds: 200), + animationDuration: const Duration(milliseconds: 200), expansionCallback: (index, open) { - setState(() => _position=open?-1:index); + setState(() => _position = open ? -1 : index); }, ), ); @@ -68,7 +70,7 @@ class _CustomExpansionPanelListState extends State { height: 50, child: Text( colorString(color), - style: TextStyle(color: Colors.black), + style: const TextStyle(color: Colors.black), ), ), ], @@ -80,8 +82,12 @@ class _CustomExpansionPanelListState extends State { color: color, child: Text( colorString(color), - style: TextStyle(color: Colors.white, shadows: [ - Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) + style: const TextStyle(color: Colors.white, shadows: [ + Shadow( + color: Colors.black, + offset: Offset(.5, .5), + blurRadius: 2, + ) ]), ), )); diff --git a/lib/widget_system/widgets/StatefulWidget/ExpansionTile/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/ExpansionTile/node1_base.dart index ea376b4..1b054c2 100644 --- a/lib/widget_system/widgets/StatefulWidget/ExpansionTile/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/ExpansionTile/node1_base.dart @@ -17,6 +17,8 @@ import '../../StatelessWidget/RadioListTile/node1_base.dart'; // "【initiallyExpanded】 : 是否初始时展开 【bool】", // } class CustomExpansionTile extends StatefulWidget { + const CustomExpansionTile({Key? key}) : super(key: key); + @override _CustomExpansionTileState createState() => _CustomExpansionTileState(); } @@ -25,14 +27,14 @@ class _CustomExpansionTileState extends State { @override Widget build(BuildContext context) { return ExpansionTile( - leading: Icon(Icons.star), - title: Text("选择语言"), + leading: const Icon(Icons.star), + title: const Text("选择语言"), backgroundColor: Colors.grey.withAlpha(6), onExpansionChanged: (value) { print('$value'); }, initiallyExpanded: false, - children: [CustomRadioListTile()], + children: const[CustomRadioListTile()], ); } } diff --git a/lib/widget_system/widgets/StatefulWidget/Form/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/Form/node1_base.dart index dfacba8..012cd28 100644 --- a/lib/widget_system/widgets/StatefulWidget/Form/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/Form/node1_base.dart @@ -13,47 +13,47 @@ import 'package:flutter/material.dart'; // "【onWillPop】 : 返回回调 【WillPopCallback】", // } class CustomForm extends StatefulWidget { + const CustomForm({Key? key}) : super(key: key); + @override _CustomFormState createState() => _CustomFormState(); } class _CustomFormState extends State { - GlobalKey _formKey = GlobalKey(); + final GlobalKey _formKey = GlobalKey(); @override Widget build(BuildContext context) { - return Container( - child: Form( - onWillPop: () => _willPop(context), - key: _formKey, - onChanged: () { - print('Form---onChanged'); - }, - child: - Stack( - alignment: Alignment.centerRight, - children: [ - Container( - width: 350, - child: UnconstrainedBox( - child: Container( - width: 200, - height: 70, - child: TextFormField( - style: TextStyle(textBaseline: TextBaseline.alphabetic), - decoration: InputDecoration( - border: OutlineInputBorder(), - labelText: 'username', - ), - validator: _validateUsername, + return Form( + onWillPop: () => _willPop(context), + key: _formKey, + onChanged: () { + print('Form---onChanged'); + }, + child: + Stack( + alignment: Alignment.centerRight, + children: [ + SizedBox( + width: 350, + child: UnconstrainedBox( + child: SizedBox( + width: 200, + height: 70, + child: TextFormField( + style: const TextStyle(textBaseline: TextBaseline.alphabetic), + decoration: const InputDecoration( + border: OutlineInputBorder(), + labelText: 'username', ), + validator: _validateUsername, ), ), ), - Positioned( - top: 0, right: 0, child: _buildSubmitButton(context)), - ], - ), + ), + Positioned( + top: 0, right: 0, child: _buildSubmitButton(context)), + ], ), ); } @@ -68,18 +68,18 @@ class _CustomFormState extends State { RaisedButton _buildSubmitButton(BuildContext context) { return RaisedButton( color: Colors.blue, - shape: CircleBorder( + shape: const CircleBorder( side: BorderSide(width: 2.0, color: Color(0xFFFFDFDFDF)), ), onPressed: _onSubmit, - child: Icon( + child: const Icon( Icons.check, color: Colors.white, ), ); } - _onSubmit(){ + void _onSubmit(){ if(_formKey.currentState==null) return; if (_formKey.currentState!.validate()) { FocusScope.of(context).requestFocus(FocusNode()); @@ -91,18 +91,18 @@ class _CustomFormState extends State { return await showDialog( context: context, builder: (context) => AlertDialog( - shape: RoundedRectangleBorder( + shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(10))), - title: Text('提示'), - content: Text('你确定要离开此页吗?'), + title: const Text('提示'), + content: const Text('你确定要离开此页吗?'), actions: [ FlatButton( onPressed: () => Navigator.of(context).pop(true), - child: Text('确定'), + child: const Text('确定'), ), FlatButton( onPressed: () => Navigator.of(context).pop(false), - child: Text('取消'), + child: const Text('取消'), ), ], ), diff --git a/lib/widget_system/widgets/StatefulWidget/FormField/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/FormField/node1_base.dart index dd7fab8..f687de2 100644 --- a/lib/widget_system/widgets/StatefulWidget/FormField/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/FormField/node1_base.dart @@ -17,19 +17,22 @@ import 'package:flutter/material.dart'; // "【onSaved】 : 表单save时回调 【FormFieldSetter】", // } class FormFieldDemo extends StatelessWidget { + const FormFieldDemo({Key? key}) : super(key: key); + final String info = 'FormField 代表表单中的一个字段,对于字符串类型的字段,框架中封装了 TextFormField 以便使用;下拉选择的字段,用 DropdownButtonFormField。' '目前框架中 FormField 的子类也只有这两个。既然是表单字段,必然是要和 Form 组件一起使用。通过对 Form 添加 GlobalKey ,来获取 FormState 对象。' '当 FormState 调用 save 方法时,所有的 FormField 都会触发 onSave 方法,当 FormState 调用 validate 方法时,所有的 FormField 都会触发 validate 方法。'; + @override Widget build(BuildContext context) { return Container( color: Colors.blue.withOpacity(0.1), - padding: EdgeInsets.all(10), - margin: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), + margin: const EdgeInsets.all(10), child: Text(info), ); } diff --git a/lib/widget_system/widgets/StatefulWidget/FutureBuilder/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/FutureBuilder/node1_base.dart index 68f434c..d0aacef 100644 --- a/lib/widget_system/widgets/StatefulWidget/FutureBuilder/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/FutureBuilder/node1_base.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; // "【future】 : 异步任务 【Future】", // } class CustomFutureBuilder extends StatefulWidget { + const CustomFutureBuilder({Key? key}) : super(key: key); + @override _CustomFutureBuilderState createState() => _CustomFutureBuilderState(); } @@ -28,27 +30,25 @@ class _CustomFutureBuilderState extends State { @override Widget build(BuildContext context) { - return Container( - child: FutureBuilder( - initialData: 'Load', - future: _future, - builder: (ctx, snap) { - if (snap.connectionState == ConnectionState.done) { - return Text('${snap.data}'); - } - if (snap.connectionState == ConnectionState.waiting) { - return CircularProgressIndicator(); - } - if (snap.hasError) { - return Text('Error'); - } - return Container(); - }), - ); + return FutureBuilder( + initialData: 'Load', + future: _future, + builder: (ctx, snap) { + if (snap.connectionState == ConnectionState.done) { + return Text('${snap.data}'); + } + if (snap.connectionState == ConnectionState.waiting) { + return const CircularProgressIndicator(); + } + if (snap.hasError) { + return const Text('Error'); + } + return Container(); + }); } Future loadData() async { - await Future.delayed(Duration(seconds: 2)); + await Future.delayed(const Duration(seconds: 2)); return 'LoadeSuccess'; } } diff --git a/lib/widget_system/widgets/StatefulWidget/GlowingOverscrollIndicator/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/GlowingOverscrollIndicator/node1_base.dart index b03a6ea..0ca5cf0 100644 --- a/lib/widget_system/widgets/StatefulWidget/GlowingOverscrollIndicator/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/GlowingOverscrollIndicator/node1_base.dart @@ -17,6 +17,8 @@ import 'package:flutter/material.dart'; // } class GlowingOverscrollIndicatorDemo extends StatelessWidget { + GlowingOverscrollIndicatorDemo({Key? key}) : super(key: key); + final List data = [ Colors.orange[50]!, Colors.orange[100]!, @@ -42,7 +44,7 @@ class GlowingOverscrollIndicatorDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 300, child: GlowingOverscrollIndicator( color: Colors.purple, @@ -51,7 +53,7 @@ class GlowingOverscrollIndicatorDemo extends StatelessWidget { axisDirection: AxisDirection.down, child: ListView.builder( itemBuilder: (_, index) => Container( - margin: EdgeInsets.all(10), + margin: const EdgeInsets.all(10), height: 60, color: data[index], ), diff --git a/lib/widget_system/widgets/StatefulWidget/Hero/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/Hero/node1_base.dart index 0cd7f58..991cd7c 100644 --- a/lib/widget_system/widgets/StatefulWidget/Hero/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/Hero/node1_base.dart @@ -13,13 +13,15 @@ import 'package:flutter/material.dart'; // "【tag】 : 标签 【String】\n", // } class CustomHero extends StatelessWidget { + const CustomHero({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - var hero = Hero( + Hero hero = Hero( //----定义一个Hero,并添加tag标签,此中组件共享 tag: 'user-head', child: ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(30)), + borderRadius: const BorderRadius.all(Radius.circular(30)), child: Image.asset( "assets/images/icon_head.webp", width: 60, @@ -29,8 +31,8 @@ class CustomHero extends StatelessWidget { ), ); - var container = Container( - alignment: Alignment(-0.8, -0.8), + Widget container = Container( + alignment: const Alignment(-0.8, -0.8), child: hero, width: 250, height: 250 * 0.618, @@ -55,9 +57,11 @@ class CustomHero extends StatelessWidget { } class TargetPage extends StatelessWidget { + const TargetPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - var hero = Hero( + Hero hero = const Hero( //----定义一个Hero,为其添加标签,两个标签相同,则可以共享 tag: 'user-head', child: Padding( @@ -71,7 +75,7 @@ class TargetPage extends StatelessWidget { ), ); - var touch = InkWell( + Widget touch = InkWell( onTap: () { Navigator.of(context).pop(); }, @@ -80,7 +84,7 @@ class TargetPage extends StatelessWidget { return Scaffold( appBar: AppBar( - actions: [touch], + actions: [touch], ), body: Container( decoration: BoxDecoration( @@ -117,8 +121,8 @@ class Bottom2TopRouter extends PageRouteBuilder { Widget child, ) => SlideTransition( position: Tween( - begin: Offset(0.0, 1.0), - end: Offset(0.0, 0.0), + begin: const Offset(0.0, 1.0), + end: const Offset(0.0, 0.0), ).animate(CurvedAnimation(parent: a1, curve: curve)), child: child)); } diff --git a/lib/widget_system/widgets/StatefulWidget/Image/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/Image/node1_base.dart index 62f3607..400aee2 100644 --- a/lib/widget_system/widgets/StatefulWidget/Image/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/Image/node1_base.dart @@ -17,9 +17,11 @@ import 'package:flutter/material.dart'; // } class LoadImage extends StatelessWidget { - final assetsImagePath = "assets/images/icon_head.webp"; - final assetsGif = "assets/images/pica.gif"; - final netImageUrl = "https://p9-juejin.byteimg.com" + const LoadImage({Key? key}) : super(key: key); + + final String assetsImagePath = "assets/images/icon_head.webp"; + final String assetsGif = "assets/images/pica.gif"; + final String netImageUrl = "https://p9-juejin.byteimg.com" "/tos-cn-i-k3u1fbpfcp/36dee4e4dceb4c41a93df4a3603439fe~" "tplv-k3u1fbpfcp-zoom-crop-mark:1304:1304:1304:734.awebp"; @@ -27,7 +29,7 @@ class LoadImage extends StatelessWidget { Widget build(BuildContext context) { return Wrap( spacing: 10, - children: [ + children: [ _loadFromAssets(), _loadFromNet(), ], @@ -36,7 +38,7 @@ class LoadImage extends StatelessWidget { Widget _loadFromAssets() => Wrap( spacing: 10, - children: [ + children: [ Image.asset(assetsImagePath, height: 80, width: 80), Image.asset(assetsGif, height: 80, width: 80), ], diff --git a/lib/widget_system/widgets/StatefulWidget/Image/node2_fit.dart b/lib/widget_system/widgets/StatefulWidget/Image/node2_fit.dart index 17573d8..2dd8f65 100644 --- a/lib/widget_system/widgets/StatefulWidget/Image/node2_fit.dart +++ b/lib/widget_system/widgets/StatefulWidget/Image/node2_fit.dart @@ -12,6 +12,8 @@ import 'package:flutter/material.dart'; // }, class FitImage extends StatefulWidget { + const FitImage({Key? key}) : super(key: key); + @override _FitImageState createState() => _FitImageState(); } @@ -21,11 +23,11 @@ class _FitImageState extends State { @override Widget build(BuildContext context) { - var imageLi = BoxFit.values + List imageLi = BoxFit.values .toList() - .map((mode) => Column(children: [ + .map((mode) => Column(children:[ Container( - margin: EdgeInsets.all(5), + margin: const EdgeInsets.all(5), width: 100, height: 80, color: Colors.grey.withAlpha(88), @@ -35,8 +37,7 @@ class _FitImageState extends State { : "assets/images/wy_30x20.webp"), fit: mode)), Text(mode.toString().split(".")[1]) - ])) - .toList(); + ])).toList(); return Wrap( children: [...imageLi, _buildSwitch()], @@ -51,7 +52,7 @@ class _FitImageState extends State { child: Wrap( crossAxisAlignment: WrapCrossAlignment.center, children: [ - Text("使用小图"), + const Text("使用小图"), Switch( value: _smallImage, onChanged: (b) => setState(() => _smallImage = b)), diff --git a/lib/widget_system/widgets/StatefulWidget/Image/node3_alignment.dart b/lib/widget_system/widgets/StatefulWidget/Image/node3_alignment.dart index fc2750a..2539717 100644 --- a/lib/widget_system/widgets/StatefulWidget/Image/node3_alignment.dart +++ b/lib/widget_system/widgets/StatefulWidget/Image/node3_alignment.dart @@ -13,29 +13,32 @@ import 'package:flutter/material.dart'; // }, class AlignmentImage extends StatelessWidget { + const AlignmentImage({Key? key}) : super(key: key); + + final List alignment = const[ + Alignment.center, + Alignment.centerLeft, + Alignment.centerRight, + Alignment.topCenter, + Alignment.topLeft, + Alignment.topRight, + Alignment.bottomCenter, + Alignment.bottomLeft, + Alignment.bottomRight + ]; //测试数组 + @override Widget build(BuildContext context) { - var alignment = [ - Alignment.center, - Alignment.centerLeft, - Alignment.centerRight, - Alignment.topCenter, - Alignment.topLeft, - Alignment.topRight, - Alignment.bottomCenter, - Alignment.bottomLeft, - Alignment.bottomRight - ]; //测试数组 - var imgLi = alignment + List imgLi = alignment .map((alignment) => //生成子Widget列表 - Column(children: [ + Column(children: [ Container( - margin: EdgeInsets.all(5), + margin: const EdgeInsets.all(5), width: 90, height: 60, color: Colors.grey.withAlpha(88), child: Image( - image: AssetImage("assets/images/wy_30x20.webp"), + image: const AssetImage("assets/images/wy_30x20.webp"), alignment: alignment, )), Text(alignment.toString()) diff --git a/lib/widget_system/widgets/StatefulWidget/Image/node4_colorBlendMode.dart b/lib/widget_system/widgets/StatefulWidget/Image/node4_colorBlendMode.dart index 647ea8c..034f818 100644 --- a/lib/widget_system/widgets/StatefulWidget/Image/node4_colorBlendMode.dart +++ b/lib/widget_system/widgets/StatefulWidget/Image/node4_colorBlendMode.dart @@ -13,19 +13,21 @@ import 'package:flutter/material.dart'; // }, class BlendModeImage extends StatelessWidget { + const BlendModeImage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Wrap( children: BlendMode.values .toList() - .map((mode) => Column(children: [ + .map((mode) => Column(children:[ Container( - margin: EdgeInsets.all(5), + margin: const EdgeInsets.all(5), width: 60, height: 60, color: Colors.red, child: Image( - image: AssetImage("assets/images/icon_head.webp"), + image: const AssetImage("assets/images/icon_head.webp"), color: Colors.blue.withAlpha(88), colorBlendMode: mode)), Text(mode.toString().split(".")[1]) diff --git a/lib/widget_system/widgets/StatefulWidget/Image/node5_repeat.dart b/lib/widget_system/widgets/StatefulWidget/Image/node5_repeat.dart index 27c45f8..10a71f2 100644 --- a/lib/widget_system/widgets/StatefulWidget/Image/node5_repeat.dart +++ b/lib/widget_system/widgets/StatefulWidget/Image/node5_repeat.dart @@ -12,19 +12,21 @@ import 'package:flutter/material.dart'; // }, class RepeatImage extends StatelessWidget { + const RepeatImage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Wrap( children: ImageRepeat.values .toList() - .map((mode) => Column(children: [ + .map((mode) => Column(children:[ Container( - margin: EdgeInsets.all(5), + margin: const EdgeInsets.all(5), width: 150, height: 60, color: Colors.red, child: Image( - image: AssetImage("assets/images/wy_30x20.webp"), + image: const AssetImage("assets/images/wy_30x20.webp"), repeat: mode)), Text(mode.toString().split(".")[1]) ])) diff --git a/lib/widget_system/widgets/StatefulWidget/Image/node6_centerSlice.dart b/lib/widget_system/widgets/StatefulWidget/Image/node6_centerSlice.dart index 4c7359d..d133dea 100644 --- a/lib/widget_system/widgets/StatefulWidget/Image/node6_centerSlice.dart +++ b/lib/widget_system/widgets/StatefulWidget/Image/node6_centerSlice.dart @@ -15,14 +15,16 @@ import 'package:flutter/material.dart'; // }, class CenterSliceImage extends StatelessWidget { + const CenterSliceImage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: 300, height: 80, child: Image.asset( "assets/images/right_chat.png", - centerSlice: Rect.fromLTRB(9, 27, 60, 27 + 1.0), + centerSlice: const Rect.fromLTRB(9, 27, 60, 27 + 1.0), fit: BoxFit.fill, ), ); diff --git a/lib/widget_system/widgets/StatefulWidget/Ink/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/Ink/node1_base.dart index 20adc80..534296e 100644 --- a/lib/widget_system/widgets/StatefulWidget/Ink/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/Ink/node1_base.dart @@ -16,6 +16,8 @@ import 'package:flutter/material.dart'; // "【color】 : 颜色 【Color】", // } class CustomInk extends StatelessWidget { + const CustomInk({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Material( @@ -24,20 +26,16 @@ class CustomInk extends StatelessWidget { padding: const EdgeInsets.all(8.0), child: Center( child: Ink( - padding: EdgeInsets.all(10), - decoration: BoxDecoration( + padding: const EdgeInsets.all(10), + decoration: const BoxDecoration( color: Colors.yellow, - borderRadius: BorderRadius.all(Radius.circular(20)) - ), - + borderRadius: BorderRadius.all(Radius.circular(20))), width: 200.0, height: 100.0, child: InkWell( - onTap: () { - }, - child: Center( - child: Text('Hello'), - )), + onTap: () {}, + child: const Center(child: Text('Hello')), + ), ), ), ), diff --git a/lib/widget_system/widgets/StatefulWidget/Ink/node2_image.dart b/lib/widget_system/widgets/StatefulWidget/Ink/node2_image.dart index 23226b8..b96aa80 100644 --- a/lib/widget_system/widgets/StatefulWidget/Ink/node2_image.dart +++ b/lib/widget_system/widgets/StatefulWidget/Ink/node2_image.dart @@ -12,22 +12,24 @@ import 'package:flutter/material.dart'; // } class InkImage extends StatelessWidget { + const InkImage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Material( color: Colors.grey[800], child: Center( child: Ink.image( - image: AssetImage('assets/images/sabar.webp'), + image: const AssetImage('assets/images/sabar.webp'), fit: BoxFit.cover, width: 300.0, height: 200.0, child: InkWell( onTap: () {}, - child: Align( + child: const Align( alignment: Alignment.topLeft, child: Padding( - padding: const EdgeInsets.all(10.0), + padding: EdgeInsets.all(10.0), child: Text('Chaos', style: TextStyle( fontWeight: FontWeight.w900, color: Colors.black)), diff --git a/lib/widget_system/widgets/StatefulWidget/InkResponse/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/InkResponse/node1_base.dart index 3294192..9592a85 100644 --- a/lib/widget_system/widgets/StatefulWidget/InkResponse/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/InkResponse/node1_base.dart @@ -17,12 +17,14 @@ import 'package:flutter/material.dart'; // } class CustomInkResponse extends StatefulWidget { + const CustomInkResponse({Key? key}) : super(key: key); + @override _CustomInkResponseState createState() => _CustomInkResponseState(); } class _CustomInkResponseState extends State { - var _info = 'Push'; + String _info = 'Push'; @override Widget build(BuildContext context) { diff --git a/lib/widget_system/widgets/StatefulWidget/InkResponse/node2_color.dart b/lib/widget_system/widgets/StatefulWidget/InkResponse/node2_color.dart index 236e4fa..316b3a4 100644 --- a/lib/widget_system/widgets/StatefulWidget/InkResponse/node2_color.dart +++ b/lib/widget_system/widgets/StatefulWidget/InkResponse/node2_color.dart @@ -17,12 +17,14 @@ import 'package:flutter/material.dart'; // } class ColorInkResponse extends StatefulWidget { + const ColorInkResponse({Key? key}) : super(key: key); + @override _ColorInkResponseState createState() => _ColorInkResponseState(); } class _ColorInkResponseState extends State { - var _info = 'Push'; + String _info = 'Push'; @override Widget build(BuildContext context) { diff --git a/lib/widget_system/widgets/StatefulWidget/InkWell/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/InkWell/node1_base.dart index de2b03d..1ae5536 100644 --- a/lib/widget_system/widgets/StatefulWidget/InkWell/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/InkWell/node1_base.dart @@ -17,12 +17,14 @@ import 'package:flutter/material.dart'; // } class CustomInkWell extends StatefulWidget { + const CustomInkWell({Key? key}) : super(key: key); + @override _CustomInkWellState createState() => _CustomInkWellState(); } class _CustomInkWellState extends State { - var _info = 'Push'; + String _info = 'Push'; @override Widget build(BuildContext context) { diff --git a/lib/widget_system/widgets/StatefulWidget/InkWell/node2_color.dart b/lib/widget_system/widgets/StatefulWidget/InkWell/node2_color.dart index 442a992..4194861 100644 --- a/lib/widget_system/widgets/StatefulWidget/InkWell/node2_color.dart +++ b/lib/widget_system/widgets/StatefulWidget/InkWell/node2_color.dart @@ -17,12 +17,14 @@ import 'package:flutter/material.dart'; // } class ColorInkWell extends StatefulWidget { + const ColorInkWell({Key? key}) : super(key: key); + @override _ColorInkWellState createState() => _ColorInkWellState(); } class _ColorInkWellState extends State { - var _info = 'Push'; + String _info = 'Push'; @override Widget build(BuildContext context) { diff --git a/lib/widget_system/widgets/StatefulWidget/InputDecorator/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/InputDecorator/node1_base.dart index 26c7452..9a34c20 100644 --- a/lib/widget_system/widgets/StatefulWidget/InputDecorator/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/InputDecorator/node1_base.dart @@ -14,16 +14,18 @@ import 'package:flutter/material.dart'; // } class InputDecoratorDemo extends StatelessWidget { + const InputDecoratorDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.all(8.0), child: InputDecorator( - decoration: InputDecoration(), + decoration: const InputDecoration(), child: EditableText( controller: TextEditingController(text:'hello'), focusNode: FocusNode(), - style: TextStyle(fontSize: 12,color: Colors.black), + style: const TextStyle(fontSize: 12,color: Colors.black), cursorColor: Colors.blue, backgroundCursorColor: Colors.orange, ), diff --git a/lib/widget_system/widgets/StatefulWidget/InteractiveViewer/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/InteractiveViewer/node1_base.dart index 41979fd..099d391 100644 --- a/lib/widget_system/widgets/StatefulWidget/InteractiveViewer/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/InteractiveViewer/node1_base.dart @@ -21,6 +21,7 @@ import 'package:flutter/material.dart'; // } class InteractiveViewerDemo extends StatelessWidget { + const InteractiveViewerDemo({Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -33,9 +34,7 @@ class InteractiveViewerDemo extends StatelessWidget { minScale: 0.3, panEnabled: true, scaleEnabled: true, - child: Container( - child: Image.asset('assets/images/caver.webp'), - ), + child: Image.asset('assets/images/caver.webp'), onInteractionStart: _onInteractionStart, onInteractionUpdate: _onInteractionUpdate, onInteractionEnd: _onInteractionEnd, diff --git a/lib/widget_system/widgets/StatefulWidget/InteractiveViewer/node2_constrained.dart b/lib/widget_system/widgets/StatefulWidget/InteractiveViewer/node2_constrained.dart index ecb1c76..7548920 100644 --- a/lib/widget_system/widgets/StatefulWidget/InteractiveViewer/node2_constrained.dart +++ b/lib/widget_system/widgets/StatefulWidget/InteractiveViewer/node2_constrained.dart @@ -12,12 +12,28 @@ import 'package:flutter/material.dart'; // } class InteractiveViewerDemo2 extends StatelessWidget { + const InteractiveViewerDemo2({Key? key}) : super(key: key); + final List colors = const [ + Colors.red, + Colors.yellow, + Colors.blue, + Colors.green + ]; + + final List colors2 = const [ + Colors.yellow, + Colors.blue, + Colors.green, + Colors.red + ]; + + @override Widget build(BuildContext context) { - const int _rowCount = 20; - const int _columnCount = 4; + int _rowCount = 20; + int _columnCount = 4; - return Container( + return SizedBox( width: 300, height: 200, child: InteractiveViewer( @@ -36,24 +52,25 @@ class InteractiveViewerDemo2 extends StatelessWidget { List buildRows(int rowCount, int columnCount) { return [ - for (int row = 0; row < rowCount; row += 1) - TableRow( - children: [ - for (int column = 0; column < columnCount; column += 1) - Container( - margin: EdgeInsets.all(2), - height: 50, - alignment: Alignment.center, - color: _colorful(row,column), - child: Text('($row,$column)',style: TextStyle(fontSize: 20,color: Colors.white),), - ), - ], - ), - ]; + for (int row = 0; row < rowCount; row += 1) + TableRow( + children: [ + for (int column = 0; column < columnCount; column += 1) + Container( + margin: const EdgeInsets.all(2), + height: 50, + alignment: Alignment.center, + color: _colorful(row, column), + child: Text( + '($row,$column)', + style: const TextStyle(fontSize: 20, color: Colors.white), + ), + ), + ], + ), + ]; } - final colors = [Colors.red,Colors.yellow,Colors.blue,Colors.green]; - final colors2 = [Colors.yellow,Colors.blue,Colors.green,Colors.red]; - - _colorful(int row, int column ) => row % 2==0?colors[column]:colors2[column]; + Color _colorful(int row, int column) => + row % 2 == 0 ? colors[column] : colors2[column]; } diff --git a/lib/widget_system/widgets/StatefulWidget/InteractiveViewer/node3_controller.dart b/lib/widget_system/widgets/StatefulWidget/InteractiveViewer/node3_controller.dart index c7a5d6b..ec176ef 100644 --- a/lib/widget_system/widgets/StatefulWidget/InteractiveViewer/node3_controller.dart +++ b/lib/widget_system/widgets/StatefulWidget/InteractiveViewer/node3_controller.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; // } class InteractiveViewerDemo3 extends StatefulWidget { + const InteractiveViewerDemo3({Key? key}) : super(key: key); + @override _InteractiveViewerDemo3State createState() => _InteractiveViewerDemo3State(); } @@ -81,14 +83,12 @@ class _InteractiveViewerDemo3State extends State height: 150, color: Colors.grey.withAlpha(33), child: InteractiveViewer( - boundaryMargin: EdgeInsets.all(40), + boundaryMargin: const EdgeInsets.all(40), transformationController: _transformationController, minScale: 0.1, maxScale: 1.8, onInteractionStart: _onInteractionStart, - child: Container( - child: Image.asset('assets/images/caver.webp'), - ), + child: Image.asset('assets/images/caver.webp'), ), ), Row( @@ -105,13 +105,13 @@ class _InteractiveViewerDemo3State extends State Widget _buildButton() { return MaterialButton( - child: Icon( + child: const Icon( Icons.refresh, color: Colors.white, ), color: Colors.green, - shape: CircleBorder( - side: BorderSide(width: 2.0, color: Color(0xFFFFDFDFDF)), + shape: const CircleBorder( + side: BorderSide(width: 2.0, color: Color(0xFFDFDFDF)), ), onPressed: _animateResetInitialize); } @@ -120,13 +120,13 @@ class _InteractiveViewerDemo3State extends State Widget _buildButton2() { return MaterialButton( - child: Icon( + child: const Icon( Icons.navigate_before, color: Colors.white, ), color: Colors.green, - shape: CircleBorder( - side: BorderSide(width: 2.0, color: Color(0xFFFFDFDFDF)), + shape: const CircleBorder( + side: BorderSide(width: 2.0, color: Color(0xFFDFDFDF)), ), onPressed: () { var temp = _transformationController.value.clone(); @@ -137,13 +137,13 @@ class _InteractiveViewerDemo3State extends State Widget _buildButton3() { return MaterialButton( - child: Icon( + child: const Icon( Icons.navigate_next, color: Colors.white, ), color: Colors.green, - shape: CircleBorder( - side: BorderSide(width: 2.0, color: Color(0xFFFFDFDFDF)), + shape: const CircleBorder( + side: BorderSide(width: 2.0, color: Color(0xFFDFDFDF)), ), onPressed: () { var temp = _transformationController.value.clone(); diff --git a/lib/widget_system/widgets/StatefulWidget/LicensePage/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/LicensePage/node1_base.dart index f031c90..58d95e3 100644 --- a/lib/widget_system/widgets/StatefulWidget/LicensePage/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/LicensePage/node1_base.dart @@ -14,12 +14,14 @@ import 'package:flutter/material.dart'; // "【applicationLegalese】 : 应用律术 【String】", // } class CustomLicensePage extends StatelessWidget { + const CustomLicensePage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: MediaQuery.of(context).size.width, height: 400, - child: LicensePage( + child: const LicensePage( applicationIcon: FlutterLogo(), applicationVersion: 'v0.0.1', applicationName: 'Flutter Unit', diff --git a/lib/widget_system/widgets/StatefulWidget/LinearProgressIndicator/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/LinearProgressIndicator/node1_base.dart index 132a9f6..a124eb3 100644 --- a/lib/widget_system/widgets/StatefulWidget/LinearProgressIndicator/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/LinearProgressIndicator/node1_base.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; // " value为null时会不停循环", // } class CustomLinearProgressIndicator extends StatefulWidget { + const CustomLinearProgressIndicator({Key? key}) : super(key: key); + @override _CustomLinearProgressIndicatorState createState() => _CustomLinearProgressIndicatorState(); @@ -27,13 +29,13 @@ class _CustomLinearProgressIndicatorState return Wrap( spacing: 10, children: data - .map((e) => Container( + .map((e) => SizedBox( width: 50, height: 3, child:LinearProgressIndicator( value: e, backgroundColor: Colors.grey.withAlpha(33), - valueColor: AlwaysStoppedAnimation(Colors.orange), + valueColor: const AlwaysStoppedAnimation(Colors.orange), ), )) .toList(), diff --git a/lib/widget_system/widgets/StatefulWidget/ListWheelScrollView/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/ListWheelScrollView/node1_base.dart index 81e433c..421b320 100644 --- a/lib/widget_system/widgets/StatefulWidget/ListWheelScrollView/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/ListWheelScrollView/node1_base.dart @@ -14,8 +14,11 @@ import 'package:flutter/material.dart'; // "【onSelectedItemChanged】 : 选中回调 【ValueChanged 】", // } class CustomListWheelScrollView extends StatefulWidget { + const CustomListWheelScrollView({Key? key}) : super(key: key); + @override - _CustomListWheelScrollViewState createState() => _CustomListWheelScrollViewState(); + _CustomListWheelScrollViewState createState() => + _CustomListWheelScrollViewState(); } class _CustomListWheelScrollViewState extends State { @@ -39,15 +42,15 @@ class _CustomListWheelScrollViewState extends State { return Column( children: [ _buildCircle(), - Container( + SizedBox( height: 150, width: 300, child: ListWheelScrollView( perspective: 0.006, itemExtent: 50, - onSelectedItemChanged: (index){ + onSelectedItemChanged: (index) { print('onSelectedItemChanged:$index'); - setState(() => _color=data[index]); + setState(() => _color = data[index]); }, children: data.map((color) => _buildItem(color)).toList(), ), @@ -57,13 +60,10 @@ class _CustomListWheelScrollViewState extends State { } Widget _buildCircle() => Container( - margin: EdgeInsets.only(bottom: 5), + margin: const EdgeInsets.only(bottom: 5), width: 30, height: 30, - decoration: BoxDecoration( - color: _color, - shape: BoxShape.circle - ), + decoration: BoxDecoration(color: _color, shape: BoxShape.circle), ); Widget _buildItem(Color color) { @@ -74,8 +74,12 @@ class _CustomListWheelScrollViewState extends State { color: color, child: Text( colorString(color), - style: TextStyle(color: Colors.white, shadows: [ - Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) + style: const TextStyle(color: Colors.white, shadows: [ + Shadow( + color: Colors.black, + offset: Offset(.5, .5), + blurRadius: 2, + ) ]), ), ); diff --git a/lib/widget_system/widgets/StatefulWidget/LongPressDraggable/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/LongPressDraggable/node1_base.dart index 1d2166d..502b32b 100644 --- a/lib/widget_system/widgets/StatefulWidget/LongPressDraggable/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/LongPressDraggable/node1_base.dart @@ -18,8 +18,11 @@ import 'package:flutter/material.dart'; // "【onDraggableCanceled】 : 拖拽取消 【Function(Velocity,Offset)】", // } class CustomLongPressDraggable extends StatefulWidget { + const CustomLongPressDraggable({Key? key}) : super(key: key); + @override - _CustomLongPressDraggableState createState() => _CustomLongPressDraggableState(); + _CustomLongPressDraggableState createState() => + _CustomLongPressDraggableState(); } class _CustomLongPressDraggableState extends State { @@ -28,62 +31,59 @@ class _CustomLongPressDraggableState extends State { @override Widget build(BuildContext context) { - return Container( - child: Column( - children: [ - Wrap( - children: _buildColors(), - spacing: 10, - ), - SizedBox(height: 20,), - _buildDragTarget() - ], - ), + return Column( + children: [ + Wrap( + children: _buildColors(), + spacing: 10, + ), + const SizedBox(height: 20), + _buildDragTarget() + ], ); } - List _buildColors() { - var colors = [ - Colors.red, - Colors.yellow, - Colors.blue, - Colors.green, - Colors.orange, - Colors.purple, - Colors.cyanAccent - ]; - return colors - .map( - (e) => LongPressDraggable( - onDragStarted: () => setState(() => _info = '开始拖拽'), - onDragEnd: (d) => setState(() => _info = '结束拖拽'), - onDragCompleted: () => _info = '拖拽完成', - onDraggableCanceled: (v, o) => _info = '拖拽取消', - child: Container( - width: 30, - height: 30, - alignment: Alignment.center, - child: Text( - colors.indexOf(e).toString(), - style: TextStyle( - color: Colors.white, fontWeight: FontWeight.bold), + final List colors = const [ + Colors.red, + Colors.yellow, + Colors.blue, + Colors.green, + Colors.orange, + Colors.purple, + Colors.cyanAccent + ]; + + List _buildColors() => colors + .map( + (e) => LongPressDraggable( + onDragStarted: () => setState(() => _info = '开始拖拽'), + onDragEnd: (d) => setState(() => _info = '结束拖拽'), + onDragCompleted: () => _info = '拖拽完成', + onDraggableCanceled: (v, o) => _info = '拖拽取消', + child: Container( + width: 30, + height: 30, + alignment: Alignment.center, + child: Text( + colors.indexOf(e).toString(), + style: const TextStyle( + color: Colors.white, fontWeight: FontWeight.bold), + ), + decoration: BoxDecoration(color: e, shape: BoxShape.circle), ), - decoration: BoxDecoration(color: e, shape: BoxShape.circle), - ), - data: e, - feedback: Container( - width: 25, - height: 25, - decoration: BoxDecoration(color: e, shape: BoxShape.circle), - )), - ) - .toList(); - } + data: e, + feedback: Container( + width: 25, + height: 25, + decoration: BoxDecoration(color: e, shape: BoxShape.circle), + )), + ) + .toList(); Widget _buildDragTarget() { return DragTarget( onAccept: (data) => setState(() { - _info='onAccept'; + _info='onAccept'; _color = data; }), builder: (context, candidateData, rejectedData) => Container( @@ -93,7 +93,7 @@ class _CustomLongPressDraggableState extends State { child: Center( child: Text( _info, - style: TextStyle(color: Colors.white), + style: const TextStyle(color: Colors.white), ), ))); } diff --git a/lib/widget_system/widgets/StatefulWidget/Material/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/Material/node1_base.dart index 1461e84..4e78c44 100644 --- a/lib/widget_system/widgets/StatefulWidget/Material/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/Material/node1_base.dart @@ -15,6 +15,8 @@ import 'package:flutter/material.dart'; // "【color】 : 颜色 【Color】", // } class CustomMaterial extends StatelessWidget { + const CustomMaterial({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Wrap( @@ -34,7 +36,7 @@ class CustomMaterial extends StatelessWidget { height: 60, child: Text( type.toString().split('.')[1], - style: TextStyle(color: Colors.black), + style: const TextStyle(color: Colors.black), ), ), ); diff --git a/lib/widget_system/widgets/StatefulWidget/Material/node2_shape.dart b/lib/widget_system/widgets/StatefulWidget/Material/node2_shape.dart index 67a3d47..58872e8 100644 --- a/lib/widget_system/widgets/StatefulWidget/Material/node2_shape.dart +++ b/lib/widget_system/widgets/StatefulWidget/Material/node2_shape.dart @@ -11,8 +11,9 @@ import 'package:flutter/material.dart'; // "【shape】 : 形状 【ShapeBorder】\n", // } class ShapeMaterial extends StatelessWidget { + const ShapeMaterial({Key? key}) : super(key: key); - final shapeMap = { + final Map shapeMap = const { 'BorderDirectional': BorderDirectional( top: BorderSide( color: Colors.white, @@ -22,44 +23,45 @@ class ShapeMaterial extends StatelessWidget { color: Colors.white, )), 'Border': Border( - top: BorderSide(width: 5.0, color: Color(0xFFFFDFDFDF)), - left: BorderSide(width: 5.0, color: Color(0xFFFFDFDFDF)), - right: BorderSide(width: 5.0, color: Color(0xFFFF7F7F7F)), - bottom: BorderSide(width: 5.0, color: Color(0xFFFF7F7F7F)), + top: BorderSide(width: 5.0, color: Color(0xFFDFDFDF)), + left: BorderSide(width: 5.0, color: Color(0xFFDFDFDF)), + right: BorderSide(width: 5.0, color: Color(0xFF7F7F7F)), + bottom: BorderSide(width: 5.0, color: Color(0xFF7F7F7F)), ), 'Circle': CircleBorder( - side: BorderSide(width: 2.0, color: Color(0xFFFFDFDFDF)), + side: BorderSide(width: 2.0, color: Color(0xFFDFDFDF)), ), 'RoundedRectangleBorder': RoundedRectangleBorder( side: BorderSide(width: 1.0, color: Colors.black), borderRadius: BorderRadius.all(Radius.circular(15))), 'ContinuousRectangleBorder': ContinuousRectangleBorder( side: BorderSide.none, - borderRadius: BorderRadius.circular(40.0), + borderRadius: BorderRadius.all(Radius.circular(40.0)), ) }; @override Widget build(BuildContext context) { return Wrap( - spacing: 10, - runSpacing: 10, - children: shapeMap.keys.map((e) => _buildMaterial(e)).toList()); + spacing: 10, + runSpacing: 10, + children: shapeMap.keys.map((e) => _buildMaterial(e)).toList(), + ); } Material _buildMaterial(String type) => Material( - shadowColor: Colors.blue, - shape: shapeMap[type], - color: Colors.orange, - elevation: 3, - textStyle: TextStyle(color: Colors.white), - child: Container( - alignment: Alignment.center, - width: 300, - height: 60, - child: Text( - type, - ), - ), - ); + shadowColor: Colors.blue, + shape: shapeMap[type], + color: Colors.orange, + elevation: 3, + textStyle: const TextStyle(color: Colors.white), + child: Container( + alignment: Alignment.center, + width: 300, + height: 60, + child: Text( + type, + ), + ), + ); } diff --git a/lib/widget_system/widgets/StatefulWidget/MaterialApp/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/MaterialApp/node1_base.dart index a315923..328fcd6 100644 --- a/lib/widget_system/widgets/StatefulWidget/MaterialApp/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/MaterialApp/node1_base.dart @@ -18,14 +18,16 @@ import 'package:flutter/material.dart'; // "【home】 : 主页 【Widget】", // } class MaterialAppDemo extends StatefulWidget { + const MaterialAppDemo({Key? key}) : super(key: key); + @override _WidgetsAppDemoState createState() => _WidgetsAppDemoState(); } class _WidgetsAppDemoState extends State { - var _debugShowCheckedModeBanner = false; - var _showPerformanceOverlay = false; - var _debugShowMaterialGrid = false; + bool _debugShowCheckedModeBanner = false; + bool _showPerformanceOverlay = false; + bool _debugShowMaterialGrid = false; @override Widget build(BuildContext context) { @@ -33,13 +35,13 @@ class _WidgetsAppDemoState extends State { mainAxisSize: MainAxisSize.min, children: [ _buildSwitchers(), - Container( + SizedBox( height: 250, child: MaterialApp( debugShowCheckedModeBanner: _debugShowCheckedModeBanner, showPerformanceOverlay: _showPerformanceOverlay, debugShowMaterialGrid: _debugShowMaterialGrid, - home: HomePage(), + home: const HomePage(), ), ), ], @@ -48,7 +50,7 @@ class _WidgetsAppDemoState extends State { Widget _buildSwitchers() { return DefaultTextStyle( - style: TextStyle(color: Colors.blue), + style: const TextStyle(color: Colors.blue), child: Wrap( spacing: 10, children: [ @@ -62,7 +64,7 @@ class _WidgetsAppDemoState extends State { }); }, ), - Text('性能浮层') + const Text('性能浮层') ], ), Column( @@ -75,7 +77,7 @@ class _WidgetsAppDemoState extends State { }); }, ), - Text('开启角标') + const Text('开启角标') ], ), Column( @@ -88,7 +90,7 @@ class _WidgetsAppDemoState extends State { }); }, ), - Text('开启网格') + const Text('开启网格') ], ) ], @@ -98,6 +100,8 @@ class _WidgetsAppDemoState extends State { } class HomePage extends StatefulWidget { + const HomePage({Key? key}) : super(key: key); + @override _HomePageState createState() => _HomePageState(); } @@ -109,14 +113,14 @@ class _HomePageState extends State { Widget build(BuildContext context) { return Scaffold( body: Container( - alignment: Alignment(0, 0.7), + alignment: const Alignment(0, 0.7), child: Text( '你点击了$_count次', - style: TextStyle(fontSize: 18, color: Colors.blue), + style: const TextStyle(fontSize: 18, color: Colors.blue), ), ), floatingActionButton: FloatingActionButton( - child: Icon(Icons.add), + child: const Icon(Icons.add), onPressed: () { setState(() { _count++; diff --git a/lib/widget_system/widgets/StatefulWidget/MergeableMaterial/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/MergeableMaterial/node1_base.dart index 44dd5de..fdf4b9b 100644 --- a/lib/widget_system/widgets/StatefulWidget/MergeableMaterial/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/MergeableMaterial/node1_base.dart @@ -17,6 +17,8 @@ import 'package:flutter/material.dart'; // } class MergeableMaterialDemo extends StatefulWidget { + const MergeableMaterialDemo({Key? key}) : super(key: key); + @override _MergeableMaterialDemoState createState() => _MergeableMaterialDemoState(); } @@ -32,7 +34,7 @@ class _MergeableMaterialDemoState extends State { @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 300, child: SingleChildScrollView( child: MergeableMaterial( diff --git a/lib/widget_system/widgets/StatefulWidget/MonthPicker/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/MonthPicker/node1_base.dart index ee72ab5..9d4da62 100644 --- a/lib/widget_system/widgets/StatefulWidget/MonthPicker/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/MonthPicker/node1_base.dart @@ -14,6 +14,8 @@ import 'package:flutter/material.dart'; // "【onChanged】 : 点击回调 【Function(DateTime)】", // } class CustomMonthPicker extends StatefulWidget { + const CustomMonthPicker({Key? key}) : super(key: key); + @override _CustomMonthPickerState createState() => _CustomMonthPickerState(); } @@ -23,7 +25,7 @@ class _CustomMonthPickerState extends State { @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 350, child: MonthPicker( selectedDate: _date, diff --git a/lib/widget_system/widgets/StatefulWidget/MouseRegion/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/MouseRegion/node1_base.dart index 66ebac1..7fc1528 100644 --- a/lib/widget_system/widgets/StatefulWidget/MouseRegion/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/MouseRegion/node1_base.dart @@ -14,6 +14,8 @@ import 'package:flutter/material.dart'; // } class MouseRegionDemo extends StatefulWidget { + const MouseRegionDemo({Key? key}) : super(key: key); + @override _MouseRegionDemoState createState() => _MouseRegionDemoState(); } @@ -42,7 +44,7 @@ class _MouseRegionDemoState extends State { @override Widget build(BuildContext context) { return ConstrainedBox( - constraints: BoxConstraints.tight(Size(300.0, 200.0)), + constraints: BoxConstraints.tight(const Size(300.0, 200.0)), child: MouseRegion( onEnter: _incrementEnter, onHover: _updateLocation, @@ -52,7 +54,7 @@ class _MouseRegionDemoState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text('你的鼠标移入移除信息:'), + const Text('你的鼠标移入移除信息:'), Text( '$_enterCounter Entries\n$_exitCounter Exits', style: Theme.of(context).textTheme.headline4, diff --git a/lib/widget_system/widgets/StatefulWidget/Navigator/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/Navigator/node1_base.dart index fbe547f..d2018c5 100644 --- a/lib/widget_system/widgets/StatefulWidget/Navigator/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/Navigator/node1_base.dart @@ -15,9 +15,11 @@ import 'package:flutter/material.dart'; // "【onPopPage】 : 出栈回调 【PopPageCallback】", // } class NavigatorDemo extends StatelessWidget { + const NavigatorDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, width: 300, child: Navigator( @@ -93,46 +95,48 @@ class TolyNavigatorObservers extends NavigatorObserver { } class HomeContent extends StatelessWidget { + const HomeContent({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - RaisedButton( - color: Colors.red, - onPressed: () { - Navigator.pushNamed(context, '/red'); - }, - ), - RaisedButton( - color: Colors.yellow, - onPressed: () { - Navigator.pushNamed(context, '/yellow'); - }, - ), - RaisedButton( - color: Colors.green, - onPressed: () { - Navigator.pushNamed(context, '/green'); - }, - ) - ], - ), - ], - ), + return Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + RaisedButton( + color: Colors.red, + onPressed: () { + Navigator.pushNamed(context, '/red'); + }, + ), + RaisedButton( + color: Colors.yellow, + onPressed: () { + Navigator.pushNamed(context, '/yellow'); + }, + ), + RaisedButton( + color: Colors.green, + onPressed: () { + Navigator.pushNamed(context, '/green'); + }, + ) + ], + ), + ], ); } } class RedPage extends StatelessWidget { + const RedPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text("RedPage"), + title: const Text("RedPage"), ), body: Container( color: Colors.red, @@ -146,7 +150,7 @@ class YellowPage extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text("YellowPage"), + title: const Text("YellowPage"), ), body: Container( color: Colors.yellow, @@ -156,11 +160,13 @@ class YellowPage extends StatelessWidget { } class GreenPage extends StatelessWidget { + const GreenPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text("GreenPage"), + title: const Text("GreenPage"), ), body: Container( color: Colors.green, diff --git a/lib/widget_system/widgets/StatefulWidget/NestedScrollView/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/NestedScrollView/node1_base.dart index 51b2cc6..241090f 100644 --- a/lib/widget_system/widgets/StatefulWidget/NestedScrollView/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/NestedScrollView/node1_base.dart @@ -19,11 +19,13 @@ import 'package:flutter/material.dart'; // } class NestedScrollViewDemo extends StatelessWidget { - final _tabs = ['风神传', '封妖志', "幻将录", "永恒传说"]; + final List _tabs = const ['风神传', '封妖志', "幻将录", "永恒传说"]; + + const NestedScrollViewDemo({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height - 200, child: Scaffold( diff --git a/lib/widget_system/widgets/StatefulWidget/OutlinedButton/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/OutlinedButton/node1_base.dart index 27498b8..ec7a27c 100644 --- a/lib/widget_system/widgets/StatefulWidget/OutlinedButton/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/OutlinedButton/node1_base.dart @@ -14,6 +14,8 @@ import 'package:flutter/material.dart'; // } class OutlinedButtonDemo extends StatelessWidget { + const OutlinedButtonDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Container( @@ -23,11 +25,11 @@ class OutlinedButtonDemo extends StatelessWidget { spacing: 20, children: [ OutlinedButton( - child: Text('OutlinedButton'), + child: const Text('OutlinedButton'), onPressed: _onPressed, onLongPress: _onLongPress, ), - OutlinedButton( + const OutlinedButton( child: Text('禁用按钮'), onPressed: null, onLongPress: null, @@ -36,7 +38,7 @@ class OutlinedButtonDemo extends StatelessWidget { )); } - _onPressed() {} + void _onPressed() {} - _onLongPress() {} + void _onLongPress() {} } diff --git a/lib/widget_system/widgets/StatefulWidget/OutlinedButton/node2_style.dart b/lib/widget_system/widgets/StatefulWidget/OutlinedButton/node2_style.dart index 48a97a9..6cf13aa 100644 --- a/lib/widget_system/widgets/StatefulWidget/OutlinedButton/node2_style.dart +++ b/lib/widget_system/widgets/StatefulWidget/OutlinedButton/node2_style.dart @@ -15,6 +15,8 @@ import 'package:flutter/material.dart'; // } class OutlinedButtonStyleDemo extends StatelessWidget { + const OutlinedButtonStyleDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Container( @@ -28,7 +30,7 @@ class OutlinedButtonStyleDemo extends StatelessWidget { primary: Colors.white, elevation: 2, shadowColor: Colors.orangeAccent), - child: Text('ElevatedButton样式'), + child: const Text('ElevatedButton样式'), onPressed: _onPressed, onLongPress: _onLongPress, ), @@ -36,13 +38,13 @@ class OutlinedButtonStyleDemo extends StatelessWidget { style: TextButton.styleFrom( backgroundColor: Colors.white, primary: Colors.black, - side: BorderSide(color: Colors.blue,width: 1), - shape: RoundedRectangleBorder( + side: const BorderSide(color: Colors.blue,width: 1), + shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(10)) ), // elevation: 2, shadowColor: Colors.orangeAccent), - child: Text('ElevatedButton边线'), + child: const Text('ElevatedButton边线'), autofocus: false, onPressed: _onPressed, onLongPress: _onLongPress, @@ -52,7 +54,7 @@ class OutlinedButtonStyleDemo extends StatelessWidget { ); } - _onPressed() {} + void _onPressed() {} - _onLongPress() {} + void _onLongPress() {} } diff --git a/lib/widget_system/widgets/StatefulWidget/Overlay/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/Overlay/node1_base.dart index 7ed1f85..b3479ab 100644 --- a/lib/widget_system/widgets/StatefulWidget/Overlay/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/Overlay/node1_base.dart @@ -12,25 +12,27 @@ import 'package:flutter/material.dart'; // } class CustomOverlay extends StatelessWidget { + const CustomOverlay({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Wrap( children: [ - Container( + SizedBox( height: 50, child: RawMaterialButton( elevation: 2, - shape: CircleBorder( + shape: const CircleBorder( side: BorderSide(width: 2.0, color: Color(0xFFFFDFDFDF)), ), fillColor: Colors.blue, splashColor: Colors.orange, - textStyle: TextStyle(color: Colors.white), - child: Icon(Icons.add), + textStyle: const TextStyle(color: Colors.white), + child: const Icon(Icons.add), onPressed: ()=>showFloating(context), ), ), - Container( + const SizedBox( height: 50, child: RawMaterialButton( elevation: 2, @@ -50,9 +52,10 @@ class CustomOverlay extends StatelessWidget { } bool show = false; -Offset offset = Offset(200, 200); +Offset offset = const Offset(200, 200); + +const double radius = 60; -final double radius = 60; var entry = OverlayEntry( builder: (context) => Stack( children: [ @@ -81,7 +84,7 @@ _buildFloating() => GestureDetector( height: radius, width: radius, alignment: Alignment.center, - decoration: BoxDecoration( + decoration: const BoxDecoration( shape: BoxShape.circle, image: DecorationImage( image: AssetImage('assets/images/icon_head.webp')), diff --git a/lib/widget_system/widgets/StatefulWidget/PageView/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/PageView/node1_base.dart index 5d441db..94a3341 100644 --- a/lib/widget_system/widgets/StatefulWidget/PageView/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/PageView/node1_base.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; // "【onPageChanged】 : 点击事件 【ValueChanged】", // } class CustomPageView extends StatelessWidget { + CustomPageView({Key? key}) : super(key: key); + final List data = [ Colors.green[50]!, Colors.green[100]!, @@ -26,34 +28,36 @@ class CustomPageView extends StatelessWidget { Colors.green[900]!, ]; + TextStyle get textStyle => + const TextStyle(color: Colors.white, fontSize: 24, shadows: [ + Shadow( + color: Colors.black, + offset: Offset(.5, .5), + blurRadius: 2, + ), + ]); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 150, child: PageView( - onPageChanged: (position){ - print(position); - }, + onPageChanged: (position) => print(position), children: data .map((color) => Container( - alignment: Alignment.center, - width: 90, - color: color, - child: Text( - colorString(color), - style: TextStyle(color: Colors.white, - fontSize:24,shadows: [ - Shadow( - color: Colors.black, - offset: Offset(.5, .5), - blurRadius: 2) - ]), - ), - )) + alignment: Alignment.center, + width: 90, + color: color, + child: Text( + colorString(color), + style: textStyle, + ), + )) .toList(), ), ); } + String colorString(Color color) => "#${color.value.toRadixString(16).padLeft(8, '0').toUpperCase()}"; } diff --git a/lib/widget_system/widgets/StatefulWidget/PageView/node2_direction.dart b/lib/widget_system/widgets/StatefulWidget/PageView/node2_direction.dart index ee66d31..b205622 100644 --- a/lib/widget_system/widgets/StatefulWidget/PageView/node2_direction.dart +++ b/lib/widget_system/widgets/StatefulWidget/PageView/node2_direction.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; // "【reverse】 : 是否反向 【bool】", // } class DirectionPageView extends StatelessWidget { + DirectionPageView({Key? key}) : super(key: key); + final List data = [ Colors.orange[50]!, Colors.orange[100]!, @@ -26,9 +28,18 @@ class DirectionPageView extends StatelessWidget { Colors.orange[900]!, ]; + TextStyle get textStyle => + const TextStyle(color: Colors.white, fontSize: 24, shadows: [ + Shadow( + color: Colors.black, + offset: Offset(.5, .5), + blurRadius: 2, + ), + ]); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 150, child: PageView( scrollDirection: Axis.vertical, @@ -37,22 +48,15 @@ class DirectionPageView extends StatelessWidget { print(position); }, children: data - .map((color) => - Container( - alignment: Alignment.center, - width: 90, - color: color, - child: Text( - colorString(color), - style: TextStyle(color: Colors.white, - fontSize: 24, shadows: [ - Shadow( - color: Colors.black, - offset: Offset(.5, .5), - blurRadius: 2) - ]), - ), - )) + .map((color) => Container( + alignment: Alignment.center, + width: 90, + color: color, + child: Text( + colorString(color), + style: textStyle, + ), + )) .toList(), ), ); diff --git a/lib/widget_system/widgets/StatefulWidget/PageView/node3_controller.dart b/lib/widget_system/widgets/StatefulWidget/PageView/node3_controller.dart index 048171d..b5a4b22 100644 --- a/lib/widget_system/widgets/StatefulWidget/PageView/node3_controller.dart +++ b/lib/widget_system/widgets/StatefulWidget/PageView/node3_controller.dart @@ -12,6 +12,8 @@ import 'package:flutter/material.dart'; // "【controller】 : 页面控制器 【PageController】", // } class CtrlPageView extends StatefulWidget { + const CtrlPageView({Key? key}) : super(key: key); + @override _CtrlPageViewState createState() => _CtrlPageViewState(); } @@ -45,9 +47,15 @@ class _CtrlPageViewState extends State { viewportFraction: 0.8, initialPage: (data.length/2).round() ); - } - + TextStyle get textStyle => + const TextStyle(color: Colors.white, fontSize: 24, shadows: [ + Shadow( + color: Colors.black, + offset: Offset(.5, .5), + blurRadius: 2, + ), + ]); @override Widget build(BuildContext context) { return Container( @@ -65,13 +73,7 @@ class _CtrlPageViewState extends State { color: color, child: Text( colorString(color), - style: TextStyle(color: Colors.white, - fontSize: 24, shadows: [ - Shadow( - color: Colors.black, - offset: Offset(.5, .5), - blurRadius: 2) - ]), + style: textStyle, ), )) .toList(), diff --git a/lib/widget_system/widgets/StatefulWidget/PaginatedDataTable/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/PaginatedDataTable/node1_base.dart index 591fc71..e7e516d 100644 --- a/lib/widget_system/widgets/StatefulWidget/PaginatedDataTable/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/PaginatedDataTable/node1_base.dart @@ -22,6 +22,8 @@ import 'package:flutter/material.dart'; // "【source】 : 数据源 【DataTableSource】", // } class PaginatedDataTableDemo extends StatefulWidget { + const PaginatedDataTableDemo({Key? key}) : super(key: key); + @override State createState() => _PaginatedDataTableDemoState(); } @@ -35,7 +37,10 @@ class _PaginatedDataTableDemoState extends State { final DessertDataSource _dessertsDataSource = DessertDataSource(); void sort( - Comparable getField(HeroInfo d), int columnIndex, bool ascending) { + Comparable Function(HeroInfo d) getField, + int columnIndex, + bool ascending, + ) { _dessertsDataSource.sort(getField, ascending); setState(() { _sortColumnIndex = columnIndex; @@ -45,12 +50,12 @@ class _PaginatedDataTableDemoState extends State { @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 300, width: 350, child: SingleChildScrollView( child: PaginatedDataTable( - actions: [ + actions: const [ IconButton(icon: Icon(Icons.add), onPressed: null), ], header: const Text( @@ -58,7 +63,7 @@ class _PaginatedDataTableDemoState extends State { style: TextStyle(color: Colors.blue), ), rowsPerPage: _rowsPerPage, - availableRowsPerPage: [5, 8, 10, 15], + availableRowsPerPage: const [5, 8, 10, 15], onRowsPerPageChanged: (int? value) { setState(() { _rowsPerPage = value ?? 0; @@ -105,7 +110,7 @@ class HeroInfo { } class DessertDataSource extends DataTableSource { - final List _desserts = [ + final List _desserts = [ HeroInfo('捷特', '《幻将录》', "人族", "男"), HeroInfo('龙少', '《幻将录》', "人族", "男"), HeroInfo('巫缨', '《幻将录》', "人族", "女"), @@ -158,7 +163,10 @@ class DessertDataSource extends DataTableSource { HeroInfo('古千缘', '《幻将录》', "人族", "男"), ]; - void sort(Comparable getField(HeroInfo d), bool ascending) { + void sort( + Comparable Function(HeroInfo d) getField, + bool ascending, + ) { _desserts.sort((HeroInfo a, HeroInfo b) { if (!ascending) { final HeroInfo c = a; diff --git a/lib/widget_system/widgets/StatefulWidget/PopupMenuButton/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/PopupMenuButton/node1_base.dart index 5426332..2bdf509 100644 --- a/lib/widget_system/widgets/StatefulWidget/PopupMenuButton/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/PopupMenuButton/node1_base.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; + import '../../../../components/project/dialogs/dialog_about.dart'; /// create by 张风捷特烈 on 2020-03-16 @@ -19,12 +20,14 @@ import '../../../../components/project/dialogs/dialog_about.dart'; // "【onSelected】 : 选择事件 【Function(T)】", // } class CustomPopupMenuButton extends StatefulWidget { + const CustomPopupMenuButton({Key? key}) : super(key: key); + @override _CustomPopupMenuButtonState createState() => _CustomPopupMenuButtonState(); } class _CustomPopupMenuButtonState extends State { - final map = { + final Map map = const { "关于": Icons.info_outline, "帮助": Icons.help_outline, "问题反馈": Icons.add_comment, @@ -34,10 +37,10 @@ class _CustomPopupMenuButtonState extends State { Widget build(BuildContext context) { return PopupMenuButton( itemBuilder: (context) => buildItems(), - offset: Offset(0, 50), - color: Color(0xffF4FFFA), + offset: const Offset(0, 50), + color: const Color(0xffF4FFFA), elevation: 1, - shape: RoundedRectangleBorder( + shape: const RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(20), bottomRight: Radius.circular(20), @@ -62,10 +65,7 @@ class _CustomPopupMenuButtonState extends State { child: Wrap( spacing: 10, children: [ - Icon( - map[e], - color: Colors.blue, - ), + Icon(map[e], color: Colors.blue), Text(e), ], ))) diff --git a/lib/widget_system/widgets/StatefulWidget/PopupMenuDivider/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/PopupMenuDivider/node1_base.dart index b87d1d5..debaaa4 100644 --- a/lib/widget_system/widgets/StatefulWidget/PopupMenuDivider/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/PopupMenuDivider/node1_base.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; + import '../../../../components/project/dialogs/dialog_about.dart'; /// create by 张风捷特烈 on 2020-03-29 @@ -12,7 +13,9 @@ import '../../../../components/project/dialogs/dialog_about.dart'; // "【height】 : 高度 【double】", // } class CustomPopupMenuDivider extends StatelessWidget { - final map = { + const CustomPopupMenuDivider({Key? key}) : super(key: key); + + final Map map = const { "关于": Icons.info_outline, "帮助": Icons.help_outline, "问题反馈": Icons.add_comment, @@ -20,41 +23,39 @@ class CustomPopupMenuDivider extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - child: Column( - children: [ - _buildPopupMenuButton(context), - PopupMenuDivider(), - ], - ), + return Column( + children: [ + _buildPopupMenuButton(context), + const PopupMenuDivider(), + ], ); } PopupMenuButton _buildPopupMenuButton(BuildContext context) { return PopupMenuButton( - itemBuilder: (context) => [ - ...buildItems().sublist(0, 2), - PopupMenuDivider(), - ...buildItems().sublist(2, 3) - ], - offset: Offset(0, 50), - color: Color(0xffF4FFFA), - elevation: 1, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(20), - bottomRight: Radius.circular(20), - topRight: Radius.circular(5), - bottomLeft: Radius.circular(5), - )), - onSelected: (e) { - print(e); - if (e == '关于') { - DialogAbout.show(context); - } - }, - onCanceled: () => print('onCanceled'), - ); + itemBuilder: (context) => [ + ...buildItems().sublist(0, 2), + const PopupMenuDivider(), + ...buildItems().sublist(2, 3) + ], + offset: const Offset(0, 50), + color: const Color(0xffF4FFFA), + elevation: 1, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(20), + bottomRight: Radius.circular(20), + topRight: Radius.circular(5), + bottomLeft: Radius.circular(5), + )), + onSelected: (e) { + print(e); + if (e == '关于') { + DialogAbout.show(context); + } + }, + onCanceled: () => print('onCanceled'), + ); } List> buildItems() { @@ -65,10 +66,7 @@ class CustomPopupMenuDivider extends StatelessWidget { child: Wrap( spacing: 10, children: [ - Icon( - map[e], - color: Colors.blue, - ), + Icon(map[e], color: Colors.blue), Text(e), ], ))) diff --git a/lib/widget_system/widgets/StatefulWidget/PositionedTransition/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/PositionedTransition/node1_base.dart index 8f78f53..d90763a 100644 --- a/lib/widget_system/widgets/StatefulWidget/PositionedTransition/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/PositionedTransition/node1_base.dart @@ -12,6 +12,8 @@ import 'package:flutter/material.dart'; // " PositionedTransition组件只能在Stack内起作用", // } class CustomPositionedTransition extends StatefulWidget { + const CustomPositionedTransition({Key? key}) : super(key: key); + @override _CustomPositionedTransitionState createState() => _CustomPositionedTransitionState(); @@ -23,7 +25,10 @@ class _CustomPositionedTransitionState extends State @override void initState() { - _ctrl = AnimationController(vsync: this, duration: Duration(seconds: 2)); + _ctrl = AnimationController( + vsync: this, + duration: const Duration(seconds: 2), + ); _ctrl.forward(); super.initState(); } @@ -46,10 +51,10 @@ class _CustomPositionedTransitionState extends State children: [ PositionedTransition( rect: RelativeRectTween( - begin: RelativeRect.fromLTRB(0, 50, 150, 100), - end: RelativeRect.fromLTRB(60, 0, 150, -50), + begin: const RelativeRect.fromLTRB(0, 50, 150, 100), + end: const RelativeRect.fromLTRB(60, 0, 150, -50), ).animate(_ctrl), - child: Icon( + child: const Icon( Icons.android, color: Colors.green, size: 50, diff --git a/lib/widget_system/widgets/StatefulWidget/Radio/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/Radio/node1_base.dart index 9486e99..b200584 100644 --- a/lib/widget_system/widgets/StatefulWidget/Radio/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/Radio/node1_base.dart @@ -14,6 +14,8 @@ import 'package:flutter/material.dart'; // "【onChanged】 : 改变时回调 【Function(T)】", // } class CustomRadio extends StatefulWidget { + const CustomRadio({Key? key}) : super(key: key); + @override _CustomRadioState createState() => _CustomRadioState(); } diff --git a/lib/widget_system/widgets/StatefulWidget/RangeSlider/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/RangeSlider/node1_base.dart index 9dacc40..5596953 100644 --- a/lib/widget_system/widgets/StatefulWidget/RangeSlider/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/RangeSlider/node1_base.dart @@ -19,12 +19,14 @@ import 'package:flutter/material.dart'; // "【onChanged】 : 改变时回调 【Function(RangeValues)】", // } class CustomRangeSlider extends StatefulWidget { + const CustomRangeSlider({Key? key}) : super(key: key); + @override _CustomRangeSliderState createState() => _CustomRangeSliderState(); } class _CustomRangeSliderState extends State { - RangeValues _rangeValues = RangeValues(90, 270); + RangeValues _rangeValues = const RangeValues(90, 270); @override Widget build(BuildContext context) { @@ -33,8 +35,8 @@ class _CustomRangeSliderState extends State { divisions: 180, min: 0.0, max: 360.0, - labels: RangeLabels("${_rangeValues.start.toStringAsFixed(1)}", - "${_rangeValues.end.toStringAsFixed(1)}"), + labels: RangeLabels(_rangeValues.start.toStringAsFixed(1), + _rangeValues.end.toStringAsFixed(1)), activeColor: Colors.orangeAccent, inactiveColor: Colors.green.withAlpha(99), onChangeStart: (value) { diff --git a/lib/widget_system/widgets/StatefulWidget/RawChip/node1_press.dart b/lib/widget_system/widgets/StatefulWidget/RawChip/node1_press.dart index 9b3938c..6b1ad03 100644 --- a/lib/widget_system/widgets/StatefulWidget/RawChip/node1_press.dart +++ b/lib/widget_system/widgets/StatefulWidget/RawChip/node1_press.dart @@ -20,19 +20,19 @@ import 'package:flutter/material.dart'; // "【onPressed】 : 点击事件 【Function()】", // } class PressRawChip extends StatelessWidget { + const PressRawChip({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( - child: RawChip( - padding: EdgeInsets.all(5), - labelPadding: EdgeInsets.all(3), - label: Text('张风捷特烈'), - avatar: Image.asset("assets/images/icon_head.webp"), - elevation: 3, - pressElevation: 5, - shadowColor: Colors.orangeAccent, - onPressed: () => Navigator.of(context).pushNamed('AboutMePage'), - ), + return RawChip( + padding: const EdgeInsets.all(5), + labelPadding: const EdgeInsets.all(3), + label: const Text('张风捷特烈'), + avatar: Image.asset("assets/images/icon_head.webp"), + elevation: 3, + pressElevation: 5, + shadowColor: Colors.orangeAccent, + onPressed: () => Navigator.of(context).pushNamed('AboutMePage'), ); } } diff --git a/lib/widget_system/widgets/StatefulWidget/RawChip/node2_select.dart b/lib/widget_system/widgets/StatefulWidget/RawChip/node2_select.dart index e4fc3b1..987a87a 100644 --- a/lib/widget_system/widgets/StatefulWidget/RawChip/node2_select.dart +++ b/lib/widget_system/widgets/StatefulWidget/RawChip/node2_select.dart @@ -18,6 +18,8 @@ import 'package:flutter/material.dart'; // "【onDeleted】 : 尾部事件 【Function()】", // } class SelectRawChip extends StatefulWidget { + const SelectRawChip({Key? key}) : super(key: key); + @override _SelectRawChipState createState() => _SelectRawChipState(); } @@ -26,21 +28,19 @@ class _SelectRawChipState extends State { bool _selected = false; @override Widget build(BuildContext context) { - return Container( - child: RawChip( - selected: _selected, - padding: EdgeInsets.all(5), - labelPadding: EdgeInsets.all(3), - deleteIconColor: Colors.red, - selectedColor: Colors.orangeAccent.withAlpha(44), - label: Text('张风捷特烈'), - avatar: Image.asset("assets/images/icon_head.webp"), - elevation: 3, - pressElevation: 5, - shadowColor: Colors.orangeAccent, - onSelected: (v)=> setState(() => _selected=v), - onDeleted: () => Navigator.of(context).pushNamed('AboutMePage'), - ), + return RawChip( + selected: _selected, + padding: const EdgeInsets.all(5), + labelPadding: const EdgeInsets.all(3), + deleteIconColor: Colors.red, + selectedColor: Colors.orangeAccent.withAlpha(44), + label: const Text('张风捷特烈'), + avatar: Image.asset("assets/images/icon_head.webp"), + elevation: 3, + pressElevation: 5, + shadowColor: Colors.orangeAccent, + onSelected: (v)=> setState(() => _selected=v), + onDeleted: () => Navigator.of(context).pushNamed('AboutMePage'), ); } } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatefulWidget/RawGestureDetector/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/RawGestureDetector/node1_base.dart index f493088..948f31c 100644 --- a/lib/widget_system/widgets/StatefulWidget/RawGestureDetector/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/RawGestureDetector/node1_base.dart @@ -16,6 +16,8 @@ import 'package:flutter/material.dart'; // } class RawGestureDetectorDemo extends StatefulWidget { + const RawGestureDetectorDemo({Key? key}) : super(key: key); + @override _RawGestureDetectorDemoState createState() => _RawGestureDetectorDemoState(); } diff --git a/lib/widget_system/widgets/StatefulWidget/RawKeyboardListener/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/RawKeyboardListener/node1_base.dart index 5dc1495..dbd4624 100644 --- a/lib/widget_system/widgets/StatefulWidget/RawKeyboardListener/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/RawKeyboardListener/node1_base.dart @@ -17,6 +17,8 @@ import 'package:flutter/services.dart'; // } class RawKeyboardListenerDemo extends StatefulWidget { + const RawKeyboardListenerDemo({Key? key}) : super(key: key); + @override _RawKeyboardListenerDemoState createState() => _RawKeyboardListenerDemoState(); } @@ -31,20 +33,19 @@ class _RawKeyboardListenerDemoState extends State { return RawKeyboardListener( focusNode: node, onKey: _onKey, - - child: Container( + child: SizedBox( width: 300, child: Row( children: [ - Expanded( + const Expanded( child: TextField( decoration: InputDecoration( border: OutlineInputBorder() ), ), ), - SizedBox(width: 20,), - Text('$_info') + const SizedBox(width: 20,), + Text(_info) ], ), ), diff --git a/lib/widget_system/widgets/StatefulWidget/RawMaterialButton/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/RawMaterialButton/node1_base.dart index f213fe8..6946852 100644 --- a/lib/widget_system/widgets/StatefulWidget/RawMaterialButton/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/RawMaterialButton/node1_base.dart @@ -18,42 +18,42 @@ import 'package:flutter/material.dart'; // "【onPressed】 : 点击事件 【Function()】", // } class CustomRawMaterialButton extends StatelessWidget { + const CustomRawMaterialButton({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( - child: Wrap( - spacing: 20, - children: [ - RawMaterialButton( - elevation: 2, - fillColor: Colors.green, - splashColor: Colors.orange, - textStyle: TextStyle(color: Colors.white), - onLongPress: ()=>print('onLongPress'), - child: Icon(Icons.remove), - onPressed: ()=>print('onPressed'), - ), - RawMaterialButton( - elevation: 2, - fillColor: Colors.blue, - splashColor: Colors.orange, - textStyle: TextStyle(color: Colors.white), - onLongPress: ()=>print('onLongPress'), - child: Text('Push'), - onPressed: ()=>print('onPressed'), - ), - RawMaterialButton( - elevation: 2, - fillColor: Colors.red, - splashColor: Colors.orange, - textStyle: TextStyle(color: Colors.white), - onLongPress: ()=>print('onLongPress'), - child: Icon(Icons.add), - onPressed: ()=>print('onPressed'), - ), + return Wrap( + spacing: 20, + children: [ + RawMaterialButton( + elevation: 2, + fillColor: Colors.green, + splashColor: Colors.orange, + textStyle: const TextStyle(color: Colors.white), + onLongPress: ()=>print('onLongPress'), + child: const Icon(Icons.remove), + onPressed: ()=>print('onPressed'), + ), + RawMaterialButton( + elevation: 2, + fillColor: Colors.blue, + splashColor: Colors.orange, + textStyle: const TextStyle(color: Colors.white), + onLongPress: ()=>print('onLongPress'), + child: const Text('Push'), + onPressed: ()=>print('onPressed'), + ), + RawMaterialButton( + elevation: 2, + fillColor: Colors.red, + splashColor: Colors.orange, + textStyle: const TextStyle(color: Colors.white), + onLongPress: ()=>print('onLongPress'), + child: const Icon(Icons.add), + onPressed: ()=>print('onPressed'), + ), - ], - ), + ], ); } } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatefulWidget/RawMaterialButton/node2_shape.dart b/lib/widget_system/widgets/StatefulWidget/RawMaterialButton/node2_shape.dart index 41a678a..683084f 100644 --- a/lib/widget_system/widgets/StatefulWidget/RawMaterialButton/node2_shape.dart +++ b/lib/widget_system/widgets/StatefulWidget/RawMaterialButton/node2_shape.dart @@ -13,51 +13,50 @@ import 'package:flutter/material.dart'; // "【shape】 : 形状 【ShapeBorder】", // } class ShapeRawMaterialButton extends StatelessWidget { + const ShapeRawMaterialButton({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( - child: Wrap( - spacing: 20, - children: [ - RawMaterialButton( - elevation: 2, - shape: CircleBorder( - side: BorderSide(width: 2.0, color: Color(0xFFFFDFDFDF)), - ), - fillColor: Colors.green, - splashColor: Colors.orange, - textStyle: TextStyle(color: Colors.white), - onLongPress: ()=>print('onLongPress'), - child: Icon(Icons.remove), - onPressed: ()=>print('onPressed'), + return Wrap( + spacing: 20, + children: [ + RawMaterialButton( + elevation: 2, + shape: const CircleBorder( + side: BorderSide(width: 2.0, color: Color(0xFFFFDFDFDF)), ), - RawMaterialButton( - shape:RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(15))), - elevation: 0, - highlightElevation: 0, - fillColor: Colors.blue, - splashColor: Colors.orange, - textStyle: TextStyle(color: Colors.white), - onLongPress: ()=>print('onLongPress'), - child: Text('Push'), - onPressed: ()=>print('onPressed'), + fillColor: Colors.green, + splashColor: Colors.orange, + textStyle: const TextStyle(color: Colors.white), + onLongPress: () => print('onLongPress'), + child: const Icon(Icons.remove), + onPressed: () => print('onPressed'), + ), + RawMaterialButton( + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(15))), + elevation: 0, + highlightElevation: 0, + fillColor: Colors.blue, + splashColor: Colors.orange, + textStyle: const TextStyle(color: Colors.white), + onLongPress: () => print('onLongPress'), + child: const Text('Push'), + onPressed: () => print('onPressed'), + ), + RawMaterialButton( + elevation: 2, + shape: const CircleBorder( + side: BorderSide(width: 2.0, color: Color(0xFFFFDFDFDF)), ), - RawMaterialButton( - elevation: 2, - shape: CircleBorder( - side: BorderSide(width: 2.0, color: Color(0xFFFFDFDFDF)), - ), - fillColor: Colors.red, - splashColor: Colors.orange, - textStyle: TextStyle(color: Colors.white), - onLongPress: ()=>print('onLongPress'), - child: Icon(Icons.add), - onPressed: ()=>print('onPressed'), - ), - - ], - ), + fillColor: Colors.red, + splashColor: Colors.orange, + textStyle: const TextStyle(color: Colors.white), + onLongPress: () => print('onLongPress'), + child: const Icon(Icons.add), + onPressed: () => print('onPressed'), + ), + ], ); } } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatefulWidget/RefreshIndicator/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/RefreshIndicator/node1_base.dart index a3c25c8..4212dc1 100644 --- a/lib/widget_system/widgets/StatefulWidget/RefreshIndicator/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/RefreshIndicator/node1_base.dart @@ -14,6 +14,8 @@ import 'package:flutter/material.dart'; // "【onRefresh】 : 异步函数 【Future Function()】" // } class CustomRefreshIndicator extends StatefulWidget { + const CustomRefreshIndicator({Key? key}) : super(key: key); + @override _CustomRefreshIndicatorState createState() => _CustomRefreshIndicatorState(); } @@ -23,8 +25,7 @@ class _CustomRefreshIndicatorState extends State { @override Widget build(BuildContext context) { - - return Container( + return SizedBox( height: 200, width: 200, child: RefreshIndicator( @@ -46,7 +47,7 @@ class _CustomRefreshIndicatorState extends State { } Future _increment() async { - await Future.delayed(Duration(seconds: 2)); + await Future.delayed(const Duration(seconds: 2)); setState(() { _count++; }); diff --git a/lib/widget_system/widgets/StatefulWidget/RelativePositionedTransition/node1_base.dart b/lib/widget_system/widgets/StatefulWidget/RelativePositionedTransition/node1_base.dart index dcbd292..bc9883e 100644 --- a/lib/widget_system/widgets/StatefulWidget/RelativePositionedTransition/node1_base.dart +++ b/lib/widget_system/widgets/StatefulWidget/RelativePositionedTransition/node1_base.dart @@ -14,6 +14,8 @@ import 'package:flutter/material.dart'; // " PositionedTransition组件只能在Stack内起作用", // } class CustomRelativePositionedTransition extends StatefulWidget { + const CustomRelativePositionedTransition({Key? key}) : super(key: key); + @override _CustomRelativePositionedTransitionState createState() => _CustomRelativePositionedTransitionState(); @@ -24,14 +26,17 @@ class _CustomRelativePositionedTransitionState with SingleTickerProviderStateMixin { late AnimationController _ctrl; late Animation rectAnimation; + @override void initState() { - _ctrl = AnimationController(vsync: this, duration: const Duration(seconds: 2)); + _ctrl = AnimationController( + vsync: this, + duration: const Duration(seconds: 2), + ); rectAnimation = RectTween( - begin: Rect.fromLTRB(0, 0, 50, 50), - end: Rect.fromLTRB(0, 0, 50, 50).translate(100, 50), + begin: const Rect.fromLTRB(0, 0, 50, 50), + end: const Rect.fromLTRB(0, 0, 50, 50).translate(100, 50), ).animate(_ctrl); - _ctrl.forward(); super.initState(); } @@ -53,9 +58,9 @@ class _CustomRelativePositionedTransitionState child: Stack( children: [ RelativePositionedTransition( - size: Size(200, 100), + size: const Size(200, 100), rect: rectAnimation as Animation, - child: Icon( + child: const Icon( Icons.android, color: Colors.green, size: 50, diff --git a/lib/widget_system/widgets/StatelessWidget/AboutDialog/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/AboutDialog/node1_base.dart index 4d717ab..8f0504a 100644 --- a/lib/widget_system/widgets/StatelessWidget/AboutDialog/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/AboutDialog/node1_base.dart @@ -3,21 +3,11 @@ /// 说明: /// -// { -// "widgetId": 130, -// "name": 'AboutDialog基本使用', -// "priority": 1, -// "subtitle": -// "【applicationIcon】 : 左上图标 【Widget】\n" -// "【applicationVersion】 : 版本号 【String】\n" -// "【applicationName】 : 应用名 【String】\n" -// "【applicationLegalese】 : 应用律术 【String】\n" -// "【children】 : 子组件列表 【List】", -// } - import 'package:flutter/material.dart'; class CustomAboutDialog extends StatelessWidget { + const CustomAboutDialog({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Stack( @@ -29,13 +19,13 @@ class CustomAboutDialog extends StatelessWidget { } Widget _buildRaisedButton(BuildContext context) => RaisedButton( - shape: RoundedRectangleBorder( + shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(10))), color: Colors.blue, onPressed: () { showDialog(context: context, builder: (ctx) => _buildAboutDialog()); }, - child: Text( + child: const Text( 'Just Show It', style: TextStyle(color: Colors.white), ), @@ -43,25 +33,29 @@ class CustomAboutDialog extends StatelessWidget { AboutDialog _buildAboutDialog() { return AboutDialog( - applicationIcon: FlutterLogo(), + applicationIcon: const FlutterLogo(), applicationVersion: 'v0.0.1', applicationName: 'Flutter Unit', applicationLegalese: 'Copyright© 2018-2020 张风捷特烈', children: [ Container( - margin: EdgeInsets.only(top: 20), + margin: const EdgeInsets.only(top: 20), width: 80, height: 80, child: Image.asset('assets/images/icon_head.webp')), Container( - margin: EdgeInsets.only(top: 10), + margin: const EdgeInsets.only(top: 10), alignment: Alignment.center, - child: Text( + child: const Text( 'The King Of Coder.', - style: TextStyle(color: Colors.white, fontSize: 20, shadows: [ - Shadow( - color: Colors.blue, offset: Offset(.5, .5), blurRadius: 3) - ]), + style: TextStyle( + color: Colors.white, + fontSize: 20, + shadows: [ + Shadow( + color: Colors.blue, offset: Offset(.5, .5), blurRadius: 3) + ], + ), )) ], ); diff --git a/lib/widget_system/widgets/StatelessWidget/AboutListTile/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/AboutListTile/node1_base.dart index cd908a7..3d05770 100644 --- a/lib/widget_system/widgets/StatelessWidget/AboutListTile/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/AboutListTile/node1_base.dart @@ -19,17 +19,19 @@ import 'package:flutter/material.dart'; class AboutListTileDemo extends StatelessWidget { + const AboutListTileDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return AboutListTile( - icon: Icon(Icons.info), - applicationIcon: FlutterLogo(), + return const AboutListTile( + icon: Icon(Icons.info), + applicationIcon: FlutterLogo(), applicationName: 'Flutter Unit', applicationVersion: 'v0.0.1', applicationLegalese: 'Copyright© 2018-2020 张风捷特烈', aboutBoxChildren: [ - Padding( - padding: const EdgeInsets.all(10.0), + Padding( + padding: EdgeInsets.all(10.0), child: Text( ' FlutterUnit是【张风捷特烈】的开源项目,' '收录Flutter的200+组件,并附加详细介绍以及操作交互,' diff --git a/lib/widget_system/widgets/StatelessWidget/ActionChip/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/ActionChip/node1_base.dart index 33fe1b1..2c487d9 100644 --- a/lib/widget_system/widgets/StatelessWidget/ActionChip/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/ActionChip/node1_base.dart @@ -19,12 +19,14 @@ import '../../../../components/project/dialogs/dialog_about.dart'; class CustomActionChip extends StatelessWidget { + const CustomActionChip({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return ActionChip( - padding: EdgeInsets.all(5), - labelPadding: EdgeInsets.all(3), - label: Text("This is a ActionChip."), + padding: const EdgeInsets.all(5), + labelPadding: const EdgeInsets.all(3), + label: const Text("This is a ActionChip."), backgroundColor: Colors.grey.withAlpha(66), avatar: Image.asset("assets/images/icon_head.webp"), shadowColor: Colors.orangeAccent, diff --git a/lib/widget_system/widgets/StatelessWidget/AlertDialog/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/AlertDialog/node1_base.dart index 3477382..5341b64 100644 --- a/lib/widget_system/widgets/StatelessWidget/AlertDialog/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/AlertDialog/node1_base.dart @@ -24,6 +24,8 @@ import 'package:flutter/material.dart'; class CustomAlertDialog extends StatelessWidget { + const CustomAlertDialog({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Column( @@ -35,38 +37,38 @@ class CustomAlertDialog extends StatelessWidget { } Widget _buildRaisedButton(BuildContext context) => RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(10))), + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(const Radius.circular(10))), color: Colors.blue, onPressed: () { showDialog(context: context, builder: (ctx) => _buildAlertDialog()); }, - child: Text( + child: const Text( 'Just Show It !', - style: TextStyle(color: Colors.white), + style: const TextStyle(color: Colors.white), ), ); Widget _buildAlertDialog() { return AlertDialog( title: _buildTitle(), - titleTextStyle: TextStyle(fontSize: 20, color: Colors.black), - titlePadding: EdgeInsets.only( + titleTextStyle: const TextStyle(fontSize: 20, color: Colors.black), + titlePadding: const EdgeInsets.only( top: 5, left: 20, ), - contentPadding: EdgeInsets.symmetric(horizontal: 5), + contentPadding: const EdgeInsets.symmetric(horizontal: 5), backgroundColor: Colors.white, content: _buildContent(), - actions: [ + actions: const [ Icon(Icons.android, color: Colors.blue,), Icon(Icons.add, color: Colors.blue,), Icon(Icons.g_translate, color: Colors.blue,), Icon(Icons.games, color: Colors.blue,), ], elevation: 4, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(10))), + shape: const RoundedRectangleBorder( + borderRadius: const BorderRadius.all(Radius.circular(10))), ); } @@ -79,23 +81,23 @@ class CustomAlertDialog extends StatelessWidget { width: 30, height: 30, ), - SizedBox(width: 10,), - Expanded( - child: Text( + const SizedBox(width: 10,), + const Expanded( + child: Text( "关于", style: TextStyle(fontSize: 18), )), - CloseButton() + const CloseButton() ], ); } Widget _buildContent() { - return Column( + return Column( mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: const EdgeInsets.all(10.0), + children: const [ + Padding( + padding: EdgeInsets.all(10.0), child: Text( ' FlutterUnit是【张风捷特烈】的开源项目,' '收录Flutter的200+组件,并附加详细介绍以及操作交互,' diff --git a/lib/widget_system/widgets/StatelessWidget/AnimatedIcon/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/AnimatedIcon/node1_base.dart index 496faae..d60b342 100644 --- a/lib/widget_system/widgets/StatelessWidget/AnimatedIcon/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/AnimatedIcon/node1_base.dart @@ -5,6 +5,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class CustomAnimatedIcon extends StatefulWidget { + const CustomAnimatedIcon({Key? key}) : super(key: key); + @override _CustomAnimatedIconState createState() => _CustomAnimatedIconState(); } @@ -15,7 +17,7 @@ class _CustomAnimatedIconState extends State @override void initState() { - _ctrl = AnimationController(vsync: this, duration: Duration(seconds: 1)); + _ctrl = AnimationController(vsync: this, duration: const Duration(seconds: 1)); _ctrl.forward(); super.initState(); } diff --git a/lib/widget_system/widgets/StatelessWidget/BackButton/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/BackButton/node1_base.dart index 5339c7c..faa00a3 100755 --- a/lib/widget_system/widgets/StatelessWidget/BackButton/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/BackButton/node1_base.dart @@ -1,27 +1,26 @@ /// create by 张风捷特烈 on 2020/4/25 /// contact me by email 1981462002@qq.com /// 说明: - -// { -// "widgetId": 31, -// "priority": 1, -// "name": "BackButton属性", -// "subtitle": "【color】: 颜色 【Color】\n" -// "【onPressed】: 点击事件 【Function】\n" -// " onPressed为空会退出当前栈", -// } - import 'package:flutter/material.dart'; class CustomBackButton extends StatelessWidget { + CustomBackButton({Key? key}) : super(key: key); + + final List data = [ + Colors.red, + Colors.yellow, + Colors.blue, + Colors.green + ]; + @override Widget build(BuildContext context) { - var data = [Colors.red,Colors.yellow,Colors.blue,Colors.green]; return Wrap( - spacing: 10, - children: data.map((e)=>BackButton( - color: e, - )).toList() - ); + spacing: 10, + children: data + .map((e) => BackButton( + color: e, + )) + .toList()); } } diff --git a/lib/widget_system/widgets/StatelessWidget/Banner/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/Banner/node1_base.dart index 7d0811b..7696317 100644 --- a/lib/widget_system/widgets/StatelessWidget/Banner/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/Banner/node1_base.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; class CustomBanner extends StatelessWidget { + CustomBanner({Key? key}) : super(key: key); final Map data = { BannerLocation.topStart: Colors.red, @@ -19,18 +20,20 @@ class CustomBanner extends StatelessWidget { runSpacing: 10, children: data.keys .map((BannerLocation location) => Container( - color: Color(0xffD8F5FF), + color: const Color(0xffD8F5FF), width: 150, - height: 150 * 0.618, - child: Banner( - message: "Flutter 2.2.3发布", - location: location, - color: data[location]!, - child: Padding( - padding: EdgeInsets.all(20), - child: FlutterLogo(textColor: Colors.blue, - style: FlutterLogoStyle.horizontal,)), - ), - )).toList()); + height: 150 * 0.618, + child: Banner( + message: "Flutter 2.2.3发布", + location: location, + color: data[location]!, + child: const Padding( + padding: EdgeInsets.all(20), + child: FlutterLogo( + textColor: Colors.blue, + style: FlutterLogoStyle.horizontal, + )), + ), + )).toList()); } } diff --git a/lib/widget_system/widgets/StatelessWidget/BottomSheet/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/BottomSheet/node1_base.dart index eb7a774..337cad1 100644 --- a/lib/widget_system/widgets/StatelessWidget/BottomSheet/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/BottomSheet/node1_base.dart @@ -3,21 +3,11 @@ /// create by 张风捷特烈 on 2020-03-25 /// contact me by email 1981462002@qq.com /// 说明: -// { -// "widgetId": 142, -// "name": 'BottomSheet基本使用', -// "priority": 1, -// "subtitle": -// "【builder】 : 组件构造器 【WidgetBuilder】\n" -// "【backgroundColor】 : 背景色 【Color】\n" -// "【elevation】 : 影深 【double】\n" -// "【shape】 : 形状 【ShapeBorder】\n" -// "【onClosing】 : 关闭回调 【Function()】", -// } - import 'package:flutter/material.dart'; class CustomBottomSheet extends StatefulWidget { + const CustomBottomSheet({Key? key}) : super(key: key); + @override _CustomBottomSheetState createState() => _CustomBottomSheetState(); } @@ -27,36 +17,33 @@ class _CustomBottomSheetState extends State { @override Widget build(BuildContext context) { - return Container( - child: FlatButton( - color: Colors.blue, - onPressed: () { - opened = !opened; - opened - ? Scaffold.of(context) - .showBottomSheet((_) => _buildBottomSheet()) - : Navigator.of(context).pop(); - }, - child: Text( - '点我显隐BottomSheet', - style: TextStyle(color: Colors.white), - ))); + return FlatButton( + color: Colors.blue, + onPressed: () { + opened = !opened; + opened + ? Scaffold.of(context).showBottomSheet((_) => _buildBottomSheet()) + : Navigator.of(context).pop(); + }, + child: const Text( + '点我显隐BottomSheet', + style: TextStyle(color: Colors.white), + )); } Widget _buildBottomSheet() => BottomSheet( enableDrag: true, elevation: 4, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topRight: Radius.circular(60), - topLeft: Radius.circular(60), - ) - ), + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topRight: Radius.circular(60), + topLeft: Radius.circular(60), + )), backgroundColor: Colors.transparent, onClosing: () => print('onClosing'), builder: (_) => (Container( - height: 250, - decoration: BoxDecoration( + height: 250, + decoration: const BoxDecoration( image: DecorationImage( image: AssetImage('assets/images/sabar_bar.webp'), fit: BoxFit.cover), diff --git a/lib/widget_system/widgets/StatelessWidget/BoxScrollView/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/BoxScrollView/node1_base.dart index e0a79f7..afa8a1f 100644 --- a/lib/widget_system/widgets/StatelessWidget/BoxScrollView/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/BoxScrollView/node1_base.dart @@ -20,6 +20,7 @@ import 'package:flutter/material.dart'; // } class BoxScrollViewDemo extends StatelessWidget { + const BoxScrollViewDemo({Key? key}) : super(key: key); final String info = 'BoxScrollView 是 ScrollView 的子类,实现了它的抽象方法,且暴露出另一个抽象方法 buildChildLayout,返回 Sliver 家族 Widget,' @@ -27,14 +28,14 @@ class BoxScrollViewDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 300, child: Column( children: [ Container( color: Colors.blue.withOpacity(0.1), - padding: EdgeInsets.all(10), - margin: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), + margin: const EdgeInsets.all(10), child: Text(info), ), Expanded(child: MyBoxScrollView()), @@ -45,6 +46,7 @@ class BoxScrollViewDemo extends StatelessWidget { } class MyBoxScrollView extends BoxScrollView { + MyBoxScrollView({Key? key}) : super(key: key); final List data = [ Colors.purple[50]!, @@ -68,19 +70,19 @@ class MyBoxScrollView extends BoxScrollView { delegate: SliverChildBuilderDelegate( (_, int index) => Container( alignment: Alignment.center, - width: 100, - height: 50, - color: data[index], - child: Text( - colorString(data[index]), - style: TextStyle(color: Colors.white, shadows: [ - Shadow( - color: Colors.black, - offset: Offset(.5, .5), - blurRadius: 2) - ]), - ), - ), + width: 100, + height: 50, + color: data[index], + child: Text( + colorString(data[index]), + style: const TextStyle(color: Colors.white, shadows: [ + Shadow( + color: Colors.black, + offset: Offset(.5, .5), + blurRadius: 2) + ]), + ), + ), childCount: data.length), ); } diff --git a/lib/widget_system/widgets/StatelessWidget/Builder/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/Builder/node1_base.dart index 5d5ed92..263540a 100644 --- a/lib/widget_system/widgets/StatelessWidget/Builder/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/Builder/node1_base.dart @@ -13,21 +13,23 @@ import 'package:flutter/material.dart'; // } class BuilderDemo extends StatelessWidget { + const BuilderDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, child: Scaffold( appBar: AppBar( - title: Text('Builder'), + title: const Text('Builder'), ), floatingActionButton: Builder( builder: (ctx) => FloatingActionButton( onPressed: () { Scaffold.of(ctx) - .showSnackBar(SnackBar(content: Text('hello builder'))); + .showSnackBar(const SnackBar(content: Text('hello builder'))); }, - child: Icon(Icons.add), + child: const Icon(Icons.add), ), ), ), diff --git a/lib/widget_system/widgets/StatelessWidget/ButtonBar/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/ButtonBar/node1_base.dart index 74006b7..0eb070c 100755 --- a/lib/widget_system/widgets/StatelessWidget/ButtonBar/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/ButtonBar/node1_base.dart @@ -14,6 +14,8 @@ import '../../../../components/project/dialogs/dialog_about.dart'; class CustomButtonBar extends StatelessWidget { + const CustomButtonBar({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return ButtonBar( @@ -21,15 +23,15 @@ class CustomButtonBar extends StatelessWidget { children: [ RaisedButton( color: Colors.blue, - child: Text("Raised"), + child: const Text("Raised"), onPressed: () => DialogAbout.show(context)), OutlineButton( - child: Text("Outline"), + child: const Text("Outline"), onPressed: () => DialogAbout.show(context)), FlatButton( color: Colors.blue, onPressed: () => DialogAbout.show(context), - child: Text("Flat"), + child: const Text("Flat"), ) ], ); diff --git a/lib/widget_system/widgets/StatelessWidget/ButtonBar/node2_padding.dart b/lib/widget_system/widgets/StatelessWidget/ButtonBar/node2_padding.dart index 0c84a52..f35dca3 100644 --- a/lib/widget_system/widgets/StatelessWidget/ButtonBar/node2_padding.dart +++ b/lib/widget_system/widgets/StatelessWidget/ButtonBar/node2_padding.dart @@ -13,24 +13,26 @@ import '../../../../components/project/dialogs/dialog_about.dart'; // "【buttonHeight】: 高 【double】", // } class PaddingButtonBar extends StatelessWidget { + const PaddingButtonBar({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return ButtonBar( alignment: MainAxisAlignment.center, buttonHeight: 40, - buttonPadding: EdgeInsets.only(left: 15,right: 15), + buttonPadding: const EdgeInsets.only(left: 15,right: 15), children: [ RaisedButton( color: Colors.blue, - child: Text("Raised"), + child: const Text("Raised"), onPressed: () => DialogAbout.show(context)), OutlineButton( - child: Text("Outline"), + child: const Text("Outline"), onPressed: () => DialogAbout.show(context)), FlatButton( color: Colors.blue, onPressed: () => DialogAbout.show(context), - child: Text("Flat"), + child: const Text("Flat"), ) ], ); diff --git a/lib/widget_system/widgets/StatelessWidget/Card/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/Card/node1_base.dart index fca2c91..978164d 100644 --- a/lib/widget_system/widgets/StatelessWidget/Card/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/Card/node1_base.dart @@ -16,18 +16,20 @@ import 'package:flutter/material.dart'; class CustomCard extends StatelessWidget { + const CustomCard({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Card( - color: Color(0xffB3FE65), + color: const Color(0xffB3FE65), elevation: 4, - margin: EdgeInsets.all(10), + margin: const EdgeInsets.all(10), child: Container( alignment: Alignment.topLeft, width: 200, height: 0.618*200, - margin: EdgeInsets.all(10), - child: Text("Card", style: TextStyle(fontSize: 20)), + margin: const EdgeInsets.all(10), + child: const Text("Card", style: const TextStyle(fontSize: 20)), ), ); } diff --git a/lib/widget_system/widgets/StatelessWidget/Card/node2_shape.dart b/lib/widget_system/widgets/StatelessWidget/Card/node2_shape.dart index 8e2e9c9..1f280e9 100644 --- a/lib/widget_system/widgets/StatelessWidget/Card/node2_shape.dart +++ b/lib/widget_system/widgets/StatelessWidget/Card/node2_shape.dart @@ -17,17 +17,19 @@ import 'package:flutter/material.dart'; import '../../../../app/utils/pather.dart'; class ShapeCard extends StatelessWidget { + const ShapeCard({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Card( - color: Color(0xffB3FE65), + color: const Color(0xffB3FE65), elevation: 6, shape: StarShapeBorder(), child: Container( alignment: Alignment.center, width: 100, height: 100, - child: Text("Card", style: TextStyle(fontSize: 20)), + child: const Text("Card", style: TextStyle(fontSize: 20)), ), ); } diff --git a/lib/widget_system/widgets/StatelessWidget/CheckboxListTile/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/CheckboxListTile/node1_base.dart index b644f1c..8ffe39f 100644 --- a/lib/widget_system/widgets/StatelessWidget/CheckboxListTile/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/CheckboxListTile/node1_base.dart @@ -17,25 +17,27 @@ import 'package:flutter/material.dart'; class CustomCheckBoxListTile extends StatefulWidget { + const CustomCheckBoxListTile({Key? key}) : super(key: key); + @override _CustomCheckBoxListTileState createState() => _CustomCheckBoxListTileState(); } class _CustomCheckBoxListTileState extends State { - var _selected = false; + bool _selected = false; @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.all(10), + margin: const EdgeInsets.all(10), color: Colors.grey.withAlpha(22), child: CheckboxListTile( value: _selected, checkColor: Colors.yellow, activeColor: Colors.orangeAccent, secondary: Image.asset("assets/images/icon_head.webp"), - title: Text("张风捷特烈"), - subtitle: Text("@万花过尽知无物"), + title: const Text("张风捷特烈"), + subtitle: const Text("@万花过尽知无物"), onChanged: (v) => setState(() => _selected = !_selected), ), ); diff --git a/lib/widget_system/widgets/StatelessWidget/CheckboxListTile/node2_select.dart b/lib/widget_system/widgets/StatelessWidget/CheckboxListTile/node2_select.dart index dcc38d8..9b62601 100644 --- a/lib/widget_system/widgets/StatelessWidget/CheckboxListTile/node2_select.dart +++ b/lib/widget_system/widgets/StatelessWidget/CheckboxListTile/node2_select.dart @@ -12,17 +12,19 @@ import 'package:flutter/material.dart'; class SelectCheckBoxListTile extends StatefulWidget { + const SelectCheckBoxListTile({Key? key}) : super(key: key); + @override _SelectCheckBoxListTileState createState() => _SelectCheckBoxListTileState(); } class _SelectCheckBoxListTileState extends State { - var _selected = false; + bool _selected = false; @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.all(10), + margin: const EdgeInsets.all(10), color: Colors.grey.withAlpha(22), child: CheckboxListTile( value: _selected, @@ -30,8 +32,8 @@ class _SelectCheckBoxListTileState extends State { checkColor: Colors.yellow, activeColor: Colors.orangeAccent, secondary: Image.asset("assets/images/icon_head.webp"), - title: Text("张风捷特烈"), - subtitle: Text("@万花过尽知无物"), + title: const Text("张风捷特烈"), + subtitle: const Text("@万花过尽知无物"), onChanged: (v) => setState(() => _selected = !_selected), ), ); diff --git a/lib/widget_system/widgets/StatelessWidget/CheckboxListTile/node3_dense.dart b/lib/widget_system/widgets/StatelessWidget/CheckboxListTile/node3_dense.dart index 81c9888..5f990ff 100644 --- a/lib/widget_system/widgets/StatelessWidget/CheckboxListTile/node3_dense.dart +++ b/lib/widget_system/widgets/StatelessWidget/CheckboxListTile/node3_dense.dart @@ -12,17 +12,19 @@ import 'package:flutter/material.dart'; class DenseCheckBoxListTile extends StatefulWidget { + const DenseCheckBoxListTile({Key? key}) : super(key: key); + @override _DenseCheckBoxListTileState createState() => _DenseCheckBoxListTileState(); } class _DenseCheckBoxListTileState extends State { - var _selected = false; + bool _selected = false; @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.all(10), + margin: const EdgeInsets.all(10), color: Colors.grey.withAlpha(22), child: CheckboxListTile( value: _selected, @@ -30,8 +32,8 @@ class _DenseCheckBoxListTileState extends State { checkColor: Colors.yellow, activeColor: Colors.orangeAccent, secondary: Image.asset("assets/images/icon_head.webp"), - title: Text("张风捷特烈"), - subtitle: Text("@万花过尽知无物"), + title: const Text("张风捷特烈"), + subtitle: const Text("@万花过尽知无物"), onChanged: (v) => setState(() => _selected = !_selected), ), ); diff --git a/lib/widget_system/widgets/StatelessWidget/CheckedModeBanner/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/CheckedModeBanner/node1_base.dart index c42a5c8..d8764a8 100644 --- a/lib/widget_system/widgets/StatelessWidget/CheckedModeBanner/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/CheckedModeBanner/node1_base.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; // } class CheckedModeBannerDemo extends StatelessWidget { + const CheckedModeBannerDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return CheckedModeBanner( @@ -21,7 +23,7 @@ class CheckedModeBannerDemo extends StatelessWidget { width: 250, height: 150, color: Theme.of(context).primaryColor, - child: Text( + child: const Text( "CheckedModeBanner", style: TextStyle(color: Colors.white, fontSize: 20), ), diff --git a/lib/widget_system/widgets/StatelessWidget/Chip/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/Chip/node1_base.dart index 7c829f5..a0d1834 100644 --- a/lib/widget_system/widgets/StatelessWidget/Chip/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/Chip/node1_base.dart @@ -16,6 +16,8 @@ import 'package:flutter/material.dart'; class CustomChip extends StatelessWidget { + const CustomChip({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Wrap( @@ -23,11 +25,11 @@ class CustomChip extends StatelessWidget { children: [ Chip( avatar: Image.asset("assets/images/icon_head.webp"), - label: Text("张风捷特烈"), - padding: EdgeInsets.all(5), - labelPadding: EdgeInsets.all(5), + label: const Text("张风捷特烈"), + padding: const EdgeInsets.all(5), + labelPadding: const EdgeInsets.all(5), ), - Chip( + const Chip( avatar: CircleAvatar( backgroundImage: AssetImage("assets/images/wy_200x300.webp")), diff --git a/lib/widget_system/widgets/StatelessWidget/Chip/node2_color.dart b/lib/widget_system/widgets/StatelessWidget/Chip/node2_color.dart index edbc8ca..3b49e4e 100644 --- a/lib/widget_system/widgets/StatelessWidget/Chip/node2_color.dart +++ b/lib/widget_system/widgets/StatelessWidget/Chip/node2_color.dart @@ -14,6 +14,8 @@ // } import 'package:flutter/material.dart'; class ColorOfChip extends StatelessWidget { + const ColorOfChip({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Wrap( @@ -21,18 +23,18 @@ class ColorOfChip extends StatelessWidget { children: [ Chip( avatar: Image.asset("assets/images/icon_head.webp"), - label: Text("张风捷特烈"), - padding: EdgeInsets.all(5), - labelPadding: EdgeInsets.all(5), + label: const Text("张风捷特烈"), + padding: const EdgeInsets.all(5), + labelPadding: const EdgeInsets.all(5), backgroundColor: Colors.grey.withAlpha(66), shadowColor: Colors.orangeAccent, elevation: 3, ), Chip( avatar: Image.asset("assets/images/icon_head.webp"), - label: Text("张风捷特烈"), - padding: EdgeInsets.all(5), - labelPadding: EdgeInsets.all(5), + label: const Text("张风捷特烈"), + padding: const EdgeInsets.all(5), + labelPadding: const EdgeInsets.all(5), backgroundColor: Colors.cyanAccent.withAlpha(11), shadowColor: Colors.blue.withAlpha(88), elevation: 4, diff --git a/lib/widget_system/widgets/StatelessWidget/Chip/node3_delete.dart b/lib/widget_system/widgets/StatelessWidget/Chip/node3_delete.dart index d3cb711..3d0ee9c 100644 --- a/lib/widget_system/widgets/StatelessWidget/Chip/node3_delete.dart +++ b/lib/widget_system/widgets/StatelessWidget/Chip/node3_delete.dart @@ -16,13 +16,15 @@ import 'package:flutter/material.dart'; import '../../../../components/project/dialogs/dialog_about.dart'; class DeleteOfChip extends StatelessWidget { + const DeleteOfChip({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Chip( avatar: Image.asset("assets/images/icon_head.webp"), - label: Text("张风捷特烈"), - padding: EdgeInsets.all(5), - labelPadding: EdgeInsets.all(3), + label: const Text("张风捷特烈"), + padding: const EdgeInsets.all(5), + labelPadding: const EdgeInsets.all(3), backgroundColor: Colors.grey.withAlpha(66), shadowColor: Colors.orangeAccent, // deleteIcon: Icon(Icons.close,size: 18), diff --git a/lib/widget_system/widgets/StatelessWidget/ChoiceChip/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/ChoiceChip/node1_base.dart index 5c548cf..6d13644 100644 --- a/lib/widget_system/widgets/StatelessWidget/ChoiceChip/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/ChoiceChip/node1_base.dart @@ -15,6 +15,8 @@ import 'package:flutter/material.dart'; class CustomChoiceChip extends StatefulWidget { + const CustomChoiceChip({Key? key}) : super(key: key); + @override _CustomChoiceChipState createState() => _CustomChoiceChipState(); } @@ -26,13 +28,13 @@ class _CustomChoiceChipState extends State { Widget build(BuildContext context) { return ChoiceChip( selected: _select, - padding: EdgeInsets.all(5), - labelPadding: EdgeInsets.all(5), + padding: const EdgeInsets.all(5), + labelPadding: const EdgeInsets.all(5), label: Text( _select ? "You are selected it." : "This is a ChoiceChip.", - style: TextStyle(fontSize: 16), + style: const TextStyle(fontSize: 16), ), backgroundColor: Colors.grey.withAlpha(66), avatar: Image.asset("assets/images/icon_head.webp"), diff --git a/lib/widget_system/widgets/StatelessWidget/CircleAvatar/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/CircleAvatar/node1_base.dart index f1fbd0d..ff2fd14 100644 --- a/lib/widget_system/widgets/StatelessWidget/CircleAvatar/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/CircleAvatar/node1_base.dart @@ -17,9 +17,11 @@ import 'package:flutter/material.dart'; class CustomCircleAvatar extends StatelessWidget { + const CustomCircleAvatar({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return CircleAvatar( + return const CircleAvatar( radius: 50, backgroundImage: AssetImage("assets/images/wy_200x300.webp"), foregroundColor: Colors.white, diff --git a/lib/widget_system/widgets/StatelessWidget/CloseButton/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/CloseButton/node1_base.dart index b66b278..958b9f3 100755 --- a/lib/widget_system/widgets/StatelessWidget/CloseButton/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/CloseButton/node1_base.dart @@ -11,8 +11,10 @@ import 'package:flutter/material.dart'; class CustomCloseButton extends StatelessWidget { + const CustomCloseButton({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return CloseButton(); + return const CloseButton(); } } diff --git a/lib/widget_system/widgets/StatelessWidget/Container/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/Container/node1_base.dart index d7168da..178c525 100644 --- a/lib/widget_system/widgets/StatelessWidget/Container/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/Container/node1_base.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; class CustomContainer extends StatelessWidget { + const CustomContainer({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Container( diff --git a/lib/widget_system/widgets/StatelessWidget/Container/node2_child.dart b/lib/widget_system/widgets/StatelessWidget/Container/node2_child.dart index b7c78c6..c9dcba9 100644 --- a/lib/widget_system/widgets/StatelessWidget/Container/node2_child.dart +++ b/lib/widget_system/widgets/StatelessWidget/Container/node2_child.dart @@ -13,16 +13,18 @@ import 'package:flutter/material.dart'; class ContainerWithChild extends StatelessWidget { + const ContainerWithChild({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Container( alignment: Alignment.topLeft, - padding: EdgeInsets.all(20), - margin: EdgeInsets.all(10), + padding: const EdgeInsets.all(20), + margin: const EdgeInsets.all(10), width: 200, height: 200 * 0.618, color: Colors.grey.withAlpha(88), - child: Icon(Icons.android), + child: const Icon(Icons.android), ); } } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/Container/node3_alignment.dart b/lib/widget_system/widgets/StatelessWidget/Container/node3_alignment.dart index 45d690f..691c0c8 100644 --- a/lib/widget_system/widgets/StatelessWidget/Container/node3_alignment.dart +++ b/lib/widget_system/widgets/StatelessWidget/Container/node3_alignment.dart @@ -11,6 +11,8 @@ import 'package:flutter/material.dart'; class ContainerAlignment extends StatelessWidget { + const ContainerAlignment({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Container( @@ -18,7 +20,7 @@ class ContainerAlignment extends StatelessWidget { width: 200, height: 200 * 0.618, color: Colors.grey.withAlpha(88), - child: Icon( + child: const Icon( Icons.android, color: Colors.green, ), diff --git a/lib/widget_system/widgets/StatelessWidget/Container/node4_decoration.dart b/lib/widget_system/widgets/StatelessWidget/Container/node4_decoration.dart index 15423df..cb5286c 100644 --- a/lib/widget_system/widgets/StatelessWidget/Container/node4_decoration.dart +++ b/lib/widget_system/widgets/StatelessWidget/Container/node4_decoration.dart @@ -13,6 +13,7 @@ import 'package:flutter/material.dart'; class ContainerDecoration extends StatelessWidget { + ContainerDecoration({Key? key}) : super(key: key); final List rainbow = [ 0xffff0000, @@ -23,31 +24,33 @@ class ContainerDecoration extends StatelessWidget { 0xff0000FF, 0xff8B00FF ]; + final List stops = [0.0, 1 / 6, 2 / 6, 3 / 6, 4 / 6, 5 / 6, 1.0]; + @override Widget build(BuildContext context) { - return Container(//容器 + return Container( alignment: Alignment.center, width: 200, height: 200 * 0.618, - margin: EdgeInsets.all(20), - padding: EdgeInsets.all(20), + margin: const EdgeInsets.all(20), + padding: const EdgeInsets.all(20), decoration: BoxDecoration(//添加渐变色 gradient: LinearGradient( stops: stops, colors: rainbow.map((e) => Color(e)).toList()), - borderRadius: BorderRadius.only( - topLeft: Radius.circular(50), - bottomRight: Radius.circular(50)), - boxShadow: [ - BoxShadow( + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(50), + bottomRight: Radius.circular(50)), + boxShadow: const [ + BoxShadow( color: Colors.grey, - offset: Offset(1, 1), + offset: Offset(1, 1), blurRadius: 10, spreadRadius: 1), ]), - child: Text( + child: const Text( "Container", style: TextStyle(fontSize: 20), ), diff --git a/lib/widget_system/widgets/StatelessWidget/Container/node5_transform.dart b/lib/widget_system/widgets/StatelessWidget/Container/node5_transform.dart index 0d47737..f35500f 100644 --- a/lib/widget_system/widgets/StatelessWidget/Container/node5_transform.dart +++ b/lib/widget_system/widgets/StatelessWidget/Container/node5_transform.dart @@ -13,16 +13,17 @@ import 'package:flutter/material.dart'; import 'dart:math'; class ContainerTransform extends StatelessWidget { + const ContainerTransform({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Container( - //容器 alignment: Alignment.center, color: Colors.cyanAccent, width: 150, height: 150 * 0.618, transform: Matrix4.skew(-pi / 10, 0), - child: Text( + child: const Text( "Container", style: TextStyle(fontSize: 20), ), diff --git a/lib/widget_system/widgets/StatelessWidget/Container/node6_constraints.dart b/lib/widget_system/widgets/StatelessWidget/Container/node6_constraints.dart index 848262e..56b11a4 100644 --- a/lib/widget_system/widgets/StatelessWidget/Container/node6_constraints.dart +++ b/lib/widget_system/widgets/StatelessWidget/Container/node6_constraints.dart @@ -1,28 +1,23 @@ /// create by 张风捷特烈 on 2020/4/25 /// contact me by email 1981462002@qq.com /// 说明: -// { -// "widgetId": 1, -// "name": 'Container的约束性', -// "priority": 6, -// "subtitle": -// "【constraints】 : 约束 【BoxConstraints】\n " -// "会约束该区域的尺寸,不会小于指定的最小宽高,也不会大于指定的最大宽高。", -// } - import 'package:flutter/material.dart'; class ContainerConstraints extends StatelessWidget { + const ContainerConstraints({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Container( - //容器 color: Colors.blue, width: 200, height: 200 * 0.618, - constraints: BoxConstraints( - minWidth: 100, maxWidth: 150, - minHeight: 20, maxHeight: 100), + constraints: const BoxConstraints( + minWidth: 100, + maxWidth: 150, + minHeight: 20, + maxHeight: 100, + ), ); } } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/CupertinoActionSheet/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/CupertinoActionSheet/node1_base.dart index a88cc1f..d1a7703 100644 --- a/lib/widget_system/widgets/StatelessWidget/CupertinoActionSheet/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/CupertinoActionSheet/node1_base.dart @@ -17,6 +17,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class CustomCupertinoActionSheet extends StatelessWidget { + const CustomCupertinoActionSheet({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Column( @@ -32,31 +34,31 @@ class CustomCupertinoActionSheet extends StatelessWidget { Container( alignment: Alignment.bottomCenter, child: CupertinoActionSheet( - title: Text("Please chose a language"), - message: Text('the language you use in this application.'), + title: const Text("Please chose a language"), + message: const Text('the language you use in this application.'), cancelButton: CupertinoActionSheetAction( - onPressed: () => Navigator.pop(context), child: Text("Cancel")), + onPressed: () => Navigator.pop(context), child: const Text("Cancel")), actions: [ CupertinoActionSheetAction( - onPressed: () => Navigator.pop(context), child: Text('Dart')), + onPressed: () => Navigator.pop(context), child: const Text('Dart')), CupertinoActionSheetAction( - onPressed: () => Navigator.pop(context), child: Text('Java')), + onPressed: () => Navigator.pop(context), child: const Text('Java')), CupertinoActionSheetAction( - onPressed: () => Navigator.pop(context), child: Text('Kotlin')), + onPressed: () => Navigator.pop(context), child: const Text('Kotlin')), ], ), ); Widget _buildRaisedButton(BuildContext context) => RaisedButton( - shape: RoundedRectangleBorder( + shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(10))), color: Colors.blue, onPressed: () => showDialog( context: context, builder: (ctx) => _buildCupertinoActionSheet(context)), - child: Text( + child: const Text( 'Just Show It !', - style: TextStyle(color: Colors.white), + style: TextStyle(color: Colors.white), ), ); } diff --git a/lib/widget_system/widgets/StatelessWidget/CupertinoActionSheetAction/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/CupertinoActionSheetAction/node1_base.dart index bdffc84..0fc93a7 100644 --- a/lib/widget_system/widgets/StatelessWidget/CupertinoActionSheetAction/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/CupertinoActionSheetAction/node1_base.dart @@ -16,25 +16,27 @@ import 'package:flutter/material.dart'; import '../../../../components/project/dialogs/dialog_about.dart'; class CustomCupertinoActionSheetAction extends StatelessWidget { + const CustomCupertinoActionSheetAction({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Column( children: [ Container( - margin: EdgeInsets.all(5), + margin: const EdgeInsets.all(5), color: Colors.grey.withAlpha(33), child: CupertinoActionSheetAction( isDefaultAction: true, onPressed: () => DialogAbout.show(context), - child: Text('张风捷特烈')), + child: const Text('张风捷特烈')), ), Container( color: Colors.grey.withAlpha(33), - margin: EdgeInsets.all(5), + margin: const EdgeInsets.all(5), child: CupertinoActionSheetAction( isDefaultAction: false, onPressed: () => DialogAbout.show(context), - child: Text('百里·巫缨')), + child: const Text('百里·巫缨')), ), ], ); diff --git a/lib/widget_system/widgets/StatelessWidget/CupertinoAlertDialog/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/CupertinoAlertDialog/node1_base.dart index f4f9f3d..57d9450 100644 --- a/lib/widget_system/widgets/StatelessWidget/CupertinoAlertDialog/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/CupertinoAlertDialog/node1_base.dart @@ -17,6 +17,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class CustomCupertinoAlertDialog extends StatelessWidget { + const CustomCupertinoAlertDialog({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Column( @@ -28,17 +30,17 @@ class CustomCupertinoAlertDialog extends StatelessWidget { } Widget _buildRaisedButton(BuildContext context) => RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(10))), + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(10))), color: Colors.blue, onPressed: () { showDialog( context: context, builder: (ctx) => _buildCupertinoAlertDialog(context)); }, - child: Text( + child: const Text( 'Just Show It !', - style: TextStyle(color: Colors.white), + style: TextStyle(color: Colors.white), ), ); @@ -50,11 +52,11 @@ class CustomCupertinoAlertDialog extends StatelessWidget { content: _buildContent(), actions: [ CupertinoButton( - child: Text("Yes, Delete"), + child: const Text("Yes, Delete"), onPressed: () => Navigator.pop(context), ), CupertinoButton( - child: Text("Cancle"), + child: const Text("Cancle"), onPressed: () => Navigator.pop(context), ), ]), @@ -65,17 +67,17 @@ class CustomCupertinoAlertDialog extends StatelessWidget { return Row( //标题 children: [ - Icon( + const Icon( CupertinoIcons.delete_solid, color: Colors.red, ), - Expanded( + const Expanded( child: Text( 'Delete File', - style: TextStyle(color: Colors.red, fontSize: 20), + style: TextStyle(color: Colors.red, fontSize: 20), )), InkWell( - child: Icon(CupertinoIcons.clear_thick), + child: const Icon(CupertinoIcons.clear_thick), onTap: () => Navigator.pop(context), ) ]); @@ -85,11 +87,11 @@ class CustomCupertinoAlertDialog extends StatelessWidget { return Padding( padding: const EdgeInsets.only(top: 18.0), child: Column( - children: [ - Text( + children: const[ + Text( ' Hi toly! If you push the conform buttom ,' ' You will lose this file. Are you sure wand to do that?', - style: TextStyle(color: Color(0xff999999), fontSize: 16), + style: TextStyle(color: Color(0xff999999), fontSize: 16), textAlign: TextAlign.justify, ), ], diff --git a/lib/widget_system/widgets/StatelessWidget/CupertinoDialogAction/no_node1_base.dart b/lib/widget_system/widgets/StatelessWidget/CupertinoDialogAction/no_node1_base.dart index 44bd153..af2e6fe 100644 --- a/lib/widget_system/widgets/StatelessWidget/CupertinoDialogAction/no_node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/CupertinoDialogAction/no_node1_base.dart @@ -8,6 +8,8 @@ import 'package:flutter/material.dart'; /// 说明: class CustomDialog extends StatelessWidget { + const CustomDialog({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Column( @@ -22,54 +24,53 @@ class CustomDialog extends StatelessWidget { onPressed: (){ }, - child: Container( + child: SizedBox( width: 50, child: DeleteDialog(), ), ); Widget _buildRaisedButton(BuildContext context) => RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(10))), + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all( Radius.circular(10))), color: Colors.blue, onPressed: () { showDialog(context: context, builder: (ctx) => _buildDialog()); }, - child: Text( + child: const Text( 'Just Show It !', - style: TextStyle(color: Colors.white), + style: TextStyle(color: Colors.white), ), ); } class DeleteDialog extends StatelessWidget { + const DeleteDialog({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( - - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - _buildBar(context), - _buildTitle(), - _buildContent(), - _buildFooter(context), - ], - ), + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + _buildBar(context), + _buildTitle(), + _buildContent(), + _buildFooter(context), + ], ); } Widget _buildTitle() { - return Text( + return const Text( 'Delete Doucument', style: TextStyle(color: Color(0xff5CC5E9), fontSize: 24), ); } Widget _buildContent() { - return Padding( - padding: const EdgeInsets.all(10.0), + return const Padding( + padding: EdgeInsets.all(10.0), child: Text( ' Hi toly! If you push the conform buttom ,' ' You will lose this file. Are you sure wand to do that?', @@ -89,10 +90,10 @@ class DeleteDialog extends StatelessWidget { alignment: Alignment.center, height: 40, width: 120, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(30)), + decoration: const BoxDecoration( + borderRadius: BorderRadius.all(const Radius.circular(30)), color: Color(0xff73D1EE)), - child: Text('Yes, Delete', + child: const Text('Yes, Delete', style: TextStyle(color: Colors.white, fontSize: 16)), ), InkWell( @@ -101,11 +102,11 @@ class DeleteDialog extends StatelessWidget { alignment: Alignment.center, height: 40, width: 120, - decoration: BoxDecoration( + decoration: const BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(30)), color: Colors.orangeAccent), - child: Text('Cancle', - style: TextStyle(color: Colors.white, fontSize: 16)), + child: const Text('Cancle', + style: TextStyle(color: Colors.white, fontSize: 16)), ), ) ], @@ -116,10 +117,10 @@ class DeleteDialog extends StatelessWidget { _buildBar(context) => Container( height: 30, alignment: Alignment.centerRight, - margin: EdgeInsets.only(right: 10, top: 5), + margin: const EdgeInsets.only(right: 10, top: 5), child: InkWell( onTap: ()=>Navigator.of(context).pop(), - child: Icon( + child: const Icon( Icons.close, color: Color(0xff82CAE3), ), diff --git a/lib/widget_system/widgets/StatelessWidget/CupertinoDialogAction/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/CupertinoDialogAction/node1_base.dart index 1f1b576..1f98bce 100644 --- a/lib/widget_system/widgets/StatelessWidget/CupertinoDialogAction/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/CupertinoDialogAction/node1_base.dart @@ -15,27 +15,30 @@ import 'package:flutter/material.dart'; // "【child】: 子组件 【Widget】", // } class CupertinoDialogActionDemo extends StatelessWidget { + const CupertinoDialogActionDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Column( children: [ CupertinoDialogAction( isDestructiveAction: false, - onPressed: ()=>_toast(context), - child: Text('CupertinoDialogAction'), + onPressed: () => _toast(context), + child: const Text('CupertinoDialogAction'), ), CupertinoDialogAction( isDestructiveAction: true, - onPressed: ()=>_toast(context), - child: Text('CupertinoDialogAction'), + onPressed: () => _toast(context), + child: const Text('CupertinoDialogAction'), ), ], ); } - _toast(BuildContext context){ + void _toast(BuildContext context) { Scaffold.of(context).showSnackBar(SnackBar( backgroundColor: Theme.of(context).primaryColor, - content: Text('CupertinoDialogAction'),)); + content: const Text('CupertinoDialogAction'), + )); } } diff --git a/lib/widget_system/widgets/StatelessWidget/CupertinoFullscreenDialogTransition/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/CupertinoFullscreenDialogTransition/node1_base.dart index 6dfce8a..f5498bf 100644 --- a/lib/widget_system/widgets/StatelessWidget/CupertinoFullscreenDialogTransition/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/CupertinoFullscreenDialogTransition/node1_base.dart @@ -16,6 +16,8 @@ import 'package:flutter/material.dart'; // } class CupertinoFullscreenDialogTransitionDemo extends StatelessWidget { + const CupertinoFullscreenDialogTransitionDemo({Key? key}) : super(key: key); + final String info = '和 CupertinoPageTransition 一样,该组件底层基于 SlideTransition 组件实现,' '主要用途是模仿 iOS 风格,用于唤出全屏对话框动画过渡效果。' @@ -27,8 +29,8 @@ class CupertinoFullscreenDialogTransitionDemo extends StatelessWidget { Widget build(BuildContext context) { return Container( color: Colors.blue.withOpacity(0.1), - padding: EdgeInsets.all(10), - margin: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), + margin: const EdgeInsets.all(10), child: Text(info), ); } diff --git a/lib/widget_system/widgets/StatelessWidget/CupertinoNavigationBarBackButton/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/CupertinoNavigationBarBackButton/node1_base.dart index dfd81ee..f87463a 100644 --- a/lib/widget_system/widgets/StatelessWidget/CupertinoNavigationBarBackButton/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/CupertinoNavigationBarBackButton/node1_base.dart @@ -13,13 +13,13 @@ import 'package:flutter/material.dart'; // } class CupertinoNavigationBarBackButtonDemo extends StatelessWidget { + const CupertinoNavigationBarBackButtonDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( - child: CupertinoNavigationBarBackButton( - color: Colors.deepPurpleAccent, - onPressed: ()=>Navigator.of(context).pop(), - ), + return CupertinoNavigationBarBackButton( + color: Colors.deepPurpleAccent, + onPressed: () => Navigator.of(context).pop(), ); } } diff --git a/lib/widget_system/widgets/StatelessWidget/CupertinoPageTransition/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/CupertinoPageTransition/node1_base.dart index 8cd35c9..94ea7ae 100644 --- a/lib/widget_system/widgets/StatelessWidget/CupertinoPageTransition/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/CupertinoPageTransition/node1_base.dart @@ -16,19 +16,20 @@ import 'package:flutter/material.dart'; // "【secondaryRouteAnimation】 : 第二路由动画 【Animation】", // } class CupertinoPageTransitionDemo extends StatelessWidget { + const CupertinoPageTransitionDemo({Key? key}) : super(key: key); + final String info = '该组件底层基于 SlideTransition 组件实现,主要用途是模仿 iOS 风格,处理页面间跳转的过渡动画。' '源码中唯一的使用处是 CupertinoPageRoute 处理路由跳转动画时,一般不会单独使用。' '如 A 跳转到 B, primaryRouteAnimation 和 secondaryRouteAnimation 都是一个 0.0->1.0 的动画,' - '前者用于处理 B 界面进入过渡动画;后者用于处理 A 界面被覆盖的过渡动画。' - ; + '前者用于处理 B 界面进入过渡动画;后者用于处理 A 界面被覆盖的过渡动画。'; @override Widget build(BuildContext context) { return Container( color: Colors.blue.withOpacity(0.1), - padding: EdgeInsets.all(10), - margin: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), + margin: const EdgeInsets.all(10), child: Text(info ), ); } diff --git a/lib/widget_system/widgets/StatelessWidget/CupertinoPopupSurface/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/CupertinoPopupSurface/node1_base.dart index 0806d45..3a02a11 100644 --- a/lib/widget_system/widgets/StatelessWidget/CupertinoPopupSurface/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/CupertinoPopupSurface/node1_base.dart @@ -17,6 +17,8 @@ import 'package:flutter/material.dart'; // } class CupertinoPopupSurfaceDemo extends StatelessWidget { + CupertinoPopupSurfaceDemo({Key? key}) : super(key: key); + final List rainbow = [ 0xffff0000, 0xffFF7F00, @@ -29,6 +31,7 @@ class CupertinoPopupSurfaceDemo extends StatelessWidget { final List stops = [0.0, 1 / 6, 2 / 6, 3 / 6, 4 / 6, 5 / 6, 1.0]; + @override Widget build(BuildContext context) { return Container( @@ -37,7 +40,7 @@ class CupertinoPopupSurfaceDemo extends StatelessWidget { radius: 1.8, stops: stops, colors: rainbow.map((e) => Color(e)).toList())), - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), child: Wrap( spacing: 10, children: [ diff --git a/lib/widget_system/widgets/StatelessWidget/CupertinoTheme/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/CupertinoTheme/node1_base.dart index f2acd06..55d48b6 100644 --- a/lib/widget_system/widgets/StatelessWidget/CupertinoTheme/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/CupertinoTheme/node1_base.dart @@ -2,21 +2,17 @@ /// create by 张风捷特烈 on 2020-03-29 /// contact me by email 1981462002@qq.com /// 说明: -// { -// "widgetId": 169, -// "name": '文字样式-TextTheme', -// "priority": 1, -// "subtitle": "后代组件可以通过CupertinoTheme.of获取主题的数据进行使用。", -// } import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class TextCupertinoTheme extends StatelessWidget { + const TextCupertinoTheme({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - var queryData = CupertinoTheme.of(context).textTheme; - var styles = { + CupertinoTextThemeData queryData = CupertinoTheme.of(context).textTheme; + Map styles = { "tabLabelTextStyle: ": queryData.tabLabelTextStyle, "actionTextStyle: ": queryData.actionTextStyle, "navActionTextStyle: ": queryData.navActionTextStyle, @@ -26,35 +22,28 @@ class TextCupertinoTheme extends StatelessWidget { "dateTimePickerTextStyle: ": queryData.dateTimePickerTextStyle, "navLargeTitleTextStyle: ": queryData.navLargeTitleTextStyle, }; - - return Container( - child: Column( - children: styles.keys.map((e) => buildItem(e, styles[e]!)).toList(), - ), + TextStyle style = + const TextStyle(fontSize: 16, fontWeight: FontWeight.bold); + return Column( + children: + styles.keys.map((e) => buildItem(e, style, styles[e]!)).toList(), ); } - Widget buildItem(String e, TextStyle style) => Column( - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - e, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + Widget buildItem(String label, TextStyle labelStyle, TextStyle style) => + Column( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(label, style: labelStyle), + Text("@toly", style: style) + ], ), - Text( - "@toly", - style: style, - ) - ], - ), - ), - Divider( - height: 1, - ) - ], - ); + ), + const Divider(height: 1) + ], + ); } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/CupertinoTheme/node2_use.dart b/lib/widget_system/widgets/StatelessWidget/CupertinoTheme/node2_use.dart index 4c4dabd..77fe711 100644 --- a/lib/widget_system/widgets/StatelessWidget/CupertinoTheme/node2_use.dart +++ b/lib/widget_system/widgets/StatelessWidget/CupertinoTheme/node2_use.dart @@ -2,34 +2,24 @@ /// create by 张风捷特烈 on 2020-03-29 /// contact me by email 1981462002@qq.com /// 说明: -// { -// "widgetId": 169, -// "name": 'CupertinoThemeData的使用', -// "priority": 2, -// "subtitle": -// "和Theme一样可以通过指定的属性,让它们在后代中共享,不过属性较少。注意如果需要使用主题,不能在当前的context中获取。", -// } - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class CustomCupertinoTheme extends StatelessWidget { + const CustomCupertinoTheme({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return CupertinoTheme( + return const CupertinoTheme( data: CupertinoThemeData( - primaryColor: Colors.blue, - primaryContrastingColor: Colors.green - ), + primaryColor: Colors.blue, primaryContrastingColor: Colors.green), child: _ChildUseTheme()); } } class _ChildUseTheme extends StatelessWidget { - const _ChildUseTheme({ - Key? key, - }) : super(key: key); + const _ChildUseTheme({Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -41,10 +31,13 @@ class _ChildUseTheme extends StatelessWidget { height: 50, color: CupertinoTheme.of(context).primaryContrastingColor, ), - Container( + SizedBox(width: 150, child: Slider(value: 0.8, onChanged: (v) => {})), + SizedBox( width: 150, - child: Slider(value: 0.8, onChanged: (v) => {})), - Container( width: 150,child: Divider(color:CupertinoTheme.of(context).primaryContrastingColor,thickness: 1,)) + child: Divider( + color: CupertinoTheme.of(context).primaryContrastingColor, + thickness: 1, + )) ]); } } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/DataTable/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/DataTable/node1_base.dart index 40f9d37..0095603 100644 --- a/lib/widget_system/widgets/StatelessWidget/DataTable/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/DataTable/node1_base.dart @@ -3,14 +3,6 @@ /// create by 张风捷特烈 on 2020-03-21 /// contact me by email 1981462002@qq.com /// 说明: -// { -// "widgetId": 102, -// "name": 'DataTable基本使用', -// "priority": 1, -// "subtitle": -// "【columns】 : 列 【List】\n" -// "【rows】 : 行 【List】", -// } import 'package:flutter/material.dart'; class _Bean { @@ -22,25 +14,29 @@ class _Bean { } class CustomDataTable extends StatelessWidget { - final data = [ + CustomDataTable({Key? key}) : super(key: key); + + final List<_Bean> data = [ _Bean(101, 'DataTable', 'StatelessWidget'), _Bean(44, 'RangeSlider', 'StatefulWidget'), _Bean(2, 'Text', 'StatelessWidget'), _Bean(1, 'Image', 'StatefulWidget'), ]; - final columns = ['id', '名称', '类型']; + final List columns = ['id', '名称', '类型']; @override Widget build(BuildContext context) { return DataTable( - columns: columns.map((e) => DataColumn(label: Text(e))).toList(), + columns: columns + .map((String title) => DataColumn(label: Text(title))) + .toList(), rows: data - .map((e) => DataRow(cells: [ - DataCell(Text('${e.id}')), - DataCell(Text('${e.name}')), - DataCell(Text('${e.type}')), - ])) + .map((_Bean bean) => DataRow(cells: [ + DataCell(Text('${bean.id}')), + DataCell(Text(bean.name)), + DataCell(Text(bean.type)), + ])) .toList()); } } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/DataTable/node2_operation.dart b/lib/widget_system/widgets/StatelessWidget/DataTable/node2_operation.dart index cd2380c..b9fa494 100644 --- a/lib/widget_system/widgets/StatelessWidget/DataTable/node2_operation.dart +++ b/lib/widget_system/widgets/StatelessWidget/DataTable/node2_operation.dart @@ -31,12 +31,14 @@ class _BeanOp { } class SortDataTable extends StatefulWidget { + const SortDataTable({Key? key}) : super(key: key); + @override _SortDataTableState createState() => _SortDataTableState(); } class _SortDataTableState extends State { - var data = [ + List<_BeanOp> data = [ _BeanOp(101, 'DataTable', 'StatelessWidget', false), _BeanOp(44, 'RangeSlider', 'StatefulWidget', false), _BeanOp(2, 'Text', 'StatelessWidget', false), @@ -44,7 +46,7 @@ class _SortDataTableState extends State { ]; bool _sortAscending = false; - var selectData = <_BeanOp>[]; + List<_BeanOp> selectData = <_BeanOp>[]; @override Widget build(BuildContext context) { @@ -54,16 +56,14 @@ class _SortDataTableState extends State { sortAscending: _sortAscending, columns: [ DataColumn( - label: Container( - child: Checkbox( - value: selectData.length == data.length, - onChanged: _onSelectAll, - ), + label: Checkbox( + value: selectData.length == data.length, + onChanged: _onSelectAll, ), ), - DataColumn(label: Text('id'), numeric: false, onSort: _onSortId), - DataColumn(label: Text('名称')), - DataColumn(label: Text('类型')), + DataColumn(label: const Text('id'), numeric: false, onSort: _onSortId), + const DataColumn(label: Text('名称')), + const DataColumn(label: Text('类型')), ], rows: data .map((e) => DataRow(selected: false, cells: [ @@ -72,9 +72,9 @@ class _SortDataTableState extends State { onChanged: (v) => _onSelectOne(v, e), )), DataCell(Text('${e.id}')), - DataCell(Text('${e.name}'), + DataCell(Text(e.name), showEditIcon: true, onTap: () {}), - DataCell(Text('${e.type}')), + DataCell(Text(e.type)), ])) .toList()); } @@ -91,13 +91,11 @@ class _SortDataTableState extends State { if(selected==null) return; setState(() { if (selected) { - //选中 selectData.add(e); } else { selectData.remove(e); } e.select = selected; - print(selectData); }); } @@ -105,10 +103,14 @@ class _SortDataTableState extends State { if(select==null) return; setState(() { if (select) { - data.forEach((e) => e.select = true); + for (_BeanOp e in data) { + e.select = true; + } selectData = data.map((e) => e).toList(); } else { - data.forEach((e) => e.select = false); + for (_BeanOp e in data) { + e.select = false; + } selectData = []; } }); diff --git a/lib/widget_system/widgets/StatelessWidget/DayPicker/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/DayPicker/node1_base.dart index b93818f..67958ca 100644 --- a/lib/widget_system/widgets/StatelessWidget/DayPicker/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/DayPicker/node1_base.dart @@ -18,6 +18,8 @@ import 'package:flutter/material.dart'; class CustomDayPicker extends StatefulWidget { + const CustomDayPicker({Key? key}) : super(key: key); + @override _CustomDayPickerState createState() => _CustomDayPickerState(); } @@ -28,14 +30,12 @@ class _CustomDayPickerState extends State { @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 350, child: DayPicker( selectedDate: _date, currentDate: DateTime.now(), - onChanged: (date){ - setState(() => _date = date); - }, + onChanged: (date)=> setState(() => _date = date), firstDate: DateTime(2018), lastDate: DateTime(2030), displayedMonth: DateTime.now() diff --git a/lib/widget_system/widgets/StatelessWidget/Dialog/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/Dialog/node1_base.dart index 111e1c9..e18c745 100644 --- a/lib/widget_system/widgets/StatelessWidget/Dialog/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/Dialog/node1_base.dart @@ -18,6 +18,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class CustomDialog extends StatelessWidget { + const CustomDialog({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Column( @@ -28,25 +30,25 @@ class CustomDialog extends StatelessWidget { ); } - Widget _buildDialog() => Dialog( + Widget _buildDialog() => const Dialog( backgroundColor: Colors.white, elevation: 5, shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(10))), - child: Container( + child: SizedBox( width: 50, child: DeleteDialog(), ), ); Widget _buildRaisedButton(BuildContext context) => RaisedButton( - shape: RoundedRectangleBorder( + shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(10))), color: Colors.blue, onPressed: () { showDialog(context: context, builder: (ctx) => _buildDialog()); }, - child: Text( + child: const Text( 'Just Show It !', style: TextStyle(color: Colors.white), ), @@ -55,32 +57,31 @@ class CustomDialog extends StatelessWidget { } class DeleteDialog extends StatelessWidget { + const DeleteDialog({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( - - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - _buildBar(context), - _buildTitle(), - _buildContent(), - _buildFooter(context), - ], - ), + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + _buildBar(context), + _buildTitle(), + _buildContent(), + _buildFooter(context), + ], ); } Widget _buildTitle() { - return Text( + return const Text( 'Delete Doucument', style: TextStyle(color: Color(0xff5CC5E9), fontSize: 24), ); } Widget _buildContent() { - return Padding( - padding: const EdgeInsets.all(15.0), + return const Padding( + padding: EdgeInsets.all(15.0), child: Text( ' Hi toly! If you push the conform buttom ,' ' You will lose this file. Are you sure wand to do that?', @@ -100,10 +101,10 @@ class DeleteDialog extends StatelessWidget { alignment: Alignment.center, height: 40, width: 100, - decoration: BoxDecoration( + decoration: const BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(30)), color: Color(0xff73D1EE)), - child: Text('Yes', + child: const Text('Yes', style: TextStyle(color: Colors.white, fontSize: 16)), ), InkWell( @@ -112,10 +113,10 @@ class DeleteDialog extends StatelessWidget { alignment: Alignment.center, height: 40, width: 100, - decoration: BoxDecoration( + decoration: const BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(30)), color: Colors.orangeAccent), - child: Text('Cancle', + child: const Text('Cancle', style: TextStyle(color: Colors.white, fontSize: 16)), ), ) @@ -124,13 +125,13 @@ class DeleteDialog extends StatelessWidget { ); } - _buildBar(context) => Container( + Widget _buildBar(context) => Container( height: 30, alignment: Alignment.centerRight, - margin: EdgeInsets.only(right: 10, top: 5), + margin: const EdgeInsets.only(right: 10, top: 5), child: InkWell( onTap: ()=>Navigator.of(context).pop(), - child: Icon( + child: const Icon( Icons.close, color: Color(0xff82CAE3), ), diff --git a/lib/widget_system/widgets/StatelessWidget/Divider/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/Divider/node1_base.dart index 377096f..ade85e0 100644 --- a/lib/widget_system/widgets/StatelessWidget/Divider/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/Divider/node1_base.dart @@ -14,20 +14,21 @@ import 'package:flutter/material.dart'; class CustomDivider extends StatelessWidget { + const CustomDivider({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - var dataColor = [ + List dataColor = [ Colors.red, Colors.yellow, Colors.blue, Colors.green]; - var dataThickness = [1.0, 2.0, 4.0, 6.0]; - var data = Map.fromIterables(dataColor, dataThickness); + List dataThickness = [1.0, 2.0, 4.0, 6.0]; + Map data = Map.fromIterables(dataColor, dataThickness); return Column( children: dataColor .map((e) => Divider( color: e, thickness: data[e], - )) - .toList(), + )).toList(), ); } } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/Divider/node2_height.dart b/lib/widget_system/widgets/StatelessWidget/Divider/node2_height.dart index eb541b6..4700889 100644 --- a/lib/widget_system/widgets/StatelessWidget/Divider/node2_height.dart +++ b/lib/widget_system/widgets/StatelessWidget/Divider/node2_height.dart @@ -3,29 +3,20 @@ /// contact me by email 1981462002@qq.com /// 说明: /// -// { -// "widgetId": 34, -// "priority": 2, -// "name": "Divider高度和空缺", -// "subtitle": "【indent】: 前面空缺长度 【double】\n" -// "【endIndent】: 后面空缺长度 【double】\n" -// "【height】: 占位高 【double】", -// } - import 'package:flutter/material.dart'; class HeightDivider extends StatelessWidget { - - final List dataColor = [ - Colors.red, Colors.yellow, - Colors.blue, Colors.green]; + const HeightDivider({Key? key}) : super(key: key); @override Widget build(BuildContext context) { + List dataThickness = [10.0, 20.0, 30.0, 40.0]; + List dataColor = [ + Colors.red, Colors.yellow, + Colors.blue, Colors.green]; + Map data = Map.fromIterables(dataColor, dataThickness); - var dataThickness = [10.0, 20.0, 30.0, 40.0]; - var data = Map.fromIterables(dataColor, dataThickness); return Column( children: dataColor .map((Color color) => Divider( diff --git a/lib/widget_system/widgets/StatelessWidget/DraggableScrollableActuator/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/DraggableScrollableActuator/node1_base.dart index f660d35..1a4167b 100644 --- a/lib/widget_system/widgets/StatelessWidget/DraggableScrollableActuator/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/DraggableScrollableActuator/node1_base.dart @@ -14,10 +14,12 @@ import 'package:flutter/material.dart'; // } class DraggableScrollableActuatorDemo extends StatelessWidget { + const DraggableScrollableActuatorDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Container( - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), child: ElevatedButton( onPressed: () { Navigator.push( @@ -26,13 +28,15 @@ class DraggableScrollableActuatorDemo extends StatelessWidget { builder: (context) => DraggableScrollableActuatorPage()), ); }, - child: Text("进入 DraggableScrollableActuator 测试页"), + child: const Text("进入 DraggableScrollableActuator 测试页"), ), ); } } class DraggableScrollableActuatorPage extends StatelessWidget { + DraggableScrollableActuatorPage({Key? key}) : super(key: key); + final List data = [ Colors.orange[50]!, Colors.orange[100]!, @@ -56,29 +60,27 @@ class DraggableScrollableActuatorPage extends StatelessWidget { Colors.red[900]!, ]; + @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text("DraggableScrollableActuator"), + title: const Text("DraggableScrollableActuator"), ), - body: Container( - // height: 400, - child: DraggableScrollableActuator( - child: Builder( - builder: (ctx) => Column( - children: [ - ElevatedButton( - onPressed: () { - DraggableScrollableActuator.reset(ctx); - }, - child: Text("重置位置"), - ), - Expanded( - child: buildSheet(), - ), - ], - ), + body: DraggableScrollableActuator( + child: Builder( + builder: (ctx) => Column( + children: [ + ElevatedButton( + onPressed: () { + DraggableScrollableActuator.reset(ctx); + }, + child: const Text("重置位置"), + ), + Expanded( + child: buildSheet(), + ), + ], ), ), ), @@ -105,7 +107,7 @@ class DraggableScrollableActuatorPage extends StatelessWidget { color: data[index], child: Text( colorString(data[index]), - style: TextStyle(color: Colors.white, shadows: [ + style: const TextStyle(color: Colors.white, shadows: [ Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) ]), ), diff --git a/lib/widget_system/widgets/StatelessWidget/Drawer/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/Drawer/node1_base.dart index 98bf6a1..db6d0f4 100644 --- a/lib/widget_system/widgets/StatelessWidget/Drawer/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/Drawer/node1_base.dart @@ -2,24 +2,18 @@ /// create by 张风捷特烈 on 2020-03-26 /// contact me by email 1981462002@qq.com /// 说明: -// { -// "widgetId": 154, -// "name": 'Drawer基本使用', -// "priority": 1, -// "subtitle": -// "【child】 : 子组件 【Widget】\n" -// "【elevation】 : 影深 【double】", -// } import 'package:flutter/material.dart'; class CustomDrawer extends StatelessWidget { + const CustomDrawer({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 400, child: Scaffold( appBar: AppBar( - title: Text('Flutter Unit'), + title: const Text('Flutter Unit'), ), drawer: Drawer( elevation: 3, @@ -30,42 +24,42 @@ class CustomDrawer extends StatelessWidget { } Widget _buildChild() => ListView( - padding: EdgeInsets.zero, - children: const [ - DrawerHeader( - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage('assets/images/caver.webp'), - fit: BoxFit.cover), - ), - child: Text( - '张风捷特烈', - style: TextStyle(fontSize: 24, color: Colors.white, shadows: [ - Shadow(color: Colors.black, offset: Offset(1, 1), blurRadius: 3) - ]), - ), - ), - ListTile( - leading: Icon( - Icons.star, - color: Colors.blue, - ), - title: Text('我的收藏'), - ), - ListTile( - leading: Icon( - Icons.palette, - color: Colors.orangeAccent, - ), - title: Text('我的绘画'), - ), - ListTile( - leading: Icon( - Icons.insert_drive_file, - color: Colors.green, - ), - title: Text('我的文件'), - ), - ], - ); + padding: EdgeInsets.zero, + children: const [ + DrawerHeader( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/images/caver.webp'), + fit: BoxFit.cover), + ), + child: Text( + '张风捷特烈', + style: TextStyle(fontSize: 24, color: Colors.white, shadows: [ + Shadow(color: Colors.black, offset: Offset(1, 1), blurRadius: 3) + ]), + ), + ), + ListTile( + leading: Icon( + Icons.star, + color: Colors.blue, + ), + title: Text('我的收藏'), + ), + ListTile( + leading: Icon( + Icons.palette, + color: Colors.orangeAccent, + ), + title: Text('我的绘画'), + ), + ListTile( + leading: Icon( + Icons.insert_drive_file, + color: Colors.green, + ), + title: Text('我的文件'), + ), + ], + ); } diff --git a/lib/widget_system/widgets/StatelessWidget/DrawerHeader/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/DrawerHeader/node1_base.dart index 724d6f6..0b976fd 100644 --- a/lib/widget_system/widgets/StatelessWidget/DrawerHeader/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/DrawerHeader/node1_base.dart @@ -16,13 +16,15 @@ import 'package:flutter/material.dart'; class CustomDrawerHeader extends StatelessWidget { + const CustomDrawerHeader({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 400, child: Scaffold( appBar: AppBar( - title: Text('Flutter Unit'), + title: const Text('Flutter Unit'), ), drawer: Drawer( elevation: 3, @@ -36,21 +38,21 @@ class CustomDrawerHeader extends StatelessWidget { padding: EdgeInsets.zero, children: [ _buildHeader(), - ListTile( + const ListTile( leading: Icon( Icons.star, color: Colors.blue, ), title: Text('我的收藏'), ), - ListTile( + const ListTile( leading: Icon( Icons.palette, color: Colors.orangeAccent, ), title: Text('我的绘画'), ), - ListTile( + const ListTile( leading: Icon( Icons.insert_drive_file, color: Colors.green, @@ -60,8 +62,7 @@ class CustomDrawerHeader extends StatelessWidget { ], ); - Widget _buildHeader() { - return DrawerHeader( + Widget _buildHeader() => const DrawerHeader( margin: EdgeInsets.all(10), padding: EdgeInsets.only(left: 20,top: 15), decoration: BoxDecoration( @@ -80,5 +81,4 @@ class CustomDrawerHeader extends StatelessWidget { ]), ), ); - } } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/FadeInImage/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/FadeInImage/node1_base.dart index 809abff..bd759cf 100644 --- a/lib/widget_system/widgets/StatelessWidget/FadeInImage/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/FadeInImage/node1_base.dart @@ -21,10 +21,12 @@ import 'package:flutter/material.dart'; // } class CustomFadeInImage extends StatelessWidget { + const CustomFadeInImage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - var placeholder = "assets/images/icon_head.webp"; - var img = + String placeholder = "assets/images/icon_head.webp"; + String img = "https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/" "15739960c2da4de3a263eeabcb60057f~tplv-k3u1fbpfcp-zoom-crop-mark" ":1304:1304:1304:734.awebp"; diff --git a/lib/widget_system/widgets/StatelessWidget/FilterChip/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/FilterChip/node1_base.dart index 2642330..a0896d2 100644 --- a/lib/widget_system/widgets/StatelessWidget/FilterChip/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/FilterChip/node1_base.dart @@ -1,19 +1,11 @@ /// create by 张风捷特烈 on 2020-03-26 /// contact me by email 1981462002@qq.com /// 说明: -// { -// "widgetId": 15, -// "priority": 1, -// "name": "FilterChip可接受选择事件", -// "subtitle": "【selected】: 是否选择 【bool】\n" -// "【onSelected】: 选择事件 【Function(bool)】\n" -// "【selectedColor】: 选择后的颜色 【Color】\n" -// "【selectedShadowColor】: 选择后的阴影颜色 【Color】\n", -// } - import 'package:flutter/material.dart'; class CustomFilterChip extends StatefulWidget { + const CustomFilterChip({Key? key}) : super(key: key); + @override _CustomFilterChipState createState() => _CustomFilterChipState(); } @@ -25,7 +17,7 @@ class _CustomFilterChipState extends State { 'C': 'Cat', 'D': 'Dog', }; - List _selected = []; + final List _selected = []; @override Widget build(BuildContext context) { @@ -33,38 +25,37 @@ class _CustomFilterChipState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Wrap( - children: map.keys.map((key) => - _buildChild(key)).toList(), + children: map.keys.map((key) => _buildChild(key)).toList(), ), Container( - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), child: Text('您已选择: ${_selected.join(', ')}')), ], ); } - Padding _buildChild(String key) { - return Padding( - padding: const EdgeInsets.all(4.0), - child: FilterChip( - selectedColor: Colors.orange.withAlpha(55), - selectedShadowColor: Colors.blue, - shadowColor: Colors.orangeAccent, - pressElevation: 5, - elevation: 3, - avatar: CircleAvatar(child: Text(key)), - label: Text(map[key]!), - selected: _selected.contains(map[key]), - onSelected: (bool value) { - setState(() { - if (value) { - _selected.add(map[key]!); - } else { - _selected.removeWhere((name) => name == map[key]); - } - }); - }, - ), - ); + Padding _buildChild(String key) => Padding( + padding: const EdgeInsets.all(4.0), + child: FilterChip( + selectedColor: Colors.orange.withAlpha(55), + selectedShadowColor: Colors.blue, + shadowColor: Colors.orangeAccent, + pressElevation: 5, + elevation: 3, + avatar: CircleAvatar(child: Text(key)), + label: Text(map[key]!), + selected: _selected.contains(map[key]), + onSelected: (bool value) => _onSelected(value, key), + ), + ); + + void _onSelected(bool value, String key) { + setState(() { + if (value) { + _selected.add(map[key]!); + } else { + _selected.removeWhere((name) => name == map[key]); + } + }); } } diff --git a/lib/widget_system/widgets/StatelessWidget/FlatButton/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/FlatButton/node1_base.dart index 4f2b38b..83f1b83 100755 --- a/lib/widget_system/widgets/StatelessWidget/FlatButton/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/FlatButton/node1_base.dart @@ -17,16 +17,18 @@ import 'package:flutter/material.dart'; class CustomFlatButton extends StatelessWidget { + const CustomFlatButton({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return FlatButton( onPressed: ()=>{}, - padding: EdgeInsets.all(8), + padding: const EdgeInsets.all(8), splashColor: Colors.green, - child: Text("FlatButton"), - textColor: Color(0xffFfffff), + child: const Text("FlatButton"), + textColor: const Color(0xffFfffff), color: Colors.blue, - highlightColor: Color(0xffF88B0A), + highlightColor: const Color(0xffF88B0A), ); } } diff --git a/lib/widget_system/widgets/StatelessWidget/FloatingActionButton/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/FloatingActionButton/node1_base.dart index fa2fe13..9a5e7b3 100644 --- a/lib/widget_system/widgets/StatelessWidget/FloatingActionButton/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/FloatingActionButton/node1_base.dart @@ -15,9 +15,11 @@ import 'package:flutter/material.dart'; class CustomFAB extends StatelessWidget { + const CustomFAB({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - var data = { + Map data = { Colors.red: Icons.add, Colors.blue: Icons.bluetooth, Colors.green: Icons.android, @@ -33,7 +35,6 @@ class CustomFAB extends StatelessWidget { child: Icon(data[e]), tooltip: "android", elevation: 5, //z-阴影盖度 - )) - .toList()); + )).toList()); } } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/FloatingActionButton/node2_mini.dart b/lib/widget_system/widgets/StatelessWidget/FloatingActionButton/node2_mini.dart index 2c47d8a..e675099 100644 --- a/lib/widget_system/widgets/StatelessWidget/FloatingActionButton/node2_mini.dart +++ b/lib/widget_system/widgets/StatelessWidget/FloatingActionButton/node2_mini.dart @@ -1,7 +1,3 @@ - - - - /// create by 张风捷特烈 on 2020-03-26 /// contact me by email 1981462002@qq.com /// 说明: @@ -15,9 +11,11 @@ import 'package:flutter/material.dart'; class MiniFAB extends StatelessWidget { + const MiniFAB({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - var data = { + Map data = { Colors.red: Icons.add, Colors.blue: Icons.bluetooth, Colors.green: Icons.android, @@ -34,7 +32,6 @@ class MiniFAB extends StatelessWidget { child: Icon(data[e]), tooltip: "android", elevation: 5, //z-阴影盖度 - )) - .toList()); + )).toList()); } } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/FloatingActionButton/node3_shape.dart b/lib/widget_system/widgets/StatelessWidget/FloatingActionButton/node3_shape.dart index fb4a3ad..577f274 100644 --- a/lib/widget_system/widgets/StatelessWidget/FloatingActionButton/node3_shape.dart +++ b/lib/widget_system/widgets/StatelessWidget/FloatingActionButton/node3_shape.dart @@ -16,9 +16,11 @@ import 'package:flutter/material.dart'; import '../../../../app/utils/pather.dart'; class ShapeFAB extends StatelessWidget { + const ShapeFAB({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - var data = { + Map data = { Colors.red: Icons.add, Colors.blue: Icons.bluetooth, Colors.green: Icons.android, @@ -35,8 +37,7 @@ class ShapeFAB extends StatelessWidget { child: Icon(data[e]), tooltip: "android", elevation: 5, - )) - .toList()); + )).toList()); } } @@ -46,9 +47,7 @@ class StarBorder extends ShapeBorder { EdgeInsetsGeometry get dimensions => EdgeInsets.zero; @override - Path getInnerPath(Rect rect, {TextDirection? textDirection}) { - return Path(); - } + Path getInnerPath(Rect rect, {TextDirection? textDirection}) => Path(); @override Path getOuterPath(Rect rect, {TextDirection? textDirection}) { @@ -60,7 +59,5 @@ class StarBorder extends ShapeBorder { void paint(Canvas canvas, Rect rect, {TextDirection? textDirection}) {} @override - ShapeBorder scale(double t) { - return this; - } + ShapeBorder scale(double t) => this; } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/FlutterLogo/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/FlutterLogo/node1_base.dart index fe426b7..d45dad4 100644 --- a/lib/widget_system/widgets/StatelessWidget/FlutterLogo/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/FlutterLogo/node1_base.dart @@ -13,10 +13,12 @@ import 'package:flutter/material.dart'; class CustomFlutterLogo extends StatelessWidget { + const CustomFlutterLogo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - var data = { + Map data = { Colors.blue:50.0, Colors.red:60.0, Colors.green:70.0, @@ -27,8 +29,7 @@ class CustomFlutterLogo extends StatelessWidget { .map((e) => FlutterLogo( size: data[e], textColor: e, - )) - .toList(), + )).toList(), ); } } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/FlutterLogo/node2_style.dart b/lib/widget_system/widgets/StatelessWidget/FlutterLogo/node2_style.dart index 0ff28a6..9f5bcb5 100644 --- a/lib/widget_system/widgets/StatelessWidget/FlutterLogo/node2_style.dart +++ b/lib/widget_system/widgets/StatelessWidget/FlutterLogo/node2_style.dart @@ -2,34 +2,26 @@ /// create by 张风捷特烈 on 2020-03-26 /// contact me by email 1981462002@qq.com /// 说明: -// { -// "widgetId": 4, -// "priority": 2, -// "name": "样式用于显示文字", -// "subtitle": "【style】 : 样式-3种枚举 【FlutterLogoStyle】\n" -// "【textColor】: 文字颜色 【Color】", -// } - import 'package:flutter/material.dart'; class FlutterLogoWithText extends StatelessWidget { - - final Map data = { - FlutterLogoStyle.horizontal:Colors.blue, - FlutterLogoStyle.markOnly:Colors.red, - FlutterLogoStyle.stacked:Colors.green, - }; - + const FlutterLogoWithText({Key? key}) : super(key: key); @override Widget build(BuildContext context) { + final Map data = { + FlutterLogoStyle.horizontal: Colors.blue, + FlutterLogoStyle.markOnly: Colors.red, + FlutterLogoStyle.stacked: Colors.green, + }; return Wrap( spacing: 20, - children: data.keys.map((FlutterLogoStyle style) => FlutterLogo( - size: 80, - style: style, - textColor: data[style]!, - )) + children: data.keys + .map((FlutterLogoStyle style) => FlutterLogo( + size: 80, + style: style, + textColor: data[style]!, + )) .toList(), ); } diff --git a/lib/widget_system/widgets/StatelessWidget/GestureDetector/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/GestureDetector/node1_base.dart index 040abfd..697fdca 100644 --- a/lib/widget_system/widgets/StatelessWidget/GestureDetector/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/GestureDetector/node1_base.dart @@ -20,12 +20,14 @@ import 'package:flutter/material.dart'; // } class CustomGestureDetector extends StatefulWidget { + const CustomGestureDetector({Key? key}) : super(key: key); + @override _CustomGestureDetectorState createState() => _CustomGestureDetectorState(); } class _CustomGestureDetectorState extends State { - var _info = ''; + String _info = ''; @override Widget build(BuildContext context) { @@ -40,7 +42,7 @@ class _CustomGestureDetectorState extends State { color: Colors.grey.withAlpha(33), child: Text( _info, - style: TextStyle(fontSize: 18, color: Colors.blue), + style: const TextStyle(fontSize: 18, color: Colors.blue), ), ), ); diff --git a/lib/widget_system/widgets/StatelessWidget/GestureDetector/node2_tap.dart b/lib/widget_system/widgets/StatelessWidget/GestureDetector/node2_tap.dart index 2d36002..63522f2 100644 --- a/lib/widget_system/widgets/StatelessWidget/GestureDetector/node2_tap.dart +++ b/lib/widget_system/widgets/StatelessWidget/GestureDetector/node2_tap.dart @@ -14,12 +14,14 @@ import 'package:flutter/material.dart'; // "【onTapCancel】 : 点击取消 【GestureTapCancelCallback】", // } class TapGestureDetector extends StatefulWidget { + const TapGestureDetector({Key? key}) : super(key: key); + @override _TapGestureDetectorState createState() => _TapGestureDetectorState(); } class _TapGestureDetectorState extends State { - var _info = ''; + String _info = ''; @override Widget build(BuildContext context) { @@ -36,7 +38,7 @@ class _TapGestureDetectorState extends State { color: Colors.grey.withAlpha(33), child: Text( _info, - style: TextStyle(fontSize: 18, color: Colors.blue), + style: const TextStyle(fontSize: 18, color: Colors.blue), ), ), ); diff --git a/lib/widget_system/widgets/StatelessWidget/GestureDetector/node3_pan.dart b/lib/widget_system/widgets/StatelessWidget/GestureDetector/node3_pan.dart index d4989fa..18a0590 100644 --- a/lib/widget_system/widgets/StatelessWidget/GestureDetector/node3_pan.dart +++ b/lib/widget_system/widgets/StatelessWidget/GestureDetector/node3_pan.dart @@ -16,12 +16,14 @@ import 'package:flutter/material.dart'; // "【onPanCancel】 : 拖动取消 【GestureDragCancelCallback】", // } class PanGestureDetector extends StatefulWidget { + const PanGestureDetector({Key? key}) : super(key: key); + @override _PanGestureDetectorState createState() => _PanGestureDetectorState(); } class _PanGestureDetectorState extends State { - var _info = ''; + String _info = ''; @override Widget build(BuildContext context) { @@ -43,7 +45,7 @@ class _PanGestureDetectorState extends State { color: Colors.grey.withAlpha(33), child: Text( _info, - style: TextStyle(fontSize: 18, color: Colors.blue), + style: const TextStyle(fontSize: 18, color: Colors.blue), ), ), ), diff --git a/lib/widget_system/widgets/StatelessWidget/GirdView/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/GirdView/node1_base.dart index f8dfa48..49b729d 100644 --- a/lib/widget_system/widgets/StatelessWidget/GirdView/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/GirdView/node1_base.dart @@ -17,20 +17,20 @@ import 'package:flutter/material.dart'; // "【crossAxisCount】 : 主轴一行数量 【int】", // } class CustomGridView extends StatelessWidget { - final data = List.generate(128, (i) => Color(0xFFFF00FF - 2*i)); + CustomGridView({Key? key}) : super(key: key); + + final List data = List.generate(128, (i) => Color(0xFFFF00FF - 2 * i)); @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, child: GridView.count( crossAxisCount: 4, mainAxisSpacing: 2, crossAxisSpacing: 2, - childAspectRatio: 1/0.618, - children: data - .map((color) => _buildItem(color)) - .toList(), + childAspectRatio: 1 / 0.618, + children: data.map((color) => _buildItem(color)).toList(), ), ); } @@ -42,13 +42,13 @@ class CustomGridView extends StatelessWidget { color: color, child: Text( colorString(color), - style: TextStyle(color: Colors.white, shadows: [ - Shadow( - color: Colors.black, - offset: Offset(.5, .5), - blurRadius: 2) - ]), - ), + style: const TextStyle( + color: Colors.white, + shadows: [ + Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) + ], + ), + ), ); String colorString(Color color) => diff --git a/lib/widget_system/widgets/StatelessWidget/GirdView/node2_direction.dart b/lib/widget_system/widgets/StatelessWidget/GirdView/node2_direction.dart index c72f57d..51f7233 100644 --- a/lib/widget_system/widgets/StatelessWidget/GirdView/node2_direction.dart +++ b/lib/widget_system/widgets/StatelessWidget/GirdView/node2_direction.dart @@ -14,11 +14,13 @@ import 'package:flutter/material.dart'; // "【shrinkWrap】 : 无边界时是否包裹 【bool】", // } class HorizontalGridView extends StatelessWidget { - final data = List.generate(128, (i) => Color(0xFF00FFFF - 2*i)); + HorizontalGridView({Key? key}) : super(key: key); + + final List data = List.generate(128, (i) => Color(0xFF00FFFF - 2 * i)); @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, child: GridView.count( scrollDirection: Axis.horizontal, @@ -27,9 +29,7 @@ class HorizontalGridView extends StatelessWidget { mainAxisSpacing: 2, crossAxisSpacing: 2, childAspectRatio: 0.618, - children: data - .map((color) => _buildItem(color)) - .toList(), + children: data.map((color) => _buildItem(color)).toList(), ), ); } @@ -41,13 +41,13 @@ class HorizontalGridView extends StatelessWidget { color: color, child: Text( colorString(color), - style: TextStyle(color: Colors.white, shadows: [ - Shadow( - color: Colors.black, - offset: Offset(.5, .5), - blurRadius: 2) - ]), - ), + style: const TextStyle( + color: Colors.white, + shadows: [ + Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) + ], + ), + ), ); String colorString(Color color) => diff --git a/lib/widget_system/widgets/StatelessWidget/GirdView/node3_extend.dart b/lib/widget_system/widgets/StatelessWidget/GirdView/node3_extend.dart index 5fc92ea..a7da1ab 100644 --- a/lib/widget_system/widgets/StatelessWidget/GirdView/node3_extend.dart +++ b/lib/widget_system/widgets/StatelessWidget/GirdView/node3_extend.dart @@ -14,11 +14,13 @@ import 'package:flutter/material.dart'; // "【shrinkWrap】 : 无边界时是否包裹 【bool】", // } class ExtentGridView extends StatelessWidget { - final data = List.generate(128, (i) => Color(0xFF00FFFF - 2*i)); + ExtentGridView({Key? key}) : super(key: key); + + final List data = List.generate(128, (i) => Color(0xFF00FFFF - 2 * i)); @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, child: GridView.extent( scrollDirection: Axis.horizontal, @@ -26,9 +28,7 @@ class ExtentGridView extends StatelessWidget { mainAxisSpacing: 2, crossAxisSpacing: 2, childAspectRatio: 0.618, - children: data - .map((color) => _buildItem(color)) - .toList(), + children: data.map((color) => _buildItem(color)).toList(), ), ); } @@ -40,13 +40,13 @@ class ExtentGridView extends StatelessWidget { color: color, child: Text( colorString(color), - style: TextStyle(color: Colors.white, shadows: [ - Shadow( - color: Colors.black, - offset: Offset(.5, .5), - blurRadius: 2) - ]), - ), + style: const TextStyle( + color: Colors.white, + shadows: [ + Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) + ], + ), + ), ); String colorString(Color color) => diff --git a/lib/widget_system/widgets/StatelessWidget/GirdView/node4_builder.dart b/lib/widget_system/widgets/StatelessWidget/GirdView/node4_builder.dart index 695cae7..a60215c 100644 --- a/lib/widget_system/widgets/StatelessWidget/GirdView/node4_builder.dart +++ b/lib/widget_system/widgets/StatelessWidget/GirdView/node4_builder.dart @@ -14,40 +14,42 @@ import 'package:flutter/material.dart'; // "【itemBuilder】 : 条目构造器 【IndexedWidgetBuilder】", // } class BuilderGridView extends StatelessWidget { - final data = List.generate(128, (i) => Color(0xFF33FFF - 2*i)); + BuilderGridView({Key? key}) : super(key: key); + + final List data = List.generate(128, (i) => Color(0xFF33FFF - 2 * i)); @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, child: GridView.builder( itemCount: data.length, scrollDirection: Axis.vertical, - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(//网格代理:定交叉轴数目 - crossAxisCount: 4,//条目个数 - mainAxisSpacing: 5,//主轴间距 - crossAxisSpacing: 5,//交叉轴间距 - childAspectRatio:1/0.618), - itemBuilder: (_, int position)=> _buildItem(data[position]) - ), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + //网格代理:定交叉轴数目 + crossAxisCount: 4, //条目个数 + mainAxisSpacing: 5, //主轴间距 + crossAxisSpacing: 5, //交叉轴间距 + childAspectRatio: 1 / 0.618), + itemBuilder: (_, int position) => _buildItem(data[position])), ); } - Container _buildItem(Color color) => Container( - alignment: Alignment.center, - width: 100, - height: 30, - color: color, - child: Text( - colorString(color), - style: TextStyle(color: Colors.white, shadows: [ - Shadow( - color: Colors.black, - offset: Offset(.5, .5), - blurRadius: 2) - ]), - ), - ); + Widget _buildItem(Color color) => Container( + alignment: Alignment.center, + width: 100, + height: 30, + color: color, + child: Text( + colorString(color), + style: const TextStyle( + color: Colors.white, + shadows: [ + Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) + ], + ), + ), + ); String colorString(Color color) => "#${color.value.toRadixString(16).padLeft(8, '0').toUpperCase()}"; diff --git a/lib/widget_system/widgets/StatelessWidget/GridPaper/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/GridPaper/node1_base.dart index e4bdb81..e96331d 100644 --- a/lib/widget_system/widgets/StatelessWidget/GridPaper/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/GridPaper/node1_base.dart @@ -13,9 +13,11 @@ import 'package:flutter/material.dart'; // "【interval】: 小块边长 【double】", // } class CustomGridPage extends StatelessWidget { + const CustomGridPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: 200, height: 100, child: GridPaper( diff --git a/lib/widget_system/widgets/StatelessWidget/GridPaper/node2_divisions.dart b/lib/widget_system/widgets/StatelessWidget/GridPaper/node2_divisions.dart index 14b4d01..c1cf824 100644 --- a/lib/widget_system/widgets/StatelessWidget/GridPaper/node2_divisions.dart +++ b/lib/widget_system/widgets/StatelessWidget/GridPaper/node2_divisions.dart @@ -13,9 +13,11 @@ import 'package:flutter/material.dart'; // "【divisions】: 小块中子块的分割数 【int】", // } class DivisionsGridPage extends StatelessWidget { + const DivisionsGridPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: 200, height: 100, child: GridPaper( diff --git a/lib/widget_system/widgets/StatelessWidget/GridTile/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/GridTile/node1_base.dart index f3085d5..80d58f8 100644 --- a/lib/widget_system/widgets/StatelessWidget/GridTile/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/GridTile/node1_base.dart @@ -13,40 +13,37 @@ import 'package:flutter/material.dart'; // } class CustomGridTile extends StatelessWidget { + const CustomGridTile({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( - width: 200, height: 200, + return SizedBox( + width: 200, + height: 200, child: GridTile( header: GridTileBar( backgroundColor: Colors.blue.withAlpha(120), - trailing: Icon( - Icons.star, - color: Colors.red, - ), - leading: CircleAvatar( + trailing: const Icon(Icons.star, color: Colors.red), + leading: const CircleAvatar( backgroundImage: AssetImage("assets/images/wy_200x300.webp"), ), - title: Text("百里·巫缨"), - subtitle: Text("倾国必倾城"), + title: const Text("百里·巫缨"), + subtitle: const Text("倾国必倾城"), ), child: Opacity( opacity: 0.5, - child: Image.asset( - "assets/images/sabar.webp", - fit: BoxFit.cover, - ), + child: Image.asset("assets/images/sabar.webp", fit: BoxFit.cover), ), - footer: Padding( - padding: const EdgeInsets.all(8.0), + footer: const Padding( + padding: EdgeInsets.all(8.0), child: Text( "ID:z\$ySX32&29", - style: TextStyle(shadows: [ - Shadow( - color: Colors.blue, - offset: Offset(.1, .1), - blurRadius: 2), - ]), + style: TextStyle( + shadows: [ + Shadow( + color: Colors.blue, offset: Offset(.1, .1), blurRadius: 2), + ], + ), ), ), ), diff --git a/lib/widget_system/widgets/StatelessWidget/GridTileBar/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/GridTileBar/node1_base.dart index eb6658d..e04a868 100644 --- a/lib/widget_system/widgets/StatelessWidget/GridTileBar/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/GridTileBar/node1_base.dart @@ -18,19 +18,18 @@ import 'package:flutter/material.dart'; class CustomGridTileBar extends StatelessWidget { + const CustomGridTileBar({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return GridTileBar( backgroundColor: Colors.blue.withAlpha(120), - trailing: Icon( - Icons.star, - color: Colors.red, - ), - leading: CircleAvatar( + trailing: const Icon(Icons.star, color: Colors.red), + leading: const CircleAvatar( backgroundImage: AssetImage("assets/images/wy_200x300.webp"), ), - title: Text("百里·巫缨"), - subtitle: Text("倾国必倾城"), + title: const Text("百里·巫缨"), + subtitle: const Text("倾国必倾城"), ); } } diff --git a/lib/widget_system/widgets/StatelessWidget/HtmlElementView/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/HtmlElementView/node1_base.dart index d2e28d4..29cfe3d 100644 --- a/lib/widget_system/widgets/StatelessWidget/HtmlElementView/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/HtmlElementView/node1_base.dart @@ -14,16 +14,19 @@ import 'package:flutter/material.dart'; // "【viewType】 : html元素唯一表识 【String】", // } class HtmlElementViewDemo extends StatelessWidget { + const HtmlElementViewDemo({Key? key}) : super(key: key); + final String info = '该组件只能用于 Flutter Web 中,嵌入 Html 元素的较为昂贵。' '内部基于 PlatformViewLink 和 PlatformViewSurface 组件实现。'; + @override Widget build(BuildContext context) { return Container( color: Colors.blue.withOpacity(0.1), - padding: EdgeInsets.all(10), - margin: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), + margin: const EdgeInsets.all(10), child: Text(info), ); } diff --git a/lib/widget_system/widgets/StatelessWidget/Icon/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/Icon/node1_base.dart index 64aa692..522ecbf 100644 --- a/lib/widget_system/widgets/StatelessWidget/Icon/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/Icon/node1_base.dart @@ -17,21 +17,15 @@ import 'package:flutter/material.dart'; class CustomIcon extends StatelessWidget { + const CustomIcon({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Wrap( crossAxisAlignment: WrapCrossAlignment.center, - children: [ - Icon( - Icons.send, - color: Colors.orange, - size: 60, - ), - Icon( - Icons.android, - color: Colors.green, - size: 100, - ), + children: const [ + Icon(Icons.send, color: Colors.orange, size: 60), + Icon(Icons.android, color: Colors.green, size: 100), ], ); } diff --git a/lib/widget_system/widgets/StatelessWidget/Icon/node2_diy.dart b/lib/widget_system/widgets/StatelessWidget/Icon/node2_diy.dart index cd0cb24..bc07c51 100644 --- a/lib/widget_system/widgets/StatelessWidget/Icon/node2_diy.dart +++ b/lib/widget_system/widgets/StatelessWidget/Icon/node2_diy.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; + import '../../../../app/res/toly_icon.dart'; /// create by 张风捷特烈 on 2020/4/27 @@ -14,6 +15,8 @@ import '../../../../app/res/toly_icon.dart'; class MyIcon extends StatelessWidget { + const MyIcon({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Wrap( @@ -24,13 +27,11 @@ class MyIcon extends StatelessWidget { TolyIcon.icon_star, TolyIcon.icon_layout, TolyIcon.icon_star_ok - ] - .map((e) => Icon( + ].map((e) => Icon( e, color: Colors.green, size: 60, - )) - .toList(), + ),).toList(), ); } } diff --git a/lib/widget_system/widgets/StatelessWidget/IconButton/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/IconButton/node1_base.dart index e1d2386..c69c775 100755 --- a/lib/widget_system/widgets/StatelessWidget/IconButton/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/IconButton/node1_base.dart @@ -15,14 +15,16 @@ import 'package:flutter/material.dart'; // } class CustomIconButton extends StatelessWidget { + const CustomIconButton({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.all(8.0), child: IconButton( - padding: EdgeInsets.only(), + padding: const EdgeInsets.only(), onPressed: () {}, - icon: Icon(Icons.android, size: 40, color: Colors.green), + icon: const Icon(Icons.android, size: 40, color: Colors.green), tooltip: "android", highlightColor: Colors.orangeAccent, splashColor: Colors.blue, diff --git a/lib/widget_system/widgets/StatelessWidget/ImageIcon/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/ImageIcon/node1_base.dart index a13615c..36f24f6 100644 --- a/lib/widget_system/widgets/StatelessWidget/ImageIcon/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/ImageIcon/node1_base.dart @@ -13,9 +13,11 @@ import 'package:flutter/material.dart'; // } class CustomImageIcon extends StatelessWidget { + const CustomImageIcon({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - var data = { + Map data = { Colors.blue: 50.0, Colors.red: 60.0, Colors.green: 70.0, @@ -25,7 +27,7 @@ class CustomImageIcon extends StatelessWidget { spacing: 10, children: data.keys .map((e) => ImageIcon( - AssetImage("assets/images/leaf.webp"), + const AssetImage("assets/images/leaf.webp"), color: e, size: data[e], )) diff --git a/lib/widget_system/widgets/StatelessWidget/InputChip/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/InputChip/node1_base.dart index c4d4beb..441d9bc 100644 --- a/lib/widget_system/widgets/StatelessWidget/InputChip/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/InputChip/node1_base.dart @@ -12,6 +12,8 @@ import 'package:flutter/material.dart'; // } class PressInputChip extends StatefulWidget { + const PressInputChip({Key? key}) : super(key: key); + @override _PressInputChipState createState() => _PressInputChipState(); } @@ -22,8 +24,8 @@ class _PressInputChipState extends State { @override Widget build(BuildContext context) { return InputChip( - padding: EdgeInsets.all(5), - labelPadding: EdgeInsets.all(3), + padding: const EdgeInsets.all(5), + labelPadding: const EdgeInsets.all(3), label: Text( !_delete ? "This is a InputChip." : diff --git a/lib/widget_system/widgets/StatelessWidget/InputChip/node2_select.dart b/lib/widget_system/widgets/StatelessWidget/InputChip/node2_select.dart index ed4bcfa..4b659cf 100644 --- a/lib/widget_system/widgets/StatelessWidget/InputChip/node2_select.dart +++ b/lib/widget_system/widgets/StatelessWidget/InputChip/node2_select.dart @@ -14,6 +14,8 @@ import 'package:flutter/material.dart'; // } class SelectInputChip extends StatefulWidget { + const SelectInputChip({Key? key}) : super(key: key); + @override _SelectInputChipState createState() => _SelectInputChipState(); } @@ -25,9 +27,9 @@ class _SelectInputChipState extends State { Widget build(BuildContext context) { return InputChip( selected: _select, - padding: EdgeInsets.all(5), - labelPadding: EdgeInsets.all(3), - label: Text("This is a InputChip."), + padding: const EdgeInsets.all(5), + labelPadding: const EdgeInsets.all(3), + label: const Text("This is a InputChip."), backgroundColor: Colors.grey.withAlpha(66), avatar: Image.asset("assets/images/icon_head.webp"), selectedColor: Colors.orangeAccent.withAlpha(88), diff --git a/lib/widget_system/widgets/StatelessWidget/ListTile/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/ListTile/node1_base.dart index 7e8417e..4ee0990 100644 --- a/lib/widget_system/widgets/StatelessWidget/ListTile/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/ListTile/node1_base.dart @@ -16,17 +16,19 @@ import 'package:flutter/material.dart'; // "【onLongPress】: 点击事件 【Function()】", // } class CustomListTile extends StatelessWidget { + const CustomListTile({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.all(10), + margin: const EdgeInsets.all(10), color: Colors.grey.withAlpha(22), child: ListTile( leading: Image.asset("assets/images/icon_head.webp"), - title: Text("以梦为马"), - subtitle: Text("海子"), - contentPadding: EdgeInsets.all(5), - trailing: Icon(Icons.more_vert), + title: const Text("以梦为马"), + subtitle: const Text("海子"), + contentPadding: const EdgeInsets.all(5), + trailing: const Icon(Icons.more_vert), onLongPress: () => Navigator.of(context).pushNamed('AboutMePage'), ), ); diff --git a/lib/widget_system/widgets/StatelessWidget/ListTile/node2_select.dart b/lib/widget_system/widgets/StatelessWidget/ListTile/node2_select.dart index fa8f8f0..b45d37c 100644 --- a/lib/widget_system/widgets/StatelessWidget/ListTile/node2_select.dart +++ b/lib/widget_system/widgets/StatelessWidget/ListTile/node2_select.dart @@ -12,6 +12,8 @@ import 'package:flutter/material.dart'; // "【onTap】: 点击事件 【Function()】", // } class SelectListTile extends StatefulWidget { + const SelectListTile({Key? key}) : super(key: key); + @override _SelectListTileState createState() => _SelectListTileState(); } @@ -22,15 +24,15 @@ class _SelectListTileState extends State { @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.all(10), + margin: const EdgeInsets.all(10), color: Colors.grey.withAlpha(22), child: ListTile( leading: Image.asset("assets/images/icon_head.webp"), selected: _selected, - title: Text("以梦为马"), - subtitle: Text("海子"), - contentPadding: EdgeInsets.all(5), - trailing: Icon(Icons.more_vert), + title: const Text("以梦为马"), + subtitle: const Text("海子"), + contentPadding: const EdgeInsets.all(5), + trailing: const Icon(Icons.more_vert), onTap: () => setState(() => _selected = !_selected), ), ); diff --git a/lib/widget_system/widgets/StatelessWidget/ListTile/node3_dense.dart b/lib/widget_system/widgets/StatelessWidget/ListTile/node3_dense.dart index bb67d12..a176f58 100644 --- a/lib/widget_system/widgets/StatelessWidget/ListTile/node3_dense.dart +++ b/lib/widget_system/widgets/StatelessWidget/ListTile/node3_dense.dart @@ -11,6 +11,8 @@ import 'package:flutter/material.dart'; // "subtitle": "【dense】: 是否密排 【bool】", // } class DenseListTile extends StatefulWidget { + const DenseListTile({Key? key}) : super(key: key); + @override _DenseListTileState createState() => _DenseListTileState(); } @@ -21,15 +23,15 @@ class _DenseListTileState extends State { @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.all(10), + margin: const EdgeInsets.all(10), color: Colors.grey.withAlpha(22), child: ListTile( leading: Image.asset("assets/images/icon_head.webp"), - title: Text("以梦为马"), - subtitle: Text("海子"), + title: const Text("以梦为马"), + subtitle: const Text("海子"), selected: false, - contentPadding: EdgeInsets.all(5), - trailing: Icon(Icons.more_vert), + contentPadding: const EdgeInsets.all(5), + trailing: const Icon(Icons.more_vert), dense: _dense, onTap: () => setState(() => _dense = !_dense), ), diff --git a/lib/widget_system/widgets/StatelessWidget/ListView/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/ListView/node1_base.dart index b4ae391..45afd5a 100644 --- a/lib/widget_system/widgets/StatelessWidget/ListView/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/ListView/node1_base.dart @@ -12,6 +12,8 @@ import 'package:flutter/material.dart'; // "【padding】 : 内边距 【EdgeInsetsGeometry】", // } class CustomListView extends StatelessWidget { + CustomListView({Key? key}) : super(key: key); + final List data = [ Colors.purple[50]!, Colors.purple[100]!, @@ -25,28 +27,30 @@ class CustomListView extends StatelessWidget { Colors.purple[900]!, ]; + TextStyle get textStyle => const TextStyle( + color: Colors.white, + shadows: [ + Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) + ], + ); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, - child: ListView( - padding: EdgeInsets.symmetric(horizontal: 5), + child: ListView( + padding: const EdgeInsets.symmetric(horizontal: 5), children: data .map((color) => Container( - alignment: Alignment.center, - width: 100, - height: 50, - color: color, - child: Text( - colorString(color), - style: TextStyle(color: Colors.white, shadows: [ - Shadow( - color: Colors.black, - offset: Offset(.5, .5), - blurRadius: 2) - ]), - ), - )) + alignment: Alignment.center, + width: 100, + height: 50, + color: color, + child: Text( + colorString(color), + style: textStyle, + ), + )) .toList(), ), ); diff --git a/lib/widget_system/widgets/StatelessWidget/ListView/node2_direction.dart b/lib/widget_system/widgets/StatelessWidget/ListView/node2_direction.dart index e61591c..081ded3 100644 --- a/lib/widget_system/widgets/StatelessWidget/ListView/node2_direction.dart +++ b/lib/widget_system/widgets/StatelessWidget/ListView/node2_direction.dart @@ -14,6 +14,8 @@ import 'package:flutter/material.dart'; // "【shrinkWrap】 : 无边界时是否包裹 【bool】", // } class HorizontalListView extends StatelessWidget { + HorizontalListView({Key? key}) : super(key: key); + final List data = [ Colors.purple[50]!, Colors.purple[100]!, @@ -27,9 +29,16 @@ class HorizontalListView extends StatelessWidget { Colors.purple[900]!, ]; + TextStyle get textStyle => const TextStyle( + color: Colors.white, + shadows: [ + Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) + ], + ); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, child: ListView( reverse: true, @@ -43,12 +52,7 @@ class HorizontalListView extends StatelessWidget { color: color, child: Text( colorString(color), - style: TextStyle(color: Colors.white, shadows: [ - Shadow( - color: Colors.black, - offset: Offset(.5, .5), - blurRadius: 2) - ]), + style: textStyle, ), )) .toList(), diff --git a/lib/widget_system/widgets/StatelessWidget/ListView/node3_builder.dart b/lib/widget_system/widgets/StatelessWidget/ListView/node3_builder.dart index 4ccdfba..d951c4d 100644 --- a/lib/widget_system/widgets/StatelessWidget/ListView/node3_builder.dart +++ b/lib/widget_system/widgets/StatelessWidget/ListView/node3_builder.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; // "【itemBuilder】 : 条目构造器 【IndexedWidgetBuilder】", // } class BuilderListView extends StatelessWidget { + BuilderListView({Key? key}) : super(key: key); + final List data = [ Colors.purple[50]!, Colors.purple[100]!, @@ -28,7 +30,7 @@ class BuilderListView extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, child: ListView.builder( itemCount: data.length, @@ -37,19 +39,24 @@ class BuilderListView extends StatelessWidget { ); } + TextStyle get textStyle => const TextStyle( + color: Colors.white, + shadows: [ + Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) + ], + ); + String colorString(Color color) => "#${color.value.toRadixString(16).padLeft(8, '0').toUpperCase()}"; Widget _buildItem(Color color) => Container( - alignment: Alignment.center, - width: 100, - height: 50, - color: color, - child: Text( - colorString(color), - style: TextStyle(color: Colors.white, shadows: [ - Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) - ]), - ), - ); + alignment: Alignment.center, + width: 100, + height: 50, + color: color, + child: Text( + colorString(color), + style: textStyle, + ), + ); } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/ListView/node4_separated.dart b/lib/widget_system/widgets/StatelessWidget/ListView/node4_separated.dart index 8a63bfc..4105d10 100644 --- a/lib/widget_system/widgets/StatelessWidget/ListView/node4_separated.dart +++ b/lib/widget_system/widgets/StatelessWidget/ListView/node4_separated.dart @@ -12,6 +12,8 @@ import 'package:flutter/material.dart'; // "【separatorBuilder】 : 条目构造器 【IndexedWidgetBuilder】", // } class SeparatedListView extends StatelessWidget { + SeparatedListView({Key? key}) : super(key: key); + final List data = [ Colors.purple[50]!, Colors.purple[100]!, @@ -24,12 +26,13 @@ class SeparatedListView extends StatelessWidget { Colors.purple[800]!, Colors.purple[900]!, ]; + @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, child: ListView.separated( - separatorBuilder: (context, index) => Divider( + separatorBuilder: (context, index) => const Divider( thickness: 1, height: 1, color: Colors.orange, @@ -43,16 +46,21 @@ class SeparatedListView extends StatelessWidget { String colorString(Color color) => "#${color.value.toRadixString(16).padLeft(8, '0').toUpperCase()}"; + TextStyle get textStyle => const TextStyle( + color: Colors.white, + shadows: [ + Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) + ], + ); + Widget _buildItem(Color color) => Container( - alignment: Alignment.center, - width: 100, - height: 50, - color: color, - child: Text( - colorString(color), - style: TextStyle(color: Colors.white, shadows: [ - Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) - ]), - ), - ); + alignment: Alignment.center, + width: 100, + height: 50, + color: color, + child: Text( + colorString(color), + style: textStyle, + ), + ); } diff --git a/lib/widget_system/widgets/StatelessWidget/Listener/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/Listener/node1_base.dart index f515e9f..894cc42 100644 --- a/lib/widget_system/widgets/StatelessWidget/Listener/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/Listener/node1_base.dart @@ -17,12 +17,14 @@ import 'package:flutter/material.dart'; // } class CustomListener extends StatefulWidget { + const CustomListener({Key? key}) : super(key: key); + @override _CustomListenerState createState() => _CustomListenerState(); } class _CustomListenerState extends State { - var _info = ''; + String _info = ''; @override Widget build(BuildContext context) { @@ -39,7 +41,7 @@ class _CustomListenerState extends State { color: Colors.grey.withAlpha(33), child: Text( _info, - style: TextStyle(fontSize: 16, color: Colors.blue), + style: const TextStyle(fontSize: 16, color: Colors.blue), ), ), ); diff --git a/lib/widget_system/widgets/StatelessWidget/MaterialBanner/node1_one_btn.dart b/lib/widget_system/widgets/StatelessWidget/MaterialBanner/node1_one_btn.dart index 5db4583..236ac64 100644 --- a/lib/widget_system/widgets/StatelessWidget/MaterialBanner/node1_one_btn.dart +++ b/lib/widget_system/widgets/StatelessWidget/MaterialBanner/node1_one_btn.dart @@ -16,31 +16,34 @@ import 'package:flutter/material.dart'; // "【backgroundColor】: 背景色 【Color】", // } class MaterialBannerDemo extends StatelessWidget { - final info = - 'Welcome to Flutter Unit!'; + const MaterialBannerDemo({Key? key}) : super(key: key); + + final String info = 'Welcome to Flutter Unit!'; @override Widget build(BuildContext context) { return Column( - children: [MaterialBanner( - content: Text( - info, - style: TextStyle(color: Colors.white), - ), - backgroundColor: Colors.purple, - leading: Icon(Icons.info, color: Colors.lightBlueAccent), - padding: EdgeInsetsDirectional.only(start: 16.0, top: 2.0), - forceActionsBelow: false, // 默认false - actions: [ - Text( - 'I KNOW', - style:TextStyle( - color: Colors.orange, - fontWeight: FontWeight.bold, - fontSize: 14) , - ) - ], - )], + children: [ + MaterialBanner( + content: Text( + info, + style: const TextStyle(color: Colors.white), + ), + backgroundColor: Colors.purple, + leading: const Icon(Icons.info, color: Colors.lightBlueAccent), + padding: const EdgeInsetsDirectional.only(start: 16.0, top: 2.0), + forceActionsBelow: false, + // 默认false + actions: const [ + Text( + 'I KNOW', + style: TextStyle( + color: Colors.orange, + fontWeight: FontWeight.bold, + fontSize: 14), + ) + ], + )], ); } diff --git a/lib/widget_system/widgets/StatelessWidget/MaterialBanner/node2_two_btn.dart b/lib/widget_system/widgets/StatelessWidget/MaterialBanner/node2_two_btn.dart index 46e976c..13335d1 100644 --- a/lib/widget_system/widgets/StatelessWidget/MaterialBanner/node2_two_btn.dart +++ b/lib/widget_system/widgets/StatelessWidget/MaterialBanner/node2_two_btn.dart @@ -12,45 +12,49 @@ import 'package:flutter/material.dart'; // "当尾部组件数量大于1,该组件结构为左中下。", // } class MaterialBannerDemoTwo extends StatelessWidget { - final info = + const MaterialBannerDemoTwo({Key? key}) : super(key: key); + + final String info = 'A banner displays an important, succinct message, and provides actions for users to address. ' 'A user action is required for itto be dismissed.'; @override Widget build(BuildContext context) { return Column( - children: [MaterialBanner( - content: Text( - info, - style: TextStyle(color: Colors.white), - ), - backgroundColor: Colors.purple, - leading: Icon(Icons.warning, color: Colors.yellow), - padding: EdgeInsetsDirectional.only(start: 16.0, top: 2.0,end: 2), - leadingPadding:EdgeInsetsDirectional.only(end: 16.0) , - actions: [ - RaisedButton( - color: Colors.white, - onPressed: () {}, - child: Text( - 'I KNOW', - style: TextStyle( - color: Colors.purple, - fontWeight: FontWeight.bold, - fontSize: 14), - ), + children: [ + MaterialBanner( + content: Text( + info, + style: const TextStyle(color: Colors.white), + ), + backgroundColor: Colors.purple, + leading: const Icon(Icons.warning, color: Colors.yellow), + padding: + const EdgeInsetsDirectional.only(start: 16.0, top: 2.0, end: 2), + leadingPadding: const EdgeInsetsDirectional.only(end: 16.0), + actions: [ + RaisedButton( + color: Colors.white, + onPressed: () {}, + child: const Text( + 'I KNOW', + style: TextStyle( + color: Colors.purple, + fontWeight: FontWeight.bold, + fontSize: 14), + ), ), RaisedButton( color: Colors.white, onPressed: () {}, - child: Text( - 'I IGNORE', - style: TextStyle( - color: Colors.purple, - fontWeight: FontWeight.bold, - fontSize: 14), - ), + child: const Text( + 'I IGNORE', + style: TextStyle( + color: Colors.purple, + fontWeight: FontWeight.bold, + fontSize: 14), + ), ), ], )], diff --git a/lib/widget_system/widgets/StatelessWidget/MaterialButton/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/MaterialButton/node1_base.dart index 9e3c20e..ad46dc9 100644 --- a/lib/widget_system/widgets/StatelessWidget/MaterialButton/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/MaterialButton/node1_base.dart @@ -20,6 +20,8 @@ import 'package:flutter/material.dart'; // } class CustomMaterialButton extends StatelessWidget { + const CustomMaterialButton({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return MaterialButton( @@ -28,8 +30,8 @@ class CustomMaterialButton extends StatelessWidget { color: Colors.orangeAccent, textColor: Colors.white, splashColor: Colors.blue, - padding: EdgeInsets.all(8), - child: Text("MaterialButton"), - onPressed: () => Navigator.of(context).pushNamed('AboutMePage')); + padding: const EdgeInsets.all(8), + child: const Text("MaterialButton"), + onPressed: () => Navigator.of(context).pushNamed('AboutMePage')); } } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/MaterialButton/node2_onLongPress.dart b/lib/widget_system/widgets/StatelessWidget/MaterialButton/node2_onLongPress.dart index b033435..fba95a7 100644 --- a/lib/widget_system/widgets/StatelessWidget/MaterialButton/node2_onLongPress.dart +++ b/lib/widget_system/widgets/StatelessWidget/MaterialButton/node2_onLongPress.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; // } class LongPressMaterialButton extends StatelessWidget { + const LongPressMaterialButton({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return MaterialButton( @@ -21,8 +23,8 @@ class LongPressMaterialButton extends StatelessWidget { color: Colors.blue, highlightColor: Colors.green, textColor: Colors.white, - padding: EdgeInsets.all(8), - child: Text("MaterialButton"), + padding: const EdgeInsets.all(8), + child: const Text("MaterialButton"), onLongPress: () => Navigator.of(context).pushNamed('AboutMePage'), onPressed: () => Navigator.of(context).pushNamed('AboutMePage')); } diff --git a/lib/widget_system/widgets/StatelessWidget/MaterialButton/node3_shape.dart b/lib/widget_system/widgets/StatelessWidget/MaterialButton/node3_shape.dart index 6a1dada..e31e5c9 100644 --- a/lib/widget_system/widgets/StatelessWidget/MaterialButton/node3_shape.dart +++ b/lib/widget_system/widgets/StatelessWidget/MaterialButton/node3_shape.dart @@ -12,46 +12,48 @@ import 'package:flutter/material.dart'; // } class ShapeMaterialButton extends StatelessWidget { + const ShapeMaterialButton({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Wrap( spacing: 20, children: [ - Container( + SizedBox( width: 40, height: 40, child: MaterialButton( - padding: EdgeInsets.all(0), - textColor: Color(0xffFfffff), + padding: const EdgeInsets.all(0), + textColor: const Color(0xffFfffff), elevation: 3, color: Colors.blue, - highlightColor: Color(0xffF88B0A), + highlightColor: const Color(0xffF88B0A), splashColor: Colors.red, - child: Icon( + child: const Icon( Icons.add, color: Colors.white, ), - shape: CircleBorder( + shape: const CircleBorder( side: BorderSide(width: 2.0, color: Color(0xFFFFDFDFDF)), ), onLongPress: () => Navigator.of(context).pushNamed('AboutMePage'), onPressed: () => Navigator.of(context).pushNamed('AboutMePage')), ), - Container( + SizedBox( width: 100, height: 40, child: MaterialButton( - padding: EdgeInsets.all(0), - textColor: Color(0xffFfffff), + padding: const EdgeInsets.all(0), + textColor: const Color(0xffFfffff), elevation: 3, color: Colors.blue, - highlightColor: Color(0xffF88B0A), + highlightColor: const Color(0xffF88B0A), splashColor: Colors.red, - child: Icon( + child: const Icon( Icons.remove, color: Colors.white, ), - shape: RoundedRectangleBorder( + shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(15))), onLongPress: () => Navigator.of(context).pushNamed('AboutMePage'), onPressed: () => Navigator.of(context).pushNamed('AboutMePage')), diff --git a/lib/widget_system/widgets/StatelessWidget/ModalBarrier/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/ModalBarrier/node1_base.dart index 8f5f2cd..bdabc29 100644 --- a/lib/widget_system/widgets/StatelessWidget/ModalBarrier/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/ModalBarrier/node1_base.dart @@ -14,10 +14,12 @@ import 'package:flutter/material.dart'; // "【color】 : 颜色 【Color】", // } class ModalBarrierDemo extends StatelessWidget { + const ModalBarrierDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: 200, height: 100, child: Stack(alignment: Alignment.center, children: [ @@ -25,7 +27,7 @@ class ModalBarrierDemo extends StatelessWidget { dismissible: true, color: Colors.grey.withOpacity(0.3), ), - Text('点击背景返回') + const Text('点击背景返回') ]), ); } diff --git a/lib/widget_system/widgets/StatelessWidget/NavigationToolbar/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/NavigationToolbar/node1_base.dart index 669157e..7789c81 100644 --- a/lib/widget_system/widgets/StatelessWidget/NavigationToolbar/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/NavigationToolbar/node1_base.dart @@ -14,12 +14,14 @@ import 'package:flutter/material.dart'; // "【middleSpacing】: 中间组件距左距离 【double】", // } class NavigationToolbarDemo extends StatelessWidget { + const NavigationToolbarDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Column( mainAxisSize: MainAxisSize.min, - children: [ - Container( + children: const [ + SizedBox( height: 60, child: NavigationToolbar( leading: Icon(Icons.ac_unit), @@ -29,7 +31,7 @@ class NavigationToolbarDemo extends StatelessWidget { trailing: Icon(Icons.more_vert), ), ), - Container( + SizedBox( height: 60, child: NavigationToolbar( leading: Icon(Icons.ac_unit), diff --git a/lib/widget_system/widgets/StatelessWidget/NotificationListener/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/NotificationListener/node1_base.dart index 87e932b..b67ec4b 100644 --- a/lib/widget_system/widgets/StatelessWidget/NotificationListener/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/NotificationListener/node1_base.dart @@ -12,6 +12,8 @@ import 'package:flutter/material.dart'; // } class NotificationListenerDemo extends StatefulWidget { + const NotificationListenerDemo({Key? key}) : super(key: key); + @override _NotificationListenerDemoState createState() => _NotificationListenerDemoState(); } @@ -21,7 +23,7 @@ class _NotificationListenerDemoState extends State { @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 250, child: NotificationListener( onNotification: _onNotification, @@ -29,7 +31,7 @@ class _NotificationListenerDemoState extends State { child: ListView.separated( itemBuilder: _buildItem, itemCount: data.length, - separatorBuilder: (_,__)=>Divider(height: 5,), + separatorBuilder: (_,__)=>const Divider(height: 5,), ), )), ); @@ -37,15 +39,15 @@ class _NotificationListenerDemoState extends State { bool _onNotification(OverscrollIndicatorNotification notification) { if (notification.leading) { - notification.disallowGlow(); - Scaffold.of(context).showSnackBar(SnackBar( + notification.disallowIndicator(); + Scaffold.of(context).showSnackBar(const SnackBar( content: Text('已滑到顶部'), backgroundColor: Colors.blue, duration: Duration(milliseconds: 200), )); } else { - notification.disallowGlow(); - Scaffold.of(context).showSnackBar(SnackBar( + notification.disallowIndicator(); + Scaffold.of(context).showSnackBar(const SnackBar( content: Text('已滑到底部'), duration: Duration(milliseconds: 200), backgroundColor: Colors.blue, diff --git a/lib/widget_system/widgets/StatelessWidget/NotificationListener/node2_update.dart b/lib/widget_system/widgets/StatelessWidget/NotificationListener/node2_update.dart index 40e0fa8..990f803 100644 --- a/lib/widget_system/widgets/StatelessWidget/NotificationListener/node2_update.dart +++ b/lib/widget_system/widgets/StatelessWidget/NotificationListener/node2_update.dart @@ -12,6 +12,8 @@ import 'package:flutter/material.dart'; // } class NotificationListenerUpdate extends StatefulWidget { + const NotificationListenerUpdate({Key? key}) : super(key: key); + @override _NotificationListenerUpdateState createState() => _NotificationListenerUpdateState(); @@ -19,18 +21,19 @@ class NotificationListenerUpdate extends StatefulWidget { class _NotificationListenerUpdateState extends State { - final data = List.generate(30, (i) => '第${i + 1}条'); + final List data = List.generate(30, (i) => '第${i + 1}条'); - var _info = ''; + String _info = ''; @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 300, child: Stack( children: [ - Positioned(child: Padding( - padding: const EdgeInsets.only(left:8.0), + Positioned( + child: Padding( + padding: const EdgeInsets.only(left: 8.0), child: Text(_info), )), NotificationListener( @@ -39,9 +42,7 @@ class _NotificationListenerUpdateState child: ListView.separated( itemBuilder: _buildItem, itemCount: data.length, - separatorBuilder: (_, __) => Divider( - height: 5, - ), + separatorBuilder: (_, __) => const Divider(height: 5), ), )), @@ -51,7 +52,6 @@ class _NotificationListenerUpdateState } bool _onNotification(ScrollUpdateNotification notification) { - setState(() { _info = 'axis------【${notification.metrics.axis}】------\n' 'pixels------【${notification.metrics.pixels}】------\n' @@ -67,9 +67,7 @@ class _NotificationListenerUpdateState 'localPosition------【${notification.dragDetails?.localPosition}】------\n' 'scrollDelta------【${notification.scrollDelta}】------\n' 'depth------【${notification.depth}】------'; - }); - return true; } @@ -77,7 +75,7 @@ class _NotificationListenerUpdateState return Container( height: 50, alignment: Alignment.centerRight, - padding: EdgeInsets.only(right: 8), + padding: const EdgeInsets.only(right: 8), child: Text( data[index], style: TextStyle(color: Theme.of(context).primaryColor, fontSize: 18), diff --git a/lib/widget_system/widgets/StatelessWidget/OrientationBuilder/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/OrientationBuilder/node1_base.dart index dacb663..7ca4b54 100644 --- a/lib/widget_system/widgets/StatelessWidget/OrientationBuilder/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/OrientationBuilder/node1_base.dart @@ -10,6 +10,8 @@ import 'package:flutter/material.dart'; // "subtitle": "【builder】 : 方向组件构造器 【OrientationWidgetBuilder】", // } class OrientationBuilderDemo extends StatefulWidget { + const OrientationBuilderDemo({Key? key}) : super(key: key); + @override _OrientationBuilderDemoState createState() => _OrientationBuilderDemoState(); } @@ -36,12 +38,12 @@ class _OrientationBuilderDemoState extends State { Widget _builder(BuildContext context, Orientation orientation) { switch(orientation){ case Orientation.portrait: - return Icon(Icons.phone_android,size: 60,); + return const Icon(Icons.phone_android,size: 60,); break; case Orientation.landscape: - return RotatedBox( + return const RotatedBox( quarterTurns: 1, - child: Icon(Icons.phone_android,size: 60,)); + child: const Icon(Icons.phone_android,size: 60,)); break; default: return Container(); } diff --git a/lib/widget_system/widgets/StatelessWidget/OutlineButton/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/OutlineButton/node1_base.dart index 3f9c9f9..1b6a48a 100755 --- a/lib/widget_system/widgets/StatelessWidget/OutlineButton/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/OutlineButton/node1_base.dart @@ -18,17 +18,19 @@ import 'package:flutter/material.dart'; // } class CustomOutlineButton extends StatelessWidget { + const CustomOutlineButton({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return OutlineButton(//边线按钮 onPressed: () {}, - child: Text("OutlineButton"), - padding: EdgeInsets.all(8), + child: const Text("OutlineButton"), + padding: const EdgeInsets.all(8), splashColor: Colors.green, highlightColor: Colors.orangeAccent, highlightedBorderColor: Colors.grey, - textColor: Color(0xff000000), - borderSide: BorderSide(color: Color(0xff0A66F8), width: 2), + textColor: const Color(0xff000000), + borderSide: const BorderSide(color: Color(0xff0A66F8), width: 2), ); } } diff --git a/lib/widget_system/widgets/StatelessWidget/PageStorage/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/PageStorage/node1_base.dart index 143cd32..7e533ea 100644 --- a/lib/widget_system/widgets/StatelessWidget/PageStorage/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/PageStorage/node1_base.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; // } class PageStorageDemo extends StatefulWidget { + const PageStorageDemo({Key? key}) : super(key: key); + @override _PageStorageDemoState createState() => _PageStorageDemoState(); } @@ -23,7 +25,7 @@ class _PageStorageDemoState extends State { @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, child: Scaffold( body: PageStorage( @@ -39,7 +41,7 @@ class _PageStorageDemoState extends State { _pageIndex = index; }); }, - items: [ + items: const [ BottomNavigationBarItem( icon: Icon(Icons.home), label: 'Home', @@ -56,11 +58,11 @@ class _PageStorageDemoState extends State { Widget _buildContentByIndex() { if (_pageIndex == 0) { - return CountWidget(key: PageStorageKey('CountWidget1')); + return const CountWidget(key: PageStorageKey('CountWidget1')); } if (_pageIndex == 1) { - return CountWidget(key: PageStorageKey('CountWidget2')); + return const CountWidget(key: PageStorageKey('CountWidget2')); } return ListView(); @@ -68,7 +70,7 @@ class _PageStorageDemoState extends State { } class CountWidget extends StatefulWidget { - CountWidget({Key? key}) : super(key: key); + const CountWidget({Key? key}) : super(key: key); @override _CountWidgetState createState() => _CountWidgetState(); @@ -93,12 +95,12 @@ class _CountWidgetState extends State { Text('点击了$_count次'), MaterialButton( onPressed: _addCount, - child: Icon( + child: const Icon( Icons.add, color: Colors.white, ), color: Colors.green, - shape: CircleBorder( + shape: const CircleBorder( side: BorderSide(width: 2.0, color: Color(0xFFFFDFDFDF)), )) ], diff --git a/lib/widget_system/widgets/StatelessWidget/Placeholder/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/Placeholder/node1_base.dart index aee4a58..c7f8f68 100644 --- a/lib/widget_system/widgets/StatelessWidget/Placeholder/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/Placeholder/node1_base.dart @@ -11,9 +11,11 @@ import 'package:flutter/material.dart'; // "【strokeWidth】: 线粗 【double】", // } class CustomPlaceholder extends StatelessWidget { + const CustomPlaceholder({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return const SizedBox( width: 100, height: 100*0.618, child: Placeholder( diff --git a/lib/widget_system/widgets/StatelessWidget/Placeholder/node2_fallback.dart b/lib/widget_system/widgets/StatelessWidget/Placeholder/node2_fallback.dart index bed98ef..6303067 100644 --- a/lib/widget_system/widgets/StatelessWidget/Placeholder/node2_fallback.dart +++ b/lib/widget_system/widgets/StatelessWidget/Placeholder/node2_fallback.dart @@ -12,9 +12,11 @@ import 'package:flutter/material.dart'; // "【fallbackWidth】: 宽 【double】", // } class FallbackPlaceholder extends StatelessWidget { + const FallbackPlaceholder({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return UnconstrainedBox( + return const UnconstrainedBox( child: Placeholder( color: Colors.blue, strokeWidth: 2, diff --git a/lib/widget_system/widgets/StatelessWidget/PositionedDirectional/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/PositionedDirectional/node1_base.dart index 2dc195f..6e5e15b 100644 --- a/lib/widget_system/widgets/StatelessWidget/PositionedDirectional/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/PositionedDirectional/node1_base.dart @@ -16,27 +16,29 @@ import 'package:flutter/material.dart'; // "【bottom】 : 到父底距离 【double】", // } class CustomPositionedDirectional extends StatelessWidget { + const CustomPositionedDirectional({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - var yellowBox = Container( + Widget yellowBox = Container( color: Colors.yellow, height: 100, width: 100, ); - var redBox = Container( + Widget redBox = Container( color: Colors.red, height: 90, width: 90, ); - var greenBox = Container( + Widget greenBox = Container( color: Colors.green, height: 80, width: 80, ); - var cyanBox = Container( + Widget cyanBox = Container( color: Colors.cyanAccent, height: 70, width: 70, diff --git a/lib/widget_system/widgets/StatelessWidget/PreferredSize/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/PreferredSize/node1_base.dart index 7b52570..bad7a86 100644 --- a/lib/widget_system/widgets/StatelessWidget/PreferredSize/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/PreferredSize/node1_base.dart @@ -10,15 +10,17 @@ import 'package:flutter/material.dart'; // "subtitle": "【preferredSize】 : 尺寸 【Size】", // } class CustomPreferredSize extends StatelessWidget { + const CustomPreferredSize({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, child: Scaffold( appBar: PreferredSize( - preferredSize: Size.fromHeight(150), + preferredSize: const Size.fromHeight(150), child: AppBar( - title: Text('PreferredSize'), + title: const Text('PreferredSize'), ), ), ), diff --git a/lib/widget_system/widgets/StatelessWidget/PreferredSize/node2_adapter.dart b/lib/widget_system/widgets/StatelessWidget/PreferredSize/node2_adapter.dart index 60cee0a..1202bbf 100644 --- a/lib/widget_system/widgets/StatelessWidget/PreferredSize/node2_adapter.dart +++ b/lib/widget_system/widgets/StatelessWidget/PreferredSize/node2_adapter.dart @@ -10,17 +10,19 @@ import 'package:flutter/material.dart'; // "subtitle": "【PreferredSize将普通组件转化为PreferredSizeWidget", // } class AdapterPreferredSize extends StatelessWidget { + const AdapterPreferredSize({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, child: Scaffold( appBar: PreferredSize( - preferredSize: Size.fromHeight(150), + preferredSize: const Size.fromHeight(150), child: AppBar( - title: Text('PreferredSize'), + title: const Text('PreferredSize'), bottom: PreferredSize( - preferredSize: Size.fromHeight(40), + preferredSize: const Size.fromHeight(40), child: Container( height: 40, color: Colors.orange, diff --git a/lib/widget_system/widgets/StatelessWidget/RadioListTile/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/RadioListTile/node1_base.dart index 4187b89..1ed6c0a 100644 --- a/lib/widget_system/widgets/StatelessWidget/RadioListTile/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/RadioListTile/node1_base.dart @@ -32,6 +32,8 @@ class ItemBean { } class CustomRadioListTile extends StatefulWidget { + const CustomRadioListTile({Key? key}) : super(key: key); + @override _CustomRadioListTileState createState() => _CustomRadioListTileState(); } diff --git a/lib/widget_system/widgets/StatelessWidget/RadioListTile/node2_dense.dart b/lib/widget_system/widgets/StatelessWidget/RadioListTile/node2_dense.dart index e3c715d..ddaa90f 100644 --- a/lib/widget_system/widgets/StatelessWidget/RadioListTile/node2_dense.dart +++ b/lib/widget_system/widgets/StatelessWidget/RadioListTile/node2_dense.dart @@ -27,6 +27,8 @@ class ItemBean { } class DenseRadioListTile extends StatefulWidget { + const DenseRadioListTile({Key? key}) : super(key: key); + @override _DenseRadioListTileState createState() => _DenseRadioListTileState(); } diff --git a/lib/widget_system/widgets/StatelessWidget/RaisedButton/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/RaisedButton/node1_base.dart index ffa0444..1530875 100755 --- a/lib/widget_system/widgets/StatelessWidget/RaisedButton/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/RaisedButton/node1_base.dart @@ -18,17 +18,19 @@ import 'package:flutter/material.dart'; // } class CustomRaisedButton extends StatelessWidget { + const CustomRaisedButton({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return RaisedButton( color: Colors.blue, splashColor: Colors.green, onPressed: () {}, - child: Text("RaisedButton"), - textColor: Color(0xffFfffff), - padding: EdgeInsets.all(8), + child: const Text("RaisedButton"), + textColor: const Color(0xffFfffff), + padding: const EdgeInsets.all(8), elevation: 5, - highlightColor: Color(0xffF88B0A), + highlightColor: const Color(0xffF88B0A), ); } } diff --git a/lib/widget_system/widgets/StatelessWidget/SafeArea/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/SafeArea/node1_base.dart index 3702067..afd775c 100644 --- a/lib/widget_system/widgets/StatelessWidget/SafeArea/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/SafeArea/node1_base.dart @@ -16,10 +16,12 @@ import 'package:flutter/material.dart'; // } class SafeAreaDemo extends StatelessWidget { + const SafeAreaDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Container( - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), child: ElevatedButton( onPressed: () { Navigator.push( @@ -27,13 +29,15 @@ class SafeAreaDemo extends StatelessWidget { MaterialPageRoute(builder: (context) => SafeAreaPage()), ); }, - child: Text("进入 SafeArea 测试页"), + child: const Text("进入 SafeArea 测试页"), ), ); } } class SafeAreaPage extends StatefulWidget { + const SafeAreaPage({Key? key}) : super(key: key); + @override _SafeAreaPageState createState() => _SafeAreaPageState(); } @@ -53,7 +57,7 @@ class _SafeAreaPageState extends State { bottom: _bottom, child: Scaffold( appBar: AppBar( - title: Text( + title: const Text( 'SafeArea 测试', ), ), @@ -63,7 +67,7 @@ class _SafeAreaPageState extends State { Expanded( child: ListView.separated( itemCount: 20, - separatorBuilder: (_, __) => Divider( + separatorBuilder: (_, __) => const Divider( height: 1, ), itemBuilder: (_, index) => Container( @@ -73,7 +77,7 @@ class _SafeAreaPageState extends State { height: 50, child: Text( "第$index个", - style: TextStyle(fontSize: 24, color: Colors.white), + style: const TextStyle(fontSize: 24, color: Colors.white), ), ), ), diff --git a/lib/widget_system/widgets/StatelessWidget/ScrollView/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/ScrollView/node1_base.dart index d03eba5..1f2f7df 100644 --- a/lib/widget_system/widgets/StatelessWidget/ScrollView/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/ScrollView/node1_base.dart @@ -20,6 +20,8 @@ import 'package:flutter/material.dart'; // } class ScrollViewDemo extends StatelessWidget { + const ScrollViewDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Container( @@ -30,6 +32,8 @@ class ScrollViewDemo extends StatelessWidget { } class MyScrollView extends ScrollView { + MyScrollView({Key? key}) : super(key: key); + final String info = 'ScrollView 其内部依靠 Viewport + Scrollable 实现滑动。它只有一个 buildSlivers 的抽象方法,返回 Sliver 家族 Widget 列表,' '其子类最简单的是 CustomScrollView,将 slivers 交由用户传递,自身打个酱油。' @@ -55,8 +59,8 @@ class MyScrollView extends ScrollView { SliverToBoxAdapter( child: Container( color: Colors.blue.withOpacity(0.1), - padding: EdgeInsets.all(10), - margin: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), + margin: const EdgeInsets.all(10), child: Text(info), ), ), @@ -68,13 +72,12 @@ class MyScrollView extends ScrollView { return SliverAppBar( expandedHeight: 190.0, leading: Container( - margin: EdgeInsets.all(10), + margin: const EdgeInsets.all(10), child: Image.asset('assets/images/icon_head.webp')), - flexibleSpace: FlexibleSpaceBar( - //伸展处布局 - titlePadding: EdgeInsets.only(left: 55, bottom: 15), //标题边距 + flexibleSpace: FlexibleSpaceBar(//伸展处布局 + titlePadding: const EdgeInsets.only(left: 55, bottom: 15), //标题边距 collapseMode: CollapseMode.parallax, //视差效果 - title: Text( + title: const Text( '张风捷特烈', style: TextStyle(color: Colors.black, //标题 shadows: [ @@ -99,7 +102,7 @@ class MyScrollView extends ScrollView { color: data[index], child: Text( colorString(data[index]), - style: TextStyle(color: Colors.white, shadows: [ + style: const TextStyle(color: Colors.white, shadows: [ Shadow( color: Colors.black, offset: Offset(.5, .5), diff --git a/lib/widget_system/widgets/StatelessWidget/SimpleDialog/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/SimpleDialog/node1_base.dart index e1ebf37..e4f8fc4 100644 --- a/lib/widget_system/widgets/StatelessWidget/SimpleDialog/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/SimpleDialog/node1_base.dart @@ -20,7 +20,9 @@ import 'package:flutter/material.dart'; // "【shape】 : 影深 【double】", // } class CustomSimpleDialog extends StatelessWidget { - final info = [ + const CustomSimpleDialog({Key? key}) : super(key: key); + + final List info = const [ '性别: 男 未婚', '微信: zdl1994328', "掘金: 张风捷特烈", @@ -42,32 +44,32 @@ class CustomSimpleDialog extends StatelessWidget { ); } Widget _buildRaisedButton(BuildContext context) => RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(10))), + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(10))), color: Colors.blue, onPressed: () { showDialog(context: context, builder: (ctx) => _buildSimpleDialog(ctx)); }, - child: Text( - 'Just Show It', - style: TextStyle(color: Colors.white), - ), + child: const Text( + 'Just Show It', + style: TextStyle(color: Colors.white), + ), ); SimpleDialog _buildSimpleDialog(BuildContext context) { return SimpleDialog( - title: _buildTitle(), - titlePadding: EdgeInsets.only( - top: 5, - left: 20, - ), - contentPadding: EdgeInsets.symmetric(horizontal: 5), - children: _buildChild(context), - backgroundColor: Colors.white, - elevation: 4, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(10))), - ); + title: _buildTitle(), + titlePadding: const EdgeInsets.only( + top: 5, + left: 20, + ), + contentPadding: const EdgeInsets.symmetric(horizontal: 5), + children: _buildChild(context), + backgroundColor: Colors.white, + elevation: 4, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(10))), + ); } List _buildChild(BuildContext context) { @@ -77,11 +79,12 @@ class CustomSimpleDialog extends StatelessWidget { children: [ SimpleDialogOption( onPressed: () => print(str), - child: Container( + child: SizedBox( width: double.infinity, child: Text( str, - style: TextStyle(color: Color(0xff999999), fontSize: 16), + style: const TextStyle( + color: Color(0xff999999), fontSize: 16), ), ), ), @@ -98,23 +101,22 @@ class CustomSimpleDialog extends StatelessWidget { } Widget _buildTitle() { - return Row( - //标题 + return Row(//标题 children: [ Image.asset( "assets/images/icon_head.webp", width: 30, height: 30, ), - SizedBox( + const SizedBox( width: 10, ), - Expanded( + const Expanded( child: Text( "张风捷特烈", style: TextStyle(fontSize: 18), )), - CloseButton() + const CloseButton() ], ); } diff --git a/lib/widget_system/widgets/StatelessWidget/SimpleDialogOption/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/SimpleDialogOption/node1_base.dart index 321f27c..b980966 100644 --- a/lib/widget_system/widgets/StatelessWidget/SimpleDialogOption/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/SimpleDialogOption/node1_base.dart @@ -12,6 +12,8 @@ import 'package:flutter/material.dart'; // "【onPressed】 : 点击事件 【Function()】", // } class CustomSimpleDialogOption extends StatelessWidget { + const CustomSimpleDialogOption({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Column( @@ -20,21 +22,21 @@ class CustomSimpleDialogOption extends StatelessWidget { alignment: Alignment.center, width: double.infinity, height: 50, - margin: EdgeInsets.all(5), + margin: const EdgeInsets.all(5), color: Colors.grey.withAlpha(33), child: SimpleDialogOption( onPressed: () => Navigator.of(context).pushNamed('AboutMePage'), - child: Text('张风捷特烈')), + child: const Text('张风捷特烈')), ), Container( height: 50, alignment: Alignment.center, width: double.infinity, color: Colors.grey.withAlpha(33), - margin: EdgeInsets.all(5), + margin: const EdgeInsets.all(5), child: SimpleDialogOption( onPressed: () => Navigator.of(context).pushNamed('AboutMePage'), - child: Text('百里·巫缨')), + child: const Text('百里·巫缨')), ), ], ); diff --git a/lib/widget_system/widgets/StatelessWidget/SingleChildScrollView/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/SingleChildScrollView/node1_base.dart index e9f748b..f6cf541 100644 --- a/lib/widget_system/widgets/StatelessWidget/SingleChildScrollView/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/SingleChildScrollView/node1_base.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; // "【padding】 : 内边距 【EdgeInsetsGeometry】", // } class CustomSingleChildScrollView extends StatelessWidget { + CustomSingleChildScrollView({Key? key}) : super(key: key); + final List data = [ Colors.blue[50]!, Colors.blue[100]!, @@ -26,34 +28,41 @@ class CustomSingleChildScrollView extends StatelessWidget { Colors.blue[900]!, ]; + TextStyle get textStyle => const TextStyle( + color: Colors.white, + shadows: [ + Shadow( + color: Colors.black, + offset: Offset(.5, .5), + blurRadius: 2, + ) + ], + ); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, child: SingleChildScrollView( - padding: EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric(horizontal: 10), child: Column( children: data .map((color) => Container( - alignment: Alignment.center, - height: 50, - color: color, - child: Text( - colorString(color), - style: TextStyle(color: Colors.white, shadows: [ - Shadow( - color: Colors.black, - offset: Offset(.5, .5), - blurRadius: 2) - ]), - ), - )) + alignment: Alignment.center, + height: 50, + color: color, + child: Text( + colorString(color), + style: textStyle, + ), + )) .toList(), ), ), ); } + String colorString(Color color) => "#${color.value.toRadixString(16).padLeft(8, '0').toUpperCase()}"; } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/SingleChildScrollView/node2_direction.dart b/lib/widget_system/widgets/StatelessWidget/SingleChildScrollView/node2_direction.dart index 6c68e42..7e255e8 100644 --- a/lib/widget_system/widgets/StatelessWidget/SingleChildScrollView/node2_direction.dart +++ b/lib/widget_system/widgets/StatelessWidget/SingleChildScrollView/node2_direction.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; // "【reverse】 : 是否反向 【Axis】", // } class DirectionSingleChildScrollView extends StatelessWidget { + DirectionSingleChildScrollView({Key? key}) : super(key: key); + final List data = [ Colors.blue[50]!, Colors.blue[100]!, @@ -26,36 +28,43 @@ class DirectionSingleChildScrollView extends StatelessWidget { Colors.blue[900]!, ]; + TextStyle get textStyle => const TextStyle( + color: Colors.white, + shadows: [ + Shadow( + color: Colors.black, + offset: Offset(.5, .5), + blurRadius: 2, + ) + ], + ); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, child: SingleChildScrollView( scrollDirection: Axis.horizontal, reverse: true, - padding: EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric(horizontal: 10), child: Row( children: data .map((color) => Container( - alignment: Alignment.center, - width: 90, - color: color, - child: Text( - colorString(color), - style: TextStyle(color: Colors.white, shadows: [ - Shadow( - color: Colors.black, - offset: Offset(.5, .5), - blurRadius: 2) - ]), - ), - )) + alignment: Alignment.center, + width: 90, + color: color, + child: Text( + colorString(color), + style: textStyle, + ), + )) .toList(), ), ), ); } + String colorString(Color color) => "#${color.value.toRadixString(16).padLeft(8, '0').toUpperCase()}"; } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/SnackBar/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/SnackBar/node1_base.dart index c3bb710..dbbca9a 100644 --- a/lib/widget_system/widgets/StatelessWidget/SnackBar/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/SnackBar/node1_base.dart @@ -17,6 +17,8 @@ import 'package:flutter/material.dart'; // "【onVisible】 : 显示时回调 【Function()】", // } class CustomSnackBar extends StatefulWidget { + const CustomSnackBar({Key? key}) : super(key: key); + @override _CustomSnackBarState createState() => _CustomSnackBarState(); } @@ -24,25 +26,24 @@ class CustomSnackBar extends StatefulWidget { class _CustomSnackBarState extends State { @override Widget build(BuildContext context) { - return Container( - child: FlatButton( - color: Colors.blue, - onPressed: () => - Scaffold.of(context).showSnackBar(_buildSnackBar()), - child: Text( - '点我弹出SnackBar', - style: TextStyle(color: Colors.white), - ))); + return FlatButton( + color: Colors.blue, + onPressed: () => + Scaffold.of(context).showSnackBar(_buildSnackBar()), + child: const Text( + '点我弹出SnackBar', + style: TextStyle(color: Colors.white), + )); } SnackBar _buildSnackBar() { return SnackBar( elevation: 3, - shape: RoundedRectangleBorder( + shape: const RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(10), topRight: Radius.circular(10))), - content: Text('Wellcome to for join Flutter Unit!'), - duration: Duration(seconds: 3), + content: const Text('Wellcome to for join Flutter Unit!'), + duration: const Duration(seconds: 3), //持续时间 backgroundColor: Colors.red, onVisible: () => print('onVisible'), diff --git a/lib/widget_system/widgets/StatelessWidget/SnackBarAction/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/SnackBarAction/node1_base.dart index f15db88..2e8fa36 100644 --- a/lib/widget_system/widgets/StatelessWidget/SnackBarAction/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/SnackBarAction/node1_base.dart @@ -14,13 +14,15 @@ import 'package:flutter/material.dart'; // "【onPressed】 : 点击回调 【Function()】", // } class CustomSnackBarAction extends StatelessWidget { + const CustomSnackBarAction({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( - child: SnackBarAction( - disabledTextColor: Colors.red, - textColor: Colors.blue, - label: '确定', - onPressed: () => print('onPressed'))); + return SnackBarAction( + disabledTextColor: Colors.red, + textColor: Colors.blue, + label: '确定', + onPressed: () => print('onPressed'), + ); } } diff --git a/lib/widget_system/widgets/StatelessWidget/Spacer/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/Spacer/node1_base.dart index 1fa5e3b..8423188 100644 --- a/lib/widget_system/widgets/StatelessWidget/Spacer/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/Spacer/node1_base.dart @@ -12,6 +12,7 @@ import 'package:flutter/material.dart'; // "一个Spacer会占据可延伸区域", // } class OneSpacer extends StatelessWidget { + const OneSpacer({Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -25,7 +26,7 @@ class OneSpacer extends StatelessWidget { height: 50, color: Colors.red, ), - Spacer(), + const Spacer(), Container( alignment: Alignment.center, width: 60, diff --git a/lib/widget_system/widgets/StatelessWidget/Spacer/node2_flex.dart b/lib/widget_system/widgets/StatelessWidget/Spacer/node2_flex.dart index 0f90049..8ebdcbf 100644 --- a/lib/widget_system/widgets/StatelessWidget/Spacer/node2_flex.dart +++ b/lib/widget_system/widgets/StatelessWidget/Spacer/node2_flex.dart @@ -12,13 +12,15 @@ import 'package:flutter/material.dart'; // "【flex】 : 剩余空间分配占比 【int】", // } class ManySpacer extends StatefulWidget { + const ManySpacer({Key? key}) : super(key: key); + @override _ManySpacerState createState() => _ManySpacerState(); } class _ManySpacerState extends State { - int _flexA=1; - int _flexB=1; + int _flexA = 1; + int _flexB = 1; @override Widget build(BuildContext context) { diff --git a/lib/widget_system/widgets/StatelessWidget/SwitchListTile/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/SwitchListTile/node1_base.dart index 2a53db2..716cfad 100644 --- a/lib/widget_system/widgets/StatelessWidget/SwitchListTile/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/SwitchListTile/node1_base.dart @@ -17,6 +17,8 @@ import 'package:flutter/material.dart'; // "【onChanged】: 选中事件 【Function(bool)】", // } class CustomSwitchListTile extends StatefulWidget { + const CustomSwitchListTile({Key? key}) : super(key: key); + @override _CustomSwitchListTileState createState() => _CustomSwitchListTileState(); } @@ -27,7 +29,7 @@ class _CustomSwitchListTileState extends State { @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.all(10), + margin: const EdgeInsets.all(10), color: Colors.grey.withAlpha(22), child: SwitchListTile( value: _value, @@ -36,8 +38,8 @@ class _CustomSwitchListTileState extends State { activeColor: Colors.orangeAccent, activeTrackColor: Colors.orange, secondary: Image.asset("assets/images/icon_head.webp"), - title: Text("张风捷特烈"), - subtitle: Text("@万花过尽知无物"), + title: const Text("张风捷特烈"), + subtitle: const Text("@万花过尽知无物"), onChanged: (v) => setState(() => _value = !_value), ), ); diff --git a/lib/widget_system/widgets/StatelessWidget/SwitchListTile/node2_select.dart b/lib/widget_system/widgets/StatelessWidget/SwitchListTile/node2_select.dart index 2b3a1cf..577636b 100644 --- a/lib/widget_system/widgets/StatelessWidget/SwitchListTile/node2_select.dart +++ b/lib/widget_system/widgets/StatelessWidget/SwitchListTile/node2_select.dart @@ -13,27 +13,29 @@ import 'package:flutter/material.dart'; // "【activeThumbImage】: 选中时圆圈图片 【ImageProvider】", // } class SelectSwitchListTile extends StatefulWidget { + const SelectSwitchListTile({Key? key}) : super(key: key); + @override _SelectSwitchListTileState createState() => _SelectSwitchListTileState(); } class _SelectSwitchListTileState extends State { - var _value=false; + bool _value=false; @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.all(10), + margin: const EdgeInsets.all(10), color: Colors.grey.withAlpha(22), child: SwitchListTile( value: _value, selected: _value, activeColor: Colors.orangeAccent, secondary: Image.asset("assets/images/icon_head.webp"), - inactiveThumbImage: AssetImage("assets/images/pica.gif"), - activeThumbImage: AssetImage("assets/images/icon_head.webp"), - title: Text("张风捷特烈"), - subtitle: Text("@万花过尽知无物"), + inactiveThumbImage: const AssetImage("assets/images/pica.gif"), + activeThumbImage: const AssetImage("assets/images/icon_head.webp"), + title: const Text("张风捷特烈"), + subtitle: const Text("@万花过尽知无物"), onChanged: (v) => setState(() => _value = !_value), ), ); diff --git a/lib/widget_system/widgets/StatelessWidget/SwitchListTile/node3_dense.dart b/lib/widget_system/widgets/StatelessWidget/SwitchListTile/node3_dense.dart index 29d84b5..a34580a 100644 --- a/lib/widget_system/widgets/StatelessWidget/SwitchListTile/node3_dense.dart +++ b/lib/widget_system/widgets/StatelessWidget/SwitchListTile/node3_dense.dart @@ -11,17 +11,19 @@ import 'package:flutter/material.dart'; // "subtitle": "【dense】: 是否密排 【bool】", // } class DenseSwitchListTile extends StatefulWidget { + const DenseSwitchListTile({Key? key}) : super(key: key); + @override _DenseSwitchListTileState createState() => _DenseSwitchListTileState(); } class _DenseSwitchListTileState extends State { - var _value=false; + bool _value = false; @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.all(10), + margin: const EdgeInsets.all(10), color: Colors.grey.withAlpha(22), child: SwitchListTile( value: _value, @@ -29,8 +31,8 @@ class _DenseSwitchListTileState extends State { selected: _value, activeColor: Colors.orangeAccent, secondary: Image.asset("assets/images/icon_head.webp"), - title: Text("张风捷特烈"), - subtitle: Text("@万花过尽知无物"), + title: const Text("张风捷特烈"), + subtitle: const Text("@万花过尽知无物"), onChanged: (v) => setState(() => _value = !_value), ), ); diff --git a/lib/widget_system/widgets/StatelessWidget/Tab/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/Tab/node1_base.dart index 3ebd4b0..77d476b 100644 --- a/lib/widget_system/widgets/StatelessWidget/Tab/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/Tab/node1_base.dart @@ -16,26 +16,26 @@ import 'package:flutter/material.dart'; // } class CustomTab extends StatelessWidget { + const CustomTab({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Tab( - icon:Icon( Icons.add,color: Colors.blue,), - child: Text('添加'), - ), - Tab( - icon:Icon( Icons.close,color: Colors.red,), - text: '删除', - ), - Tab( - icon:Icon( Icons.refresh,color: Colors.green), - text: '更新', - ), - ], - ), + return Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: const [ + Tab( + icon:Icon( Icons.add,color: Colors.blue,), + child: Text('添加'), + ), + Tab( + icon:Icon( Icons.close,color: Colors.red,), + text: '删除', + ), + Tab( + icon:Icon( Icons.refresh,color: Colors.green), + text: '更新', + ), + ], ); } } diff --git a/lib/widget_system/widgets/StatelessWidget/TabBar/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/TabBar/node1_base.dart index 2d65120..56f0896 100644 --- a/lib/widget_system/widgets/StatelessWidget/TabBar/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/TabBar/node1_base.dart @@ -20,14 +20,16 @@ import 'package:flutter/material.dart'; // "【tabs】 : 标签组件 【List】", // } class CustomTabBar extends StatefulWidget { + const CustomTabBar({Key? key}) : super(key: key); + @override _CustomTabBarState createState() => _CustomTabBarState(); } class _CustomTabBarState extends State with SingleTickerProviderStateMixin { - final tabs = ['风画庭', '雨韵舍', '雷鸣殿', '电疾堂', '霜寒阁', '雪月楼']; - late TabController _tabController; + final List tabs = ['风画庭', '雨韵舍', '雷鸣殿', '电疾堂', '霜寒阁', '雪月楼']; + late TabController _tabController; @override void initState() { @@ -44,16 +46,14 @@ class _CustomTabBarState extends State @override Widget build(BuildContext context) { return TabBar( - onTap: (tab) { - print(tab); - }, - labelStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), - unselectedLabelStyle: TextStyle(fontSize: 16), + onTap: (tab) => print(tab), + labelStyle: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + unselectedLabelStyle: const TextStyle(fontSize: 16), isScrollable: true, controller: _tabController, labelColor: Colors.blue, indicatorWeight: 3, - indicatorPadding: EdgeInsets.symmetric(horizontal: 10), + indicatorPadding: const EdgeInsets.symmetric(horizontal: 10), unselectedLabelColor: Colors.grey, indicatorColor: Colors.orangeAccent, tabs: tabs.map((e) => Tab(text: e)).toList(), diff --git a/lib/widget_system/widgets/StatelessWidget/TabBar/node2_noShadow.dart b/lib/widget_system/widgets/StatelessWidget/TabBar/node2_noShadow.dart index e7c4058..6989752 100644 --- a/lib/widget_system/widgets/StatelessWidget/TabBar/node2_noShadow.dart +++ b/lib/widget_system/widgets/StatelessWidget/TabBar/node2_noShadow.dart @@ -12,13 +12,15 @@ import 'package:flutter/material.dart'; // "将Theme关于水波纹的颜色设置为透明即可。", // } class NoShadowTabBarDemo extends StatefulWidget { + const NoShadowTabBarDemo({Key? key}) : super(key: key); + @override _NSTabBarState createState() => _NSTabBarState(); } class _NSTabBarState extends State with SingleTickerProviderStateMixin { - final tabs = ['风画庭', '雨韵舍', '雷鸣殿', '电疾堂', '霜寒阁', '雪月楼']; + final List tabs = ['风画庭', '雨韵舍', '雷鸣殿', '电疾堂', '霜寒阁', '雪月楼']; late TabController _tabController; @override @@ -41,16 +43,14 @@ class _NSTabBarState extends State highlightColor: Colors.transparent, ), child: TabBar( - onTap: (tab) { - print(tab); - }, - labelStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), - unselectedLabelStyle: TextStyle(fontSize: 16), + onTap: (tab) => print(tab), + labelStyle: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + unselectedLabelStyle: const TextStyle(fontSize: 16), isScrollable: true, controller: _tabController, labelColor: Colors.blue, indicatorWeight: 3, - indicatorPadding: EdgeInsets.symmetric(horizontal: 10), + indicatorPadding: const EdgeInsets.symmetric(horizontal: 10), unselectedLabelColor: Colors.grey, indicatorColor: Colors.orangeAccent, tabs: tabs.map((e) => Tab(text: e)).toList(), diff --git a/lib/widget_system/widgets/StatelessWidget/TabPageSelector/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/TabPageSelector/node1_base.dart index d176e62..ab504e0 100644 --- a/lib/widget_system/widgets/StatelessWidget/TabPageSelector/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/TabPageSelector/node1_base.dart @@ -15,14 +15,16 @@ import 'package:flutter/material.dart'; // } class TabPageSelectorDemo extends StatefulWidget { + const TabPageSelectorDemo({Key? key}) : super(key: key); + @override _TabPageSelectorDemoState createState() => _TabPageSelectorDemoState(); } class _TabPageSelectorDemoState extends State with SingleTickerProviderStateMixin { - final tabs = ['风画庭', '雨韵舍', '雷鸣殿', '电疾堂', '霜寒阁', '雪月楼']; - late TabController _tabController; + final List tabs = ['风画庭', '雨韵舍', '雷鸣殿', '电疾堂', '霜寒阁', '雪月楼']; + late TabController _tabController; @override void initState() { @@ -38,7 +40,7 @@ class _TabPageSelectorDemoState extends State @override Widget build(BuildContext context) { - return Container( + return SizedBox( height: 200, child: Stack( alignment: Alignment.center, @@ -66,7 +68,7 @@ class _TabPageSelectorDemoState extends State .map((e) => Center( child: Text( e, - style: TextStyle(color: Colors.white, fontSize: 20), + style: const TextStyle(color: Colors.white, fontSize: 20), ))) .toList()); } diff --git a/lib/widget_system/widgets/StatelessWidget/TabPageSelectorIndicator/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/TabPageSelectorIndicator/node1_base.dart index fa94034..6b377b3 100644 --- a/lib/widget_system/widgets/StatelessWidget/TabPageSelectorIndicator/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/TabPageSelectorIndicator/node1_base.dart @@ -16,39 +16,39 @@ import 'package:flutter/material.dart'; // } class TabPageSelectorIndicatorDemo extends StatelessWidget { + const TabPageSelectorIndicatorDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - TabPageSelectorIndicator( - backgroundColor: Colors.greenAccent, - borderColor: Colors.deepPurpleAccent, - size: 15, - ), - TabPageSelectorIndicator( - backgroundColor: Colors.blue, - borderColor: Colors.grey, - size: 20, - ), - TabPageSelectorIndicator( - backgroundColor: Colors.green, - borderColor: Colors.red, - size: 25, - ), - TabPageSelectorIndicator( - backgroundColor: Colors.yellow, - borderColor: Colors.brown, - size: 30, - ), - TabPageSelectorIndicator( - backgroundColor: Colors.amber, - borderColor: Colors.purpleAccent, - size: 35, - ), - ], - ), + return Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children:const [ + TabPageSelectorIndicator( + backgroundColor: Colors.greenAccent, + borderColor: Colors.deepPurpleAccent, + size: 15, + ), + TabPageSelectorIndicator( + backgroundColor: Colors.blue, + borderColor: Colors.grey, + size: 20, + ), + TabPageSelectorIndicator( + backgroundColor: Colors.green, + borderColor: Colors.red, + size: 25, + ), + TabPageSelectorIndicator( + backgroundColor: Colors.yellow, + borderColor: Colors.brown, + size: 30, + ), + TabPageSelectorIndicator( + backgroundColor: Colors.amber, + borderColor: Colors.purpleAccent, + size: 35, + ), + ], ); } diff --git a/lib/widget_system/widgets/StatelessWidget/Text/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/Text/node1_base.dart index c49082d..fc27085 100644 --- a/lib/widget_system/widgets/StatelessWidget/Text/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/Text/node1_base.dart @@ -18,6 +18,8 @@ import 'package:flutter/material.dart'; // "【letterSpacing】: 字距 【double】", // } class CustomText extends StatelessWidget { + const CustomText({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { TextStyle style = const TextStyle( diff --git a/lib/widget_system/widgets/StatelessWidget/Text/node2_shadows.dart b/lib/widget_system/widgets/StatelessWidget/Text/node2_shadows.dart index 6770a09..a7bf941 100644 --- a/lib/widget_system/widgets/StatelessWidget/Text/node2_shadows.dart +++ b/lib/widget_system/widgets/StatelessWidget/Text/node2_shadows.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; // "【backgroundColor】: 背景颜色 【Color】", // } class ShadowText extends StatelessWidget { + const ShadowText({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return const Text( diff --git a/lib/widget_system/widgets/StatelessWidget/Text/node3_decoration.dart b/lib/widget_system/widgets/StatelessWidget/Text/node3_decoration.dart index bf6d736..1aee5c8 100644 --- a/lib/widget_system/widgets/StatelessWidget/Text/node3_decoration.dart +++ b/lib/widget_system/widgets/StatelessWidget/Text/node3_decoration.dart @@ -16,6 +16,8 @@ import 'package:flutter/material.dart'; // "【decorationStyle】: 装饰线样式 【TextDecorationStyle】", // } class DecorationText extends StatelessWidget { + const DecorationText({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return const Text( diff --git a/lib/widget_system/widgets/StatelessWidget/Text/node4_textAlign.dart b/lib/widget_system/widgets/StatelessWidget/Text/node4_textAlign.dart index 44bd4b5..11b8b2c 100644 --- a/lib/widget_system/widgets/StatelessWidget/Text/node4_textAlign.dart +++ b/lib/widget_system/widgets/StatelessWidget/Text/node4_textAlign.dart @@ -13,6 +13,8 @@ import 'package:flutter/material.dart'; // "下面依次是:left、right、center、justify、start、end ", // } class TextAlignText extends StatelessWidget { + const TextAlignText({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Wrap( diff --git a/lib/widget_system/widgets/StatelessWidget/Text/node5_textDirection.dart b/lib/widget_system/widgets/StatelessWidget/Text/node5_textDirection.dart index dd301de..da2ce79 100644 --- a/lib/widget_system/widgets/StatelessWidget/Text/node5_textDirection.dart +++ b/lib/widget_system/widgets/StatelessWidget/Text/node5_textDirection.dart @@ -14,6 +14,8 @@ import 'package:flutter/material.dart'; // "下面依次是:rtl、ltr ", // } class TextDirectionText extends StatelessWidget { + const TextDirectionText({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Wrap( diff --git a/lib/widget_system/widgets/StatelessWidget/Text/node6_softWrap.dart b/lib/widget_system/widgets/StatelessWidget/Text/node6_softWrap.dart index abbe4e0..cc80eb6 100644 --- a/lib/widget_system/widgets/StatelessWidget/Text/node6_softWrap.dart +++ b/lib/widget_system/widgets/StatelessWidget/Text/node6_softWrap.dart @@ -14,6 +14,8 @@ import 'package:flutter/material.dart'; // "下面softWrap=false; overflow依次是:clip、fade、ellipsis、visible ", // } class SoftWrapText extends StatelessWidget { + const SoftWrapText({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Wrap( diff --git a/lib/widget_system/widgets/StatelessWidget/Theme/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/Theme/node1_base.dart index 289eb33..d16b467 100644 --- a/lib/widget_system/widgets/StatelessWidget/Theme/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/Theme/node1_base.dart @@ -11,6 +11,8 @@ import 'package:flutter/material.dart'; // "子组件可以通过ThemeData.of获取主题的数据进行使用。", // } class TextThemeDemo extends StatelessWidget { + const TextThemeDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { TextTheme queryData = Theme.of(context).textTheme; @@ -30,15 +32,18 @@ class TextThemeDemo extends StatelessWidget { "bodyText2: ": queryData.bodyText2!, }; - return Container( - child: Column( - children: styles.keys - .map((String styleInfo) => buildItem(styleInfo, styles[styleInfo]!)) - .toList(), - ), + return Column( + children: styles.keys + .map((String styleInfo) => buildItem(styleInfo, styles[styleInfo]!)) + .toList(), ); } + TextStyle get textStyle => const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ); + Widget buildItem(String styleInfo, TextStyle style) => Column( children: [ Padding( @@ -46,20 +51,12 @@ class TextThemeDemo extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( - styleInfo, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), - ), - Text( - "@toly", - style: style, - ) - ], - ), - ), - const Divider( - height: 1, - ) + Text(styleInfo, style: textStyle), + Text("@toly", style: style) + ], + ), + ), + const Divider(height: 1) ], - ); + ); } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/Theme/node2_use.dart b/lib/widget_system/widgets/StatelessWidget/Theme/node2_use.dart index 6944cd5..89d1d3e 100644 --- a/lib/widget_system/widgets/StatelessWidget/Theme/node2_use.dart +++ b/lib/widget_system/widgets/StatelessWidget/Theme/node2_use.dart @@ -12,6 +12,8 @@ import 'package:flutter/material.dart'; // "使用Theme,可以指定非常多的属性作为主题,这些属性将应用于所有的后代组件,如指定字体、滑块、卡片、文字、分割线、按钮等属性。", // } class CustomTheme extends StatelessWidget { + const CustomTheme({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Theme( @@ -39,14 +41,11 @@ class CustomTheme extends StatelessWidget { color: Colors.transparent, ), ), - Container( + const SizedBox( width: 150, child: Slider(value: 0.8, onChanged: null), ), - Container( - width: 150, - child: const Divider(), - ) + const SizedBox(width: 150, child: Divider()) ])); } } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/Title/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/Title/node1_base.dart index 35ffab2..4028775 100644 --- a/lib/widget_system/widgets/StatelessWidget/Title/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/Title/node1_base.dart @@ -12,15 +12,15 @@ import 'package:flutter/material.dart'; // "【child】: 子组件 【Widget】", // } class TitleDemo extends StatelessWidget { + const TitleDemo({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( - child: Title( - title: '张风捷特烈', - color: const Color(0xFF9C27B0), - child: const Center( - child: Text('应用菜单栏中该页的名称为: 张风捷特烈'), - ), + return Title( + title: '张风捷特烈', + color: const Color(0xFF9C27B0), + child: const Center( + child: Text('应用菜单栏中该页的名称为: 张风捷特烈'), ), ); } diff --git a/lib/widget_system/widgets/StatelessWidget/ToggleButtons/node1_single.dart b/lib/widget_system/widgets/StatelessWidget/ToggleButtons/node1_single.dart index a66cdfd..8b0c653 100644 --- a/lib/widget_system/widgets/StatelessWidget/ToggleButtons/node1_single.dart +++ b/lib/widget_system/widgets/StatelessWidget/ToggleButtons/node1_single.dart @@ -15,6 +15,8 @@ import 'package:flutter/material.dart'; // "【onPressed】: 点击事件 【Function(int)】", // } class CustomToggleButtons extends StatefulWidget { + const CustomToggleButtons({Key? key}) : super(key: key); + @override _CustomToggleButtonsState createState() => _CustomToggleButtonsState(); } @@ -38,6 +40,5 @@ class _CustomToggleButtonsState extends State { _isSelected[value] = true; }), ); - } } \ No newline at end of file diff --git a/lib/widget_system/widgets/StatelessWidget/ToggleButtons/node2_color.dart b/lib/widget_system/widgets/StatelessWidget/ToggleButtons/node2_color.dart index 697469f..733409e 100644 --- a/lib/widget_system/widgets/StatelessWidget/ToggleButtons/node2_color.dart +++ b/lib/widget_system/widgets/StatelessWidget/ToggleButtons/node2_color.dart @@ -17,6 +17,8 @@ import 'package:flutter/material.dart'; // "【splashColor】: 水波纹色 【Color】", // } class ColorToggleButtons extends StatefulWidget { + const ColorToggleButtons({Key? key}) : super(key: key); + @override _ColorToggleButtonsState createState() => _ColorToggleButtonsState(); } diff --git a/lib/widget_system/widgets/StatelessWidget/ToggleButtons/node3_multi.dart b/lib/widget_system/widgets/StatelessWidget/ToggleButtons/node3_multi.dart index 95d2b97..8c52e11 100644 --- a/lib/widget_system/widgets/StatelessWidget/ToggleButtons/node3_multi.dart +++ b/lib/widget_system/widgets/StatelessWidget/ToggleButtons/node3_multi.dart @@ -12,12 +12,14 @@ import 'package:flutter/material.dart'; // "subtitle": " 可以控制状态转化的逻辑来形成不同的效果。", // } class ProToggleButtons extends StatefulWidget { + const ProToggleButtons({Key? key}) : super(key: key); + @override _ProToggleButtonsState createState() => _ProToggleButtonsState(); } class _ProToggleButtonsState extends State { - List _isSelected = [false, false, false]; + final List _isSelected = [false, false, false]; @override Widget build(BuildContext context) { diff --git a/lib/widget_system/widgets/StatelessWidget/UserAccountsDrawerHeader/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/UserAccountsDrawerHeader/node1_base.dart index 3e77baf..64c4c7c 100644 --- a/lib/widget_system/widgets/StatelessWidget/UserAccountsDrawerHeader/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/UserAccountsDrawerHeader/node1_base.dart @@ -15,24 +15,29 @@ import 'package:flutter/material.dart'; // } class CustomUAGHP extends StatelessWidget { + const CustomUAGHP({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: MediaQuery.of(context).size.width / 3 * 2, child: UserAccountsDrawerHeader( accountName: Container( padding: const EdgeInsets.all(8.0), - child: Text( + child: const Text( "张风捷特烈", style: - TextStyle(color: Colors.orangeAccent, fontSize: 22, shadows: [ + TextStyle(color: Colors.orangeAccent, fontSize: 22, shadows: [ Shadow( - color: Colors.black, offset: Offset(.5, .5), blurRadius: 2), + color: Colors.black, + offset: Offset(.5, .5), + blurRadius: 2, + ), ]), ), ), - accountEmail: Padding( - padding: const EdgeInsets.all(8.0), + accountEmail: const Padding( + padding: EdgeInsets.all(8.0), child: Text("1981462002@qq.com", style: TextStyle(color: Colors.white, fontSize: 14, shadows: [ Shadow( @@ -43,11 +48,11 @@ class CustomUAGHP extends StatelessWidget { ), currentAccountPicture: Container( padding: const EdgeInsets.all(15.0), - child: CircleAvatar( + child: const CircleAvatar( backgroundImage: AssetImage("assets/images/icon_head.webp"), ), ), - decoration: BoxDecoration( + decoration: const BoxDecoration( image: DecorationImage(image: AssetImage("assets/images/caver.webp")), ), ), diff --git a/lib/widget_system/widgets/StatelessWidget/UserAccountsDrawerHeader/node2_pro.dart b/lib/widget_system/widgets/StatelessWidget/UserAccountsDrawerHeader/node2_pro.dart index 54669d3..834e33e 100644 --- a/lib/widget_system/widgets/StatelessWidget/UserAccountsDrawerHeader/node2_pro.dart +++ b/lib/widget_system/widgets/StatelessWidget/UserAccountsDrawerHeader/node2_pro.dart @@ -14,54 +14,54 @@ import 'package:flutter/material.dart'; // "【margin】: 外边距 【EdgeInsetsGeometry】", // } class ProUAGHP extends StatelessWidget { + const ProUAGHP({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( + return SizedBox( width: MediaQuery.of(context).size.width / 3 * 2, child: UserAccountsDrawerHeader( - margin: EdgeInsets.all(10), + margin: const EdgeInsets.all(10), accountName: Container( padding: const EdgeInsets.all(8.0), - child: Text( + child: const Text( "张风捷特烈", style: - TextStyle(color: Colors.orangeAccent, fontSize: 22, - shadows: [ + TextStyle(color: Colors.orangeAccent, fontSize: 22, shadows: [ Shadow( - color: Colors.black, - offset: Offset(.5, .5), - blurRadius: 2), + color: Colors.black, + offset: Offset(.5, .5), + blurRadius: 2, + ), ]), ), ), - accountEmail: Padding( - padding: const EdgeInsets.all(8.0), + accountEmail: const Padding( + padding: EdgeInsets.all(8.0), child: Text("1981462002@qq.com", - style: TextStyle( - color: Colors.white, fontSize: 14, - shadows: [ + style: TextStyle(color: Colors.white, fontSize: 14, shadows: [ Shadow( - color: Colors.orangeAccent, - offset: Offset(.5, .5), - blurRadius: 2), + color: Colors.orangeAccent, + offset: Offset(.5, .5), + blurRadius: 2, + ), ])), ), currentAccountPicture: Container( padding: const EdgeInsets.all(15.0), - child: CircleAvatar( + child: const CircleAvatar( backgroundImage: AssetImage("assets/images/icon_head.webp"), ), ), - otherAccountsPictures: [ + otherAccountsPictures: const [ FlutterLogo(textColor: Colors.green), ], onDetailsPressed: () { }, arrowColor: Colors.white, - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/caver.webp")), + decoration: const BoxDecoration( + image: DecorationImage(image: AssetImage("assets/images/caver.webp")), ), ), ); diff --git a/lib/widget_system/widgets/StatelessWidget/VerticalDivider/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/VerticalDivider/node1_base.dart index 28e0f16..434136f 100644 --- a/lib/widget_system/widgets/StatelessWidget/VerticalDivider/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/VerticalDivider/node1_base.dart @@ -11,14 +11,16 @@ import 'package:flutter/material.dart'; // "【thickness】: 线粗细 【double】", // } class CustomVerticalDivider extends StatelessWidget { + const CustomVerticalDivider({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - var dataColor = [ + List dataColor = [ Colors.red, Colors.yellow, Colors.blue, Colors.green]; - var dataThickness = [1.0, 2.0, 4.0, 6.0]; - var data = Map.fromIterables(dataColor, dataThickness); - return Container( + List dataThickness = [1.0, 2.0, 4.0, 6.0]; + Map data = Map.fromIterables(dataColor, dataThickness); + return SizedBox( height: 150, child: Row( mainAxisSize: MainAxisSize.min, @@ -26,8 +28,7 @@ class CustomVerticalDivider extends StatelessWidget { .map((e) => VerticalDivider( color: e, thickness: data[e], - )) - .toList(), + )).toList(), ), ); } diff --git a/lib/widget_system/widgets/StatelessWidget/VerticalDivider/node2_height.dart b/lib/widget_system/widgets/StatelessWidget/VerticalDivider/node2_height.dart index c6dbe87..0a93eae 100644 --- a/lib/widget_system/widgets/StatelessWidget/VerticalDivider/node2_height.dart +++ b/lib/widget_system/widgets/StatelessWidget/VerticalDivider/node2_height.dart @@ -15,14 +15,16 @@ import 'package:flutter/material.dart'; // "【height】: 占位高 【double】", // } class HeightVerticalDivider extends StatelessWidget { + const HeightVerticalDivider({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { - var dataColor = [ + List dataColor = [ Colors.red, Colors.yellow, Colors.blue, Colors.green]; - var dataThickness = [10.0, 20.0, 30.0, 40.0]; - var data = Map.fromIterables(dataColor, dataThickness); - return Container( + List dataThickness = [10.0, 20.0, 30.0, 40.0]; + Map data = Map.fromIterables(dataColor, dataThickness); + return SizedBox( height: 150, child: Row( mainAxisSize: MainAxisSize.min, diff --git a/lib/widget_system/widgets/StatelessWidget/Visibility/node1_base.dart b/lib/widget_system/widgets/StatelessWidget/Visibility/node1_base.dart index 232981b..5d0bbe3 100644 --- a/lib/widget_system/widgets/StatelessWidget/Visibility/node1_base.dart +++ b/lib/widget_system/widgets/StatelessWidget/Visibility/node1_base.dart @@ -12,19 +12,21 @@ import 'package:flutter/material.dart'; // "默认孩子隐藏时会失去原来所在区域。", // } class CustomVisibility extends StatelessWidget { + const CustomVisibility({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Wrap( spacing: 10, - children: [ + children: [ _buildVisibility(true), _buildVisibility(false), ], ); } - _buildVisibility(bool visible) { - var box = Container( + Widget _buildVisibility(bool visible) { + Widget box = Container( height: 30, width: 30, color: Colors.blue, @@ -44,7 +46,7 @@ class CustomVisibility extends StatelessWidget { height: 80 * 0.618, width: 80, color: Colors.red, - child: Text( + child: const Text( "visible\ntrue", style: TextStyle(fontSize: 20), ), diff --git a/lib/widget_system/widgets/StatelessWidget/Visibility/node2_replacement.dart b/lib/widget_system/widgets/StatelessWidget/Visibility/node2_replacement.dart index 4c083cf..d9ed102 100644 --- a/lib/widget_system/widgets/StatelessWidget/Visibility/node2_replacement.dart +++ b/lib/widget_system/widgets/StatelessWidget/Visibility/node2_replacement.dart @@ -11,6 +11,8 @@ import 'package:flutter/material.dart'; // "subtitle": "【replacement】 : 隐藏时的占位组件 【Widget】", // } class ReplacementVisibility extends StatelessWidget { + const ReplacementVisibility({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Wrap( @@ -22,8 +24,8 @@ class ReplacementVisibility extends StatelessWidget { ); } - _buildVisibility(bool visible) { - var box = Container( + Widget _buildVisibility(bool visible) { + Widget box = Container( height: 30, width: 30, color: Colors.blue, @@ -48,7 +50,7 @@ class ReplacementVisibility extends StatelessWidget { height: 80 * 0.618, width: 80, color: Colors.red, - child: Text( + child: const Text( "visible\ntrue", style: TextStyle(fontSize: 20), ), diff --git a/lib/widget_system/widgets/widgets_map.dart b/lib/widget_system/widgets/widgets_map.dart index 900dd56..e3b8745 100644 --- a/lib/widget_system/widgets/widgets_map.dart +++ b/lib/widget_system/widgets/widgets_map.dart @@ -14,12 +14,12 @@ class WidgetsMap { switch (name) { case "Container": return [ - CustomContainer(), - ContainerWithChild(), - ContainerAlignment(), + const CustomContainer(), + const ContainerWithChild(), + const ContainerAlignment(), ContainerDecoration(), - ContainerTransform(), - ContainerConstraints() + const ContainerTransform(), + const ContainerConstraints() ]; case "CupertinoSegmentedControl": return [ @@ -38,27 +38,27 @@ class WidgetsMap { PrimaryScrollControllerDemo(), ];case "CupertinoFullscreenDialogTransition": return [ - CupertinoFullscreenDialogTransitionDemo(), + const CupertinoFullscreenDialogTransitionDemo(), ];case "CupertinoPageTransition": return [ - CupertinoPageTransitionDemo(), + const CupertinoPageTransitionDemo(), ];case "HtmlElementView": return [ - HtmlElementViewDemo(), + const HtmlElementViewDemo(), ]; case "Text": return [ - CustomText(), - ShadowText(), - DecorationText(), - TextAlignText(), - TextDirectionText(), - SoftWrapText() + const CustomText(), + const ShadowText(), + const DecorationText(), + const TextAlignText(), + const TextDirectionText(), + const SoftWrapText() ]; case "Card": return [ - CustomCard(), - ShapeCard(), + const CustomCard(), + const ShapeCard(), ]; case "ElevatedButton": return [ @@ -77,8 +77,8 @@ class WidgetsMap { ]; case "FlutterLogo": return [ - CustomFlutterLogo(), - FlutterLogoWithText(), + const CustomFlutterLogo(), + const FlutterLogoWithText(), ]; case "Banner": return [ @@ -124,7 +124,7 @@ class WidgetsMap { ]; case "ModalBarrier": return [ - ModalBarrierDemo(), + const ModalBarrierDemo(), ]; case "AnimatedModalBarrier": return [ @@ -152,7 +152,7 @@ class WidgetsMap { ]; case "ScrollView": return [ - ScrollViewDemo(), + const ScrollViewDemo(), ]; case "SliverWithKeepAliveWidget": return [ @@ -160,7 +160,7 @@ class WidgetsMap { ]; case "BoxScrollView": return [ - BoxScrollViewDemo(), + const BoxScrollViewDemo(), ]; case "CupertinoUserInterfaceLevel": return [ @@ -224,7 +224,7 @@ class WidgetsMap { ]; case "SafeArea": return [ - SafeAreaDemo(), + const SafeAreaDemo(), ]; case "AnimatedBuilder": return [ @@ -240,10 +240,10 @@ class WidgetsMap { ]; case "PageStorage": return [ - PageStorageDemo(), + const PageStorageDemo(), ]; case "NotificationListener": - return [NotificationListenerDemo(), NotificationListenerUpdate()]; + return [const NotificationListenerDemo(), const NotificationListenerUpdate()]; case "Scrollable": return [ @@ -296,19 +296,19 @@ class WidgetsMap { ]; case "TabPageSelector": return [ - TabPageSelectorDemo(), + const TabPageSelectorDemo(), ]; case "CupertinoNavigationBarBackButton": return [ - CupertinoNavigationBarBackButtonDemo(), + const CupertinoNavigationBarBackButtonDemo(), ]; case "TabPageSelectorIndicator": return [ - TabPageSelectorIndicatorDemo(), + const TabPageSelectorIndicatorDemo(), ]; case "Title": return [ - TitleDemo(), + const TitleDemo(), ]; case "ToggleButtonsTheme": return [ @@ -320,11 +320,11 @@ class WidgetsMap { ]; case "NavigationToolbar": return [ - NavigationToolbarDemo(), + const NavigationToolbarDemo(), ]; case "CupertinoDialogAction": return [ - CupertinoDialogActionDemo(), + const CupertinoDialogActionDemo(), ]; case "ButtonBarTheme": return [ @@ -345,25 +345,25 @@ class WidgetsMap { ]; case "MaterialBanner": return [ - MaterialBannerDemo(), - MaterialBannerDemoTwo(), + const MaterialBannerDemo(), + const MaterialBannerDemoTwo(), ]; case "OrientationBuilder": return [ - OrientationBuilderDemo(), + const OrientationBuilderDemo(), ]; case "Icon": return [ - CustomIcon(), - MyIcon(), + const CustomIcon(), + const MyIcon(), ]; case "ImageIcon": return [ - CustomImageIcon(), + const CustomImageIcon(), ]; case "FadeInImage": return [ - CustomFadeInImage(), + const CustomFadeInImage(), ]; case "InteractiveViewer": return [ @@ -373,7 +373,7 @@ class WidgetsMap { ]; case "CircleAvatar": return [ - CustomCircleAvatar(), + const CustomCircleAvatar(), ]; case "SliverLayoutBuilder": return [ @@ -381,8 +381,8 @@ class WidgetsMap { ]; case "Visibility": return [ - CustomVisibility(), - ReplacementVisibility(), + const CustomVisibility(), + const ReplacementVisibility(), ]; case "RepaintBoundary": return [ @@ -391,26 +391,26 @@ class WidgetsMap { ]; case "Chip": return [ - CustomChip(), - ColorOfChip(), - DeleteOfChip(), + const CustomChip(), + const ColorOfChip(), + const DeleteOfChip(), ]; case "ChoiceChip": - return [CustomChoiceChip()]; + return [const CustomChoiceChip()]; case "ListTileTheme": return [ListTileThemeDemo()]; case "ValueListenableBuilder": return [ValueListenableBuilderDemo()]; case "ActionChip": - return [CustomActionChip()]; + return [const CustomActionChip()]; case "MaterialBannerTheme": return [MaterialBannerThemeDemo()]; case "PopupMenuTheme": return [PopupMenuThemeDemo()]; case "InputChip": - return [PressInputChip(), SelectInputChip()]; + return [const PressInputChip(), const SelectInputChip()]; case "FilterChip": - return [CustomFilterChip()]; + return [const CustomFilterChip()]; case "IntrinsicHeight": return [IntrinsicHeightDemo()]; case "IntrinsicWidth": @@ -418,67 +418,67 @@ class WidgetsMap { case "ChipTheme": return [ChipThemeDemo()]; case "ListTile": - return [CustomListTile(), SelectListTile(), DenseListTile()]; + return [const CustomListTile(), const SelectListTile(), const DenseListTile()]; case "CheckboxListTile": return [ - CustomCheckBoxListTile(), - SelectCheckBoxListTile(), - DenseCheckBoxListTile() + const CustomCheckBoxListTile(), + const SelectCheckBoxListTile(), + const DenseCheckBoxListTile() ]; case "SwitchListTile": return [ - CustomSwitchListTile(), - SelectSwitchListTile(), - DenseSwitchListTile() + const CustomSwitchListTile(), + const SelectSwitchListTile(), + const DenseSwitchListTile() ]; case "RadioListTile": return [ - CustomRadioListTile(), - DenseRadioListTile(), + const CustomRadioListTile(), + const DenseRadioListTile(), ]; case "GridTileBar": return [ - CustomGridTileBar(), + const CustomGridTileBar(), ]; case "GridTile": return [ - CustomGridTile(), + const CustomGridTile(), ]; case "UserAccountsDrawerHeader": return [ - CustomUAGHP(), - ProUAGHP(), + const CustomUAGHP(), + const ProUAGHP(), ]; case "MaterialButton": return [ - CustomMaterialButton(), - LongPressMaterialButton(), - ShapeMaterialButton(), + const CustomMaterialButton(), + const LongPressMaterialButton(), + const ShapeMaterialButton(), ]; case "CupertinoButton": return [CustomCupertinoButton()]; case "FlatButton": - return [CustomFlatButton()]; + return [const CustomFlatButton()]; case "RaisedButton": - return [CustomRaisedButton()]; + return [const CustomRaisedButton()]; case "OutlineButton": - return [CustomOutlineButton()]; + return [const CustomOutlineButton()]; case "FloatingActionButton": - return [CustomFAB(), MiniFAB(), ShapeFAB()]; + return [const CustomFAB(), const MiniFAB(), const ShapeFAB()]; case "ButtonBar": return [ - CustomButtonBar(), - PaddingButtonBar(), + const CustomButtonBar(), + const PaddingButtonBar(), ]; case "IconButton": return [ - CustomIconButton(), + const CustomIconButton(), ]; case "BackButton": return [ @@ -487,19 +487,19 @@ class WidgetsMap { case "CloseButton": return [ - CustomCloseButton(), + const CustomCloseButton(), ]; case "ToggleButtons": return [ - CustomToggleButtons(), - ColorToggleButtons(), - ProToggleButtons(), + const CustomToggleButtons(), + const ColorToggleButtons(), + const ProToggleButtons(), ]; case "ToggleButtons": return [ - CustomToggleButtons(), - ColorToggleButtons(), - ProToggleButtons(), + const CustomToggleButtons(), + const ColorToggleButtons(), + const ProToggleButtons(), ]; case "NestedScrollView": return [ @@ -515,23 +515,23 @@ class WidgetsMap { ]; case "Divider": return [ - CustomDivider(), - HeightDivider(), + const CustomDivider(), + const HeightDivider(), ]; case "VerticalDivider": return [ - CustomVerticalDivider(), - HeightVerticalDivider(), + const CustomVerticalDivider(), + const HeightVerticalDivider(), ]; case "Placeholder": return [ - CustomPlaceholder(), - FallbackPlaceholder(), + const CustomPlaceholder(), + const FallbackPlaceholder(), ]; case "GridPager": return [ - CustomGridPage(), - DivisionsGridPage(), + const CustomGridPage(), + const DivisionsGridPage(), ]; case "Image": return [ @@ -617,7 +617,7 @@ class WidgetsMap { ]; case "CheckedModeBanner": return [ - CheckedModeBannerDemo(), + const CheckedModeBannerDemo(), ]; case "DefaultTabController": return [ @@ -633,7 +633,7 @@ class WidgetsMap { ]; case "DraggableScrollableActuator": return [ - DraggableScrollableActuatorDemo(), + const DraggableScrollableActuatorDemo(), ]; case "GlowingOverscrollIndicator": return [ @@ -682,8 +682,8 @@ class WidgetsMap { ]; case "TabBar": return [ - CustomTabBar(), - NoShadowTabBarDemo(), + const CustomTabBar(), + const NoShadowTabBarDemo(), ]; case "TabBarView": return [ @@ -876,7 +876,7 @@ class WidgetsMap { case "DataTable": return [ CustomDataTable(), - SortDataTable(), + const SortDataTable(), ]; case "Draggable": return [ @@ -898,8 +898,8 @@ class WidgetsMap { ]; case "Spacer": return [ - OneSpacer(), - ManySpacer(), + const OneSpacer(), + const ManySpacer(), ]; case "Positioned": return [ @@ -971,43 +971,43 @@ class WidgetsMap { ]; case "AnimatedIcon": return [ - CustomAnimatedIcon(), + const CustomAnimatedIcon(), ]; case "Dialog": return [ - CustomDialog(), + const CustomDialog(), ]; case "AlertDialog": return [ - CustomAlertDialog(), + const CustomAlertDialog(), ]; case "SimpleDialog": return [ - CustomSimpleDialog(), + const CustomSimpleDialog(), ]; case "CupertinoAlertDialog": return [ - CustomCupertinoAlertDialog(), + const CustomCupertinoAlertDialog(), ]; case "AboutDialog": return [ - CustomAboutDialog(), + const CustomAboutDialog(), ]; case "CupertinoActionSheet": return [ - CustomCupertinoActionSheet(), + const CustomCupertinoActionSheet(), ]; case "CupertinoActionSheetAction": return [ - CustomCupertinoActionSheetAction(), + const CustomCupertinoActionSheetAction(), ]; case "SimpleDialogOption": return [ - CustomSimpleDialogOption(), + const CustomSimpleDialogOption(), ]; case "DayPicker": return [ - CustomDayPicker(), + const CustomDayPicker(), ]; case "MonthPicker": return [ @@ -1031,15 +1031,15 @@ class WidgetsMap { ]; case "SnackBar": return [ - CustomSnackBar(), + const CustomSnackBar(), ]; case "SnackBarAction": return [ - CustomSnackBarAction(), + const CustomSnackBarAction(), ]; case "BottomSheet": return [ - CustomBottomSheet(), + const CustomBottomSheet(), ]; case "CupertinoContextMenu": return [ @@ -1055,26 +1055,26 @@ class WidgetsMap { ]; case "Builder": return [ - BuilderDemo(), + const BuilderDemo(), ]; case "GestureDetector": return [ - CustomGestureDetector(), - TapGestureDetector(), - PanGestureDetector(), + const CustomGestureDetector(), + const TapGestureDetector(), + const PanGestureDetector(), ]; case "Listener": return [ - CustomListener(), + const CustomListener(), ]; case "Tab": return [ - CustomTab(), + const CustomTab(), ]; case "PreferredSize": return [ - CustomPreferredSize(), - AdapterPreferredSize(), + const CustomPreferredSize(), + const AdapterPreferredSize(), ]; case "InkResponse": return [ @@ -1102,11 +1102,11 @@ class WidgetsMap { ]; case "Drawer": return [ - CustomDrawer(), + const CustomDrawer(), ]; case "DrawerHeader": return [ - CustomDrawerHeader(), + const CustomDrawerHeader(), ]; case "CupertinoApp": return [ @@ -1122,7 +1122,7 @@ class WidgetsMap { ]; case "PositionedDirectional": return [ - CustomPositionedDirectional(), + const CustomPositionedDirectional(), ]; case "Material": return [ @@ -1168,9 +1168,9 @@ class WidgetsMap { CustomMediaQuery(), ]; case "Theme": - return [TextThemeDemo(), CustomTheme()]; + return [const TextThemeDemo(), const CustomTheme()]; case "CupertinoTheme": - return [TextCupertinoTheme(), CustomCupertinoTheme()]; + return [const TextCupertinoTheme(), const CustomCupertinoTheme()]; case "WillPopScope": return [ CustomWillPopScope(), @@ -1268,7 +1268,7 @@ class WidgetsMap { ]; case "AboutListTile": return [ - AboutListTileDemo(), + const AboutListTileDemo(), ]; case "Scrollbar": return [ diff --git a/pubspec.lock b/pubspec.lock index b741b98..1879f88 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,13 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + archive: + dependency: transitive + description: + name: archive + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.2.2" args: dependency: transitive description: @@ -57,6 +64,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.15.0" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.1" cupertino_icons: dependency: "direct main" description: @@ -64,6 +78,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.4" + dash_painter: + dependency: "direct main" + description: + name: dash_painter + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.2" dio: dependency: "direct main" description: @@ -111,6 +132,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "8.0.1" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.4" flutter_markdown: dependency: "direct main" description: @@ -156,6 +184,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "4.0.0" + image: + dependency: "direct main" + description: + name: image + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.3" intl: dependency: "direct main" description: @@ -177,6 +212,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.0.1" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.1" markdown: dependency: transitive description: @@ -317,6 +359,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.0.5" + petitparser: + dependency: transitive + description: + name: petitparser + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.4.0" platform: dependency: "direct main" description: @@ -609,6 +658,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.0.4" + wrapper: + dependency: "direct main" + description: + name: wrapper + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.2" xdg_directories: dependency: transitive description: @@ -616,6 +672,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.2.0" + xml: + dependency: transitive + description: + name: xml + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.3.1" sdks: dart: ">=2.15.0 <3.0.0" flutter: ">=2.8.0" diff --git a/pubspec.yaml b/pubspec.yaml index 13d76a1..c48964a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -29,7 +29,9 @@ dependencies: intl: ^0.17.0 path_provider: ^2.0.9 # 路径 platform: ^3.1.0 - + image: ^3.1.0 + wrapper: ^1.0.2 + dash_painter: ^1.0.2 flutter_spinkit: ^5.1.0 # loading flutter_markdown: ^0.6.4 # markdown dio: ^4.0.4 # 网络请求 @@ -37,6 +39,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + flutter_lints: ^1.0.0 flutter: uses-material-design: true