dart migrate

flutter upgrade to 2.2.0
master
张萌 3 years ago
parent 2ca1997739
commit 6ead6aced6

@ -0,0 +1,4 @@
{
"flutterSdkVersion": "2.2.0",
"flavors": {}
}

@ -14,19 +14,19 @@ class CodeStyle extends InheritedWidget {
this.punctuationStyle, this.punctuationStyle,
this.classStyle, this.classStyle,
this.constantStyle, this.constantStyle,
@required Widget child, required Widget child,
}) : super(child: child); }) : super(child: child);
final TextStyle baseStyle; final TextStyle? baseStyle;
final TextStyle numberStyle; final TextStyle? numberStyle;
final TextStyle commentStyle; final TextStyle? commentStyle;
final TextStyle keywordStyle; final TextStyle? keywordStyle;
final TextStyle stringStyle; final TextStyle? stringStyle;
final TextStyle punctuationStyle; final TextStyle? punctuationStyle;
final TextStyle classStyle; final TextStyle? classStyle;
final TextStyle constantStyle; final TextStyle? constantStyle;
static CodeStyle of(BuildContext context) { static CodeStyle? of(BuildContext context) {
return context.dependOnInheritedWidgetOfExactType<CodeStyle>(); return context.dependOnInheritedWidgetOfExactType<CodeStyle>();
} }

@ -6,12 +6,12 @@ import 'code_view.dart';
class BasePage extends StatelessWidget { class BasePage extends StatelessWidget {
final String title; final String title;
final Widget body; final Widget body;
final List<Widget> actions; final List<Widget>? actions;
final CodeBuilder codeBuilder; final CodeBuilder? codeBuilder;
const BasePage( const BasePage(
{Key key, {Key? key,
@required this.title, required this.title,
@required this.body, required this.body,
this.actions, this.actions,
this.codeBuilder}) this.codeBuilder})
: super(key: key); : super(key: key);

@ -4,10 +4,10 @@ import 'package:get/get.dart';
import 'code_view.dart'; import 'code_view.dart';
class CodeTile extends StatelessWidget { class CodeTile extends StatelessWidget {
final Widget title; final Widget? title;
final Widget subTitle; final Widget? subTitle;
final CodeBuilder builder; final CodeBuilder? builder;
const CodeTile({Key key, this.title, this.subTitle, this.builder}) const CodeTile({Key? key, this.title, this.subTitle, this.builder})
: super(key: key); : super(key: key);
@override @override

@ -5,9 +5,9 @@ import '../codeviewer/code_style.dart';
typedef CodeBuilder = TextSpan Function(BuildContext context); typedef CodeBuilder = TextSpan Function(BuildContext context);
class CodeView extends StatefulWidget { class CodeView extends StatefulWidget {
final CodeBuilder text; final CodeBuilder? text;
final String title; final String title;
CodeView({Key key, @required this.text, this.title = 'Code'}) CodeView({Key? key, required this.text, this.title = 'Code'})
: super(key: key); : super(key: key);
@override @override
@ -33,7 +33,7 @@ class _CodeViewState extends State<CodeView> {
classStyle: codeTheme.copyWith(color: Colors.yellow), classStyle: codeTheme.copyWith(color: Colors.yellow),
constantStyle: codeTheme.copyWith(color: Colors.pink), constantStyle: codeTheme.copyWith(color: Colors.pink),
child: child:
Builder(builder: (context) => Text.rich(widget.text(context))), Builder(builder: (context) => Text.rich(widget.text!(context))),
)), )),
); );
} }

@ -5,13 +5,13 @@ import 'package:get/get.dart';
class ExampleScaffold extends StatelessWidget { class ExampleScaffold extends StatelessWidget {
final String title; final String title;
final CodeBuilder text; final CodeBuilder? text;
final List<Widget> children; final List<Widget> children;
const ExampleScaffold({ const ExampleScaffold({
Key key, Key? key,
@required this.title, required this.title,
this.text, this.text,
@required this.children, required this.children,
}) : super(key: key); }) : super(key: key);
@override @override

@ -2,9 +2,9 @@ import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ColorObject { class ColorObject {
Color color; Color? color;
String name; String? name;
String codeName; String? codeName;
ColorObject({ ColorObject({
this.color, this.color,
this.name, this.name,

@ -6,7 +6,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
class ExampleListExt extends StatefulWidget { class ExampleListExt extends StatefulWidget {
const ExampleListExt({Key key}) : super(key: key); const ExampleListExt({Key? key}) : super(key: key);
@override @override
_ExampleListExtState createState() => _ExampleListExtState(); _ExampleListExtState createState() => _ExampleListExtState();

@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
class ExampleNumExt extends StatefulWidget { class ExampleNumExt extends StatefulWidget {
ExampleNumExt({Key key}) : super(key: key); ExampleNumExt({Key? key}) : super(key: key);
@override @override
_ExampleNumExtState createState() => _ExampleNumExtState(); _ExampleNumExtState createState() => _ExampleNumExtState();

@ -4,7 +4,7 @@ import 'package:example/component/example_scaffold.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ExampleStringExt extends StatefulWidget { class ExampleStringExt extends StatefulWidget {
ExampleStringExt({Key key}) : super(key: key); ExampleStringExt({Key? key}) : super(key: key);
@override @override
_ExampleStringExtState createState() => _ExampleStringExtState(); _ExampleStringExtState createState() => _ExampleStringExtState();

@ -37,14 +37,14 @@ class MyApp extends StatelessWidget {
} }
class MyHomePage extends StatefulWidget { class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key); MyHomePage({Key? key}) : super(key: key);
@override @override
_MyHomePageState createState() => _MyHomePageState(); _MyHomePageState createState() => _MyHomePageState();
} }
class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin { class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
TabController _tabController; TabController? _tabController;
@override @override
void initState() { void initState() {
@ -56,9 +56,9 @@ class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
print(Theme.of(context).textTheme.headline1.fontFamily); print(Theme.of(context).textTheme.headline1!.fontFamily);
return ASScaffold( return ASScaffold(
leading: navigator.canPop() leading: navigator!.canPop()
? IconButton( ? IconButton(
icon: Icon(Icons.backpack, color: Colors.black), icon: Icon(Icons.backpack, color: Colors.black),
onPressed: () {}, onPressed: () {},
@ -74,7 +74,7 @@ class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
], ],
), ),
bottomNavigationBar: ASNavigationBar( bottomNavigationBar: ASNavigationBar(
controller: _tabController, controller: _tabController!,
items: [ items: [
BottomNavigationBarItem( BottomNavigationBarItem(
icon: Icon(Icons.home), icon: Icon(Icons.home),

@ -6,7 +6,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
class MainExtention extends StatefulWidget { class MainExtention extends StatefulWidget {
MainExtention({Key key}) : super(key: key); MainExtention({Key? key}) : super(key: key);
@override @override
_MainExtentionState createState() => _MainExtentionState(); _MainExtentionState createState() => _MainExtentionState();
@ -14,9 +14,9 @@ class MainExtention extends StatefulWidget {
class _MainExtentionState extends State<MainExtention> { class _MainExtentionState extends State<MainExtention> {
_innerButton({ _innerButton({
VoidCallback onPressed, VoidCallback? onPressed,
Widget child, required Widget child,
Widget icon, Widget? icon,
}) { }) {
return TextButton( return TextButton(
onPressed: onPressed, onPressed: onPressed,

@ -21,7 +21,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
class MainHome extends StatefulWidget { class MainHome extends StatefulWidget {
MainHome({Key key}) : super(key: key); MainHome({Key? key}) : super(key: key);
@override @override
_MainHomeState createState() => _MainHomeState(); _MainHomeState createState() => _MainHomeState();
@ -29,15 +29,15 @@ class MainHome extends StatefulWidget {
class _MainHomeState extends State<MainHome> { class _MainHomeState extends State<MainHome> {
_innerButton({ _innerButton({
VoidCallback onPressed, VoidCallback? onPressed,
String title, required String title,
IconData icon, IconData? icon,
}) { }) {
return TextButton( return TextButton(
onPressed: onPressed, onPressed: onPressed,
child: Row( child: Row(
children: [ children: [
Expanded(child: Icon(icon) ?? SizedBox()), Expanded(child: icon != null ? Icon(icon) : SizedBox()),
Text(title), Text(title),
Spacer(), Spacer(),
], ],

@ -4,7 +4,7 @@ import 'package:get/get.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
class MainUtils extends StatefulWidget { class MainUtils extends StatefulWidget {
MainUtils({Key key}) : super(key: key); MainUtils({Key? key}) : super(key: key);
@override @override
_MainUtilsState createState() => _MainUtilsState(); _MainUtilsState createState() => _MainUtilsState();
@ -12,9 +12,9 @@ class MainUtils extends StatefulWidget {
class _MainUtilsState extends State<MainUtils> { class _MainUtilsState extends State<MainUtils> {
_innerButton({ _innerButton({
VoidCallback onPressed, VoidCallback? onPressed,
Widget child, required Widget child,
Widget icon, Widget? icon,
}) { }) {
return TextButton( return TextButton(
onPressed: onPressed, onPressed: onPressed,

@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
class ExampleCameraView extends StatefulWidget { class ExampleCameraView extends StatefulWidget {
ExampleCameraView({Key key}) : super(key: key); ExampleCameraView({Key? key}) : super(key: key);
@override @override
_ExampleCameraViewState createState() => _ExampleCameraViewState(); _ExampleCameraViewState createState() => _ExampleCameraViewState();
@ -24,8 +24,8 @@ class _ExampleCameraViewState extends State<ExampleCameraView> {
ListTile( ListTile(
title: 'CameraView'.text.make(), title: 'CameraView'.text.make(),
onTap: () async { onTap: () async {
File file = await camView(context, title: 'TEST'); File? file = await camView(context, title: 'TEST');
print(await file.length()); print(await file?.length());
}, },
), ),
// END // END

@ -8,7 +8,7 @@ import 'package:get/get.dart';
class ExampleBottomButton extends StatefulWidget { class ExampleBottomButton extends StatefulWidget {
ExampleBottomButton({Key key}) : super(key: key); ExampleBottomButton({Key? key}) : super(key: key);
@override @override
_ExampleBottomButtonState createState() => _ExampleBottomButtonState(); _ExampleBottomButtonState createState() => _ExampleBottomButtonState();

@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
class ExampleBox extends StatefulWidget { class ExampleBox extends StatefulWidget {
ExampleBox({Key key}) : super(key: key); ExampleBox({Key? key}) : super(key: key);
@override @override
_ExampleBoxState createState() => _ExampleBoxState(); _ExampleBoxState createState() => _ExampleBoxState();

@ -7,7 +7,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
class ExampleButton extends StatefulWidget { class ExampleButton extends StatefulWidget {
ExampleButton({Key key}) : super(key: key); ExampleButton({Key? key}) : super(key: key);
@override @override
_ExampleButtonState createState() => _ExampleButtonState(); _ExampleButtonState createState() => _ExampleButtonState();
@ -153,25 +153,25 @@ class _ExampleButtonState extends State<ExampleButton> {
groupValue: groupValue, groupValue: groupValue,
value: 0, value: 0,
title: '候选0', title: '候选0',
onTap: (_) => setState(() => groupValue = 0), onTap: (dynamic _) => setState(() => groupValue = 0),
), ),
ASRadioButton( ASRadioButton(
groupValue: groupValue, groupValue: groupValue,
value: 1, value: 1,
title: '候选1', title: '候选1',
onTap: (_) => setState(() => groupValue = 1), onTap: (dynamic _) => setState(() => groupValue = 1),
), ),
ASRadioButton( ASRadioButton(
groupValue: groupValue, groupValue: groupValue,
value: 2, value: 2,
title: '候选2', title: '候选2',
onTap: (_) => setState(() => groupValue = 2), onTap: (dynamic _) => setState(() => groupValue = 2),
), ),
ASRadioButton( ASRadioButton(
groupValue: groupValue, groupValue: groupValue,
value: 3, value: 3,
title: '候选3', title: '候选3',
onTap: (_) => setState(() => groupValue = 3), onTap: (dynamic _) => setState(() => groupValue = 3),
), ),
], ],
), ),

@ -3,7 +3,7 @@ import 'package:ansu_ui/chart/circle_chart_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ExampleChart extends StatefulWidget { class ExampleChart extends StatefulWidget {
const ExampleChart({Key key}) : super(key: key); const ExampleChart({Key? key}) : super(key: key);
@override @override
_ExampleChartState createState() => _ExampleChartState(); _ExampleChartState createState() => _ExampleChartState();

@ -3,7 +3,7 @@ import 'package:ansu_ui/divider/as_dotted_divider.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ExampleDivider extends StatefulWidget { class ExampleDivider extends StatefulWidget {
ExampleDivider({Key key}) : super(key: key); ExampleDivider({Key? key}) : super(key: key);
@override @override
_ExampleDividerState createState() => _ExampleDividerState(); _ExampleDividerState createState() => _ExampleDividerState();

@ -2,7 +2,7 @@ import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ExampleDrawer extends StatefulWidget { class ExampleDrawer extends StatefulWidget {
ExampleDrawer({Key key}) : super(key: key); ExampleDrawer({Key? key}) : super(key: key);
@override @override
_ExampleDrawerState createState() => _ExampleDrawerState(); _ExampleDrawerState createState() => _ExampleDrawerState();

@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
class ExampleListTile extends StatefulWidget { class ExampleListTile extends StatefulWidget {
ExampleListTile({Key key}) : super(key: key); ExampleListTile({Key? key}) : super(key: key);
@override @override
_ExampleListTileState createState() => _ExampleListTileState(); _ExampleListTileState createState() => _ExampleListTileState();

@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
class ExampleNumericButton extends StatefulWidget { class ExampleNumericButton extends StatefulWidget {
ExampleNumericButton({Key key}) : super(key: key); ExampleNumericButton({Key? key}) : super(key: key);
@override @override
_ExampleNumericButtonState createState() => _ExampleNumericButtonState(); _ExampleNumericButtonState createState() => _ExampleNumericButtonState();

@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
class ExamplePicker extends StatefulWidget { class ExamplePicker extends StatefulWidget {
ExamplePicker({Key key}) : super(key: key); ExamplePicker({Key? key}) : super(key: key);
@override @override
_ExamplePickerState createState() => _ExamplePickerState(); _ExamplePickerState createState() => _ExamplePickerState();
@ -40,7 +40,7 @@ class _ExamplePickerState extends State<ExamplePicker> {
trailing: ASButton( trailing: ASButton(
title: '日期选择器', title: '日期选择器',
onPressed: () async { onPressed: () async {
DateTime date = await asDatePicker(context); DateTime? date = await asDatePicker(context);
Get.snackbar(date.toString(), 'MESSAGE'); Get.snackbar(date.toString(), 'MESSAGE');
}, },
), ),
@ -75,8 +75,8 @@ class _ExamplePickerState extends State<ExamplePicker> {
trailing: ASButton( trailing: ASButton(
title: '图片选择器', title: '图片选择器',
onPressed: () async { onPressed: () async {
File file = await camView(context, title: '图片选择器'); File? file = await camView(context, title: '图片选择器');
print(file.lengthSync()); print(file?.lengthSync());
}, },
), ),
), ),
@ -86,7 +86,7 @@ class _ExamplePickerState extends State<ExamplePicker> {
trailing: ASButton( trailing: ASButton(
title: '图片选择器', title: '图片选择器',
onPressed: () async { onPressed: () async {
File file = await pickImageFile(); File? file = await pickImageFile();
}, },
), ),
), ),

@ -3,14 +3,14 @@ import 'package:flutter/material.dart';
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
class ExamplePopUpMenu extends StatefulWidget { class ExamplePopUpMenu extends StatefulWidget {
ExamplePopUpMenu({Key key}) : super(key: key); ExamplePopUpMenu({Key? key}) : super(key: key);
@override @override
_ExamplePopUpMenuState createState() => _ExamplePopUpMenuState(); _ExamplePopUpMenuState createState() => _ExamplePopUpMenuState();
} }
class _ExamplePopUpMenuState extends State<ExamplePopUpMenu> { class _ExamplePopUpMenuState extends State<ExamplePopUpMenu> {
int _value; int? _value;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ASScaffold( return ASScaffold(
@ -25,7 +25,7 @@ class _ExamplePopUpMenuState extends State<ExamplePopUpMenu> {
return TextButton( return TextButton(
child: '$_value'.text.make(), child: '$_value'.text.make(),
onPressed: () async { onPressed: () async {
int result = await showASPopUpMenu<int>( int? result = await showASPopUpMenu<int>(
context: context, context: context,
initValue: _value, initValue: _value,
items: List.generate( items: List.generate(

@ -2,7 +2,7 @@ import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ExampleRefresh extends StatefulWidget { class ExampleRefresh extends StatefulWidget {
ExampleRefresh({Key key}) : super(key: key); ExampleRefresh({Key? key}) : super(key: key);
@override @override
_ExampleRefreshState createState() => _ExampleRefreshState(); _ExampleRefreshState createState() => _ExampleRefreshState();

@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
class ExampleScaffold extends StatefulWidget { class ExampleScaffold extends StatefulWidget {
ExampleScaffold({Key key}) : super(key: key); ExampleScaffold({Key? key}) : super(key: key);
@override @override
_ExampleScaffoldState createState() => _ExampleScaffoldState(); _ExampleScaffoldState createState() => _ExampleScaffoldState();
@ -14,15 +14,15 @@ class ExampleScaffold extends StatefulWidget {
class _ExampleScaffoldState extends State<ExampleScaffold> class _ExampleScaffoldState extends State<ExampleScaffold>
with TickerProviderStateMixin { with TickerProviderStateMixin {
TabController _tabController; late TabController _tabController;
List<String> tabs; List<String>? tabs;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
tabs = List.generate(10, (index) => 'Tab $index'); tabs = List.generate(10, (index) => 'Tab $index');
_tabController = TabController( _tabController = TabController(
length: tabs.length, length: tabs!.length,
vsync: this, vsync: this,
); );
} }

@ -4,7 +4,7 @@ import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
class ExampleStyleColor extends StatefulWidget { class ExampleStyleColor extends StatefulWidget {
ExampleStyleColor({Key key}) : super(key: key); ExampleStyleColor({Key? key}) : super(key: key);
@override @override
_ExampleStyleColorState createState() => _ExampleStyleColorState(); _ExampleStyleColorState createState() => _ExampleStyleColorState();
@ -26,7 +26,7 @@ class _ExampleStyleColorState extends State<ExampleStyleColor> {
], ],
), ),
), ),
subtitle: Text(object.codeName), subtitle: Text(object.codeName!),
trailing: Card( trailing: Card(
color: object.color, color: object.color,
child: SizedBox(height: 50.w, width: 50.w), child: SizedBox(height: 50.w, width: 50.w),

@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
class ExampleTabBar extends StatefulWidget { class ExampleTabBar extends StatefulWidget {
ExampleTabBar({Key key}) : super(key: key); ExampleTabBar({Key? key}) : super(key: key);
@override @override
_ExampleTabBarState createState() => _ExampleTabBarState(); _ExampleTabBarState createState() => _ExampleTabBarState();
@ -13,10 +13,10 @@ class ExampleTabBar extends StatefulWidget {
class _ExampleTabBarState extends State<ExampleTabBar> class _ExampleTabBarState extends State<ExampleTabBar>
with TickerProviderStateMixin { with TickerProviderStateMixin {
TabController _tabController1; TabController? _tabController1;
TabController _tabController2; TabController? _tabController2;
TabController _tabController3; TabController? _tabController3;
TabController _tabController4; TabController? _tabController4;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -58,23 +58,23 @@ class _ExampleTabBarState extends State<ExampleTabBar>
// BEGIN tabBar // BEGIN tabBar
ASTabBar( ASTabBar(
items: ['全部', 'Part1', 'Part2'], items: ['全部', 'Part1', 'Part2'],
controller: _tabController1, controller: _tabController1!,
), ),
ASTabBar( ASTabBar(
items: List.generate(5, (index) => 'Tab $index'), items: List.generate(5, (index) => 'Tab $index'),
controller: _tabController2, controller: _tabController2!,
), ),
ASTabBar( ASTabBar(
isScrollable: true, isScrollable: true,
items: List.generate(10, (index) => 'Tab $index'), items: List.generate(10, (index) => 'Tab $index'),
controller: _tabController3, controller: _tabController3!,
), ),
ASTabBar.tag( ASTabBar.tag(
isScrollable: true, isScrollable: true,
tabItems: List.generate(10, (index) => 'Tab $index') tabItems: List.generate(10, (index) => 'Tab $index')
.map((e) => ASTabBarItem(title: e, tag: e)) .map((e) => ASTabBarItem(title: e, tag: e))
.toList(), .toList(),
controller: _tabController4, controller: _tabController4!,
), ),
// END // END

@ -6,7 +6,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
class ExampleTag extends StatefulWidget { class ExampleTag extends StatefulWidget {
ExampleTag({Key key}) : super(key: key); ExampleTag({Key? key}) : super(key: key);
@override @override
_ExampaleTagState createState() => _ExampaleTagState(); _ExampaleTagState createState() => _ExampaleTagState();

@ -2,14 +2,14 @@ import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ExampleTextFiled extends StatefulWidget { class ExampleTextFiled extends StatefulWidget {
ExampleTextFiled({Key key}) : super(key: key); ExampleTextFiled({Key? key}) : super(key: key);
@override @override
_ExampleTextFiledState createState() => _ExampleTextFiledState(); _ExampleTextFiledState createState() => _ExampleTextFiledState();
} }
class _ExampleTextFiledState extends State<ExampleTextFiled> { class _ExampleTextFiledState extends State<ExampleTextFiled> {
TextEditingController _controller; TextEditingController? _controller;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ASScaffold( return ASScaffold(

@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
class ExampleToast extends StatelessWidget { class ExampleToast extends StatelessWidget {
const ExampleToast({Key key}) : super(key: key); const ExampleToast({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

@ -10,13 +10,6 @@ packages:
url: "https://git.oa00.com/flutter_pub/animated_collection.git" url: "https://git.oa00.com/flutter_pub/animated_collection.git"
source: git source: git
version: "0.0.1" version: "0.0.1"
animator:
dependency: transitive
description:
name: animator
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.0"
ansu_ui: ansu_ui:
dependency: "direct main" dependency: "direct main"
description: description:
@ -28,86 +21,93 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: args name: args
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.2.0"
async: async:
dependency: transitive dependency: transitive
description: description:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.5.0" version: "2.8.2"
auto_size_text_pk: auto_size_text_pk:
dependency: transitive dependency: transitive
description: description:
name: auto_size_text_pk name: auto_size_text_pk
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.0" version: "3.0.0"
bot_toast: bot_toast:
dependency: transitive dependency: transitive
description: description:
name: bot_toast name: bot_toast
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.1" version: "4.0.1"
characters: characters:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.3.1"
cli_util: cli_util:
dependency: transitive dependency: transitive
description: description:
name: cli_util name: cli_util
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.3.0" version: "0.3.3"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.15.0" version: "1.15.0"
cross_file:
dependency: transitive
description:
name: cross_file
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.1+4"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
name: cupertino_icons name: cupertino_icons
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.2" version: "1.0.3"
expandable: expandable:
dependency: transitive dependency: transitive
description: description:
name: expandable name: expandable
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "5.0.1" version: "5.0.1"
file: file:
dependency: transitive dependency: transitive
description: description:
name: file name: file
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.1.0" version: "6.1.2"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -117,7 +117,7 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: flutter_easyrefresh name: flutter_easyrefresh
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.2.1" version: "2.2.1"
flutter_localizations: flutter_localizations:
@ -129,16 +129,16 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: flutter_plugin_android_lifecycle name: flutter_plugin_android_lifecycle
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.1" version: "2.0.2"
flutter_screenutil: flutter_screenutil:
dependency: transitive dependency: transitive
description: description:
name: flutter_screenutil name: flutter_screenutil
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "5.0.0" version: "5.0.0+2"
flutter_web_plugins: flutter_web_plugins:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -148,107 +148,107 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: get name: get
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.1.4" version: "4.3.8"
glob: glob:
dependency: transitive dependency: transitive
description: description:
name: glob name: glob
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.1" version: "2.0.1"
grinder: grinder:
dependency: "direct main" dependency: "direct main"
description: description:
name: grinder name: grinder
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.9.0" version: "0.9.0"
http: http:
dependency: transitive dependency: transitive
description: description:
name: http name: http
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.13.1" version: "0.13.3"
http_parser: http_parser:
dependency: transitive dependency: transitive
description: description:
name: http_parser name: http_parser
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.0" version: "4.0.0"
image_picker: image_picker:
dependency: transitive dependency: transitive
description: description:
name: image_picker name: image_picker
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.7.4" version: "0.7.5+4"
image_picker_for_web: image_picker_for_web:
dependency: transitive dependency: transitive
description: description:
name: image_picker_for_web name: image_picker_for_web
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.1.3"
image_picker_platform_interface: image_picker_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: image_picker_platform_interface name: image_picker_platform_interface
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.1" version: "2.3.0"
intl: intl:
dependency: transitive dependency: transitive
description: description:
name: intl name: intl
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.17.0" version: "0.17.0"
js: js:
dependency: transitive dependency: transitive
description: description:
name: js name: js
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.3" version: "0.6.3"
lpinyin: lpinyin:
dependency: transitive dependency: transitive
description: description:
name: lpinyin name: lpinyin
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.1" version: "2.0.3"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0"
pedantic: pedantic:
dependency: transitive dependency: transitive
description: description:
name: pedantic name: pedantic
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.11.0" version: "1.11.1"
plugin_platform_interface: plugin_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: plugin_platform_interface name: plugin_platform_interface
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.1"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -258,58 +258,51 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.1" version: "1.8.1"
states_rebuilder:
dependency: transitive
description:
name: states_rebuilder
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.0.0+1"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
velocity_x: velocity_x:
dependency: transitive dependency: transitive
description: description:
name: velocity_x name: velocity_x
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.6.1" version: "3.3.0"
vxstate: vxstate:
dependency: transitive dependency: transitive
description: description:
name: vxstate name: vxstate
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.1" version: "2.1.0"
sdks: sdks:
dart: ">=2.12.0 <3.0.0" dart: ">=2.12.0 <3.0.0"
flutter: ">=2.0.0" flutter: ">=2.0.0"

@ -4,7 +4,7 @@ publish_to: "none"
version: 1.0.0+1 version: 1.0.0+1
environment: environment:
sdk: ">=2.7.0 <3.0.0" sdk: '>=2.12.0 <3.0.0'
dependencies: dependencies:
flutter: flutter:
@ -17,7 +17,7 @@ dependencies:
cupertino_icons: ^1.0.0 cupertino_icons: ^1.0.0
ansu_ui: ansu_ui:
path: ../ path: ../
get: get: ^4.1.3
grinder: grinder:
args: args:

@ -25,7 +25,7 @@ void main(List<String> arguments) {
writeSegments( writeSegments(
sourceDirectoryPath: path.join(Directory.current.path, 'lib'), sourceDirectoryPath: path.join(Directory.current.path, 'lib'),
targetFilePath: argResults['target'] as String, targetFilePath: argResults['target'] as String?,
isDryRun: argResults['dry-run'] as bool, isDryRun: argResults['dry-run'] as bool,
); );
} }

@ -76,15 +76,15 @@ class DartSyntaxPrehighlighter extends SyntaxPrehighlighter {
'bool', 'bool',
]; ];
String _src; String? _src;
StringScanner _scanner; late StringScanner _scanner;
List<_HighlightSpan> _spans; late List<_HighlightSpan> _spans;
@override @override
List<CodeSpan> format(String src) { List<CodeSpan> format(String? src) {
_src = src; _src = src;
_scanner = StringScanner(_src); _scanner = StringScanner(_src!);
if (_generateSpans()) { if (_generateSpans()) {
// Successfully parsed the code // Successfully parsed the code
@ -93,19 +93,19 @@ class DartSyntaxPrehighlighter extends SyntaxPrehighlighter {
for (final span in _spans) { for (final span in _spans) {
if (currentPosition != span.start) { if (currentPosition != span.start) {
formattedText formattedText.add(
.add(CodeSpan(text: _src.substring(currentPosition, span.start))); CodeSpan(text: _src!.substring(currentPosition, span.start)));
} }
formattedText formattedText
.add(CodeSpan(type: span.type, text: span.textForSpan(_src))); .add(CodeSpan(type: span.type, text: span.textForSpan(_src!)));
currentPosition = span.end; currentPosition = span.end;
} }
if (currentPosition != _src.length) { if (currentPosition != _src!.length) {
formattedText formattedText.add(
.add(CodeSpan(text: _src.substring(currentPosition, _src.length))); CodeSpan(text: _src!.substring(currentPosition, _src!.length)));
} }
return formattedText; return formattedText;
@ -126,23 +126,23 @@ class DartSyntaxPrehighlighter extends SyntaxPrehighlighter {
if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) { if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.comment, _HighlightType.comment,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
// Line comments // Line comments
if (_scanner.scan('//')) { if (_scanner.scan('//')) {
final startComment = _scanner.lastMatch.start; final startComment = _scanner.lastMatch!.start;
var eof = false; var eof = false;
int endComment; int endComment;
if (_scanner.scan(RegExp(r'.*\n'))) { if (_scanner.scan(RegExp(r'.*\n'))) {
endComment = _scanner.lastMatch.end - 1; endComment = _scanner.lastMatch!.end - 1;
} else { } else {
eof = true; eof = true;
endComment = _src.length; endComment = _src!.length;
} }
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
@ -162,8 +162,8 @@ class DartSyntaxPrehighlighter extends SyntaxPrehighlighter {
if (_scanner.scan(RegExp(r'r".*"'))) { if (_scanner.scan(RegExp(r'r".*"'))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.string, _HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
@ -172,8 +172,8 @@ class DartSyntaxPrehighlighter extends SyntaxPrehighlighter {
if (_scanner.scan(RegExp(r"r'.*'"))) { if (_scanner.scan(RegExp(r"r'.*'"))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.string, _HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
@ -182,8 +182,8 @@ class DartSyntaxPrehighlighter extends SyntaxPrehighlighter {
if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) { if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.string, _HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
@ -192,8 +192,8 @@ class DartSyntaxPrehighlighter extends SyntaxPrehighlighter {
if (_scanner.scan(RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) { if (_scanner.scan(RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.string, _HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
@ -202,8 +202,8 @@ class DartSyntaxPrehighlighter extends SyntaxPrehighlighter {
if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) { if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.string, _HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
@ -212,8 +212,8 @@ class DartSyntaxPrehighlighter extends SyntaxPrehighlighter {
if (_scanner.scan(RegExp(r"'(?:[^'\\]|\\.)*'"))) { if (_scanner.scan(RegExp(r"'(?:[^'\\]|\\.)*'"))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.string, _HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
@ -222,8 +222,8 @@ class DartSyntaxPrehighlighter extends SyntaxPrehighlighter {
if (_scanner.scan(RegExp(r'\d+\.\d+'))) { if (_scanner.scan(RegExp(r'\d+\.\d+'))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.number, _HighlightType.number,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
@ -231,7 +231,7 @@ class DartSyntaxPrehighlighter extends SyntaxPrehighlighter {
// Integer // Integer
if (_scanner.scan(RegExp(r'\d+'))) { if (_scanner.scan(RegExp(r'\d+'))) {
_spans.add(_HighlightSpan(_HighlightType.number, _spans.add(_HighlightSpan(_HighlightType.number,
_scanner.lastMatch.start, _scanner.lastMatch.end)); _scanner.lastMatch!.start, _scanner.lastMatch!.end));
continue; continue;
} }
@ -239,8 +239,8 @@ class DartSyntaxPrehighlighter extends SyntaxPrehighlighter {
if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) { if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.punctuation, _HighlightType.punctuation,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
@ -249,17 +249,17 @@ class DartSyntaxPrehighlighter extends SyntaxPrehighlighter {
if (_scanner.scan(RegExp(r'@\w+'))) { if (_scanner.scan(RegExp(r'@\w+'))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.keyword, _HighlightType.keyword,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
// Words // Words
if (_scanner.scan(RegExp(r'\w+'))) { if (_scanner.scan(RegExp(r'\w+'))) {
_HighlightType type; _HighlightType? type;
var word = _scanner.lastMatch[0]; var word = _scanner.lastMatch![0]!;
if (word.startsWith('_')) { if (word.startsWith('_')) {
word = word.substring(1); word = word.substring(1);
} }
@ -279,8 +279,8 @@ class DartSyntaxPrehighlighter extends SyntaxPrehighlighter {
if (type != null) { if (type != null) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
type, type,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
} }
} }
@ -346,13 +346,13 @@ class CodeSpan {
CodeSpan({this.type = _HighlightType.base, this.text}); CodeSpan({this.type = _HighlightType.base, this.text});
final _HighlightType type; final _HighlightType type;
final String text; final String? text;
@override @override
String toString() { String toString() {
return 'TextSpan(' return 'TextSpan('
'style: codeStyle.${_styleNameOf(type)}, ' 'style: codeStyle.${_styleNameOf(type)}, '
"text: '${_escape(text)}'" "text: '${_escape(text!)}'"
')'; ')';
} }
} }
@ -376,7 +376,6 @@ String _styleNameOf(_HighlightType type) {
case _HighlightType.base: case _HighlightType.base:
return 'baseStyle'; return 'baseStyle';
} }
return '';
} }
String _escape(String text) { String _escape(String text) {

@ -4,6 +4,7 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'prehighlighter.dart'; import 'prehighlighter.dart';
const _globalPrologue = const _globalPrologue =
@ -30,7 +31,7 @@ enum _FileReadStatus {
/// Returns the new status of the scanner whose previous status was /// Returns the new status of the scanner whose previous status was
/// [oldStatus], after scanning the line [line]. /// [oldStatus], after scanning the line [line].
_FileReadStatus _updatedStatus(_FileReadStatus oldStatus, String line) { _FileReadStatus? _updatedStatus(_FileReadStatus? oldStatus, String line) {
_FileReadStatus lineStatus; _FileReadStatus lineStatus;
if (line.trim().startsWith('//')) { if (line.trim().startsWith('//')) {
lineStatus = _FileReadStatus.comments; lineStatus = _FileReadStatus.comments;
@ -40,7 +41,7 @@ _FileReadStatus _updatedStatus(_FileReadStatus oldStatus, String line) {
lineStatus = _FileReadStatus.finished; lineStatus = _FileReadStatus.finished;
} }
_FileReadStatus newStatus; _FileReadStatus? newStatus;
switch (oldStatus) { switch (oldStatus) {
case _FileReadStatus.comments: case _FileReadStatus.comments:
newStatus = newStatus =
@ -56,6 +57,8 @@ _FileReadStatus _updatedStatus(_FileReadStatus oldStatus, String line) {
case _FileReadStatus.finished: case _FileReadStatus.finished:
newStatus = oldStatus; newStatus = oldStatus;
break; break;
default:
newStatus = oldStatus;
} }
return newStatus; return newStatus;
} }
@ -77,7 +80,7 @@ Map<String, String> _createSegments(String sourceDirectoryPath) {
final content = file.readAsStringSync(); final content = file.readAsStringSync();
final lines = const LineSplitter().convert(content); final lines = const LineSplitter().convert(content);
var status = _FileReadStatus.comments; _FileReadStatus? status = _FileReadStatus.comments;
final prologue = StringBuffer(); final prologue = StringBuffer();
@ -135,7 +138,7 @@ Map<String, String> _createSegments(String sourceDirectoryPath) {
// Simple line. // Simple line.
for (final name in activeSubsegments) { for (final name in activeSubsegments) {
subsegments[name].writeln(line); subsegments[name]!.writeln(line);
} }
} }
} }
@ -146,7 +149,7 @@ Map<String, String> _createSegments(String sourceDirectoryPath) {
} }
var segments = <String, List<TaggedString>>{}; var segments = <String, List<TaggedString>>{};
var segmentPrologues = <String, String>{}; var segmentPrologues = <String, String?>{};
// Sometimes a code segment is made up of subsegments. They are marked by // Sometimes a code segment is made up of subsegments. They are marked by
// names with a "#" symbol in it, such as "bottomSheetDemoModal#1" and // names with a "#" symbol in it, such as "bottomSheetDemoModal#1" and
@ -168,7 +171,7 @@ Map<String, String> _createSegments(String sourceDirectoryPath) {
if (!segments.containsKey(name)) { if (!segments.containsKey(name)) {
segments[name] = []; segments[name] = [];
} }
segments[name].add( segments[name]!.add(
TaggedString( TaggedString(
text: value.toString(), text: value.toString(),
order: order, order: order,
@ -179,7 +182,7 @@ Map<String, String> _createSegments(String sourceDirectoryPath) {
}); });
segments.forEach((key, value) { segments.forEach((key, value) {
value.sort((ts1, ts2) => (ts1.order - ts2.order).sign.round()); value.sort((ts1, ts2) => (ts1.order! - ts2.order!).sign.round());
}); });
var answer = <String, String>{}; var answer = <String, String>{};
@ -187,11 +190,11 @@ Map<String, String> _createSegments(String sourceDirectoryPath) {
for (final name in segments.keys) { for (final name in segments.keys) {
final buffer = StringBuffer(); final buffer = StringBuffer();
buffer.write(segmentPrologues[name].trim()); buffer.write(segmentPrologues[name]!.trim());
buffer.write('\n\n'); buffer.write('\n\n');
for (final ts in segments[name]) { for (final ts in segments[name]!) {
buffer.write(ts.text.trim()); buffer.write(ts.text!.trim());
buffer.write('\n\n'); buffer.write('\n\n');
} }
@ -208,8 +211,8 @@ Map<String, String> _createSegments(String sourceDirectoryPath) {
class TaggedString { class TaggedString {
TaggedString({this.text, this.order}); TaggedString({this.text, this.order});
final String text; final String? text;
final double order; final double? order;
} }
void _formatSegments(Map<String, String> segments, IOSink output) { void _formatSegments(Map<String, String> segments, IOSink output) {
@ -254,9 +257,11 @@ void _formatSegments(Map<String, String> segments, IOSink output) {
/// ///
/// The target file is overwritten. /// The target file is overwritten.
void writeSegments( void writeSegments(
{String sourceDirectoryPath, String targetFilePath, bool isDryRun}) { {required String sourceDirectoryPath,
String? targetFilePath,
required bool isDryRun}) {
final segments = _createSegments(sourceDirectoryPath); final segments = _createSegments(sourceDirectoryPath);
final output = isDryRun ? stdout : File(targetFilePath).openWrite(); final output = isDryRun ? stdout : File(targetFilePath!).openWrite();
_formatSegments(segments, output); _formatSegments(segments, output);
} }

@ -63,7 +63,7 @@ Future<void> _runProcess(String executable, List<String> arguments) async {
// Function to make sure we capture all of the stdout. // Function to make sure we capture all of the stdout.
// Reference: https://github.com/dart-lang/sdk/issues/31666 // Reference: https://github.com/dart-lang/sdk/issues/31666
Future<String> _startProcess(String executable, Future<String> _startProcess(String executable,
{List<String> arguments = const [], String input}) async { {List<String> arguments = const [], String? input}) async {
final output = <int>[]; final output = <int>[];
final completer = Completer<int>(); final completer = Completer<int>();
final process = await Process.start(executable, arguments); final process = await Process.start(executable, arguments);

@ -10,88 +10,81 @@ packages:
url: "https://git.oa00.com/flutter_pub/animated_collection.git" url: "https://git.oa00.com/flutter_pub/animated_collection.git"
source: git source: git
version: "0.0.1" version: "0.0.1"
animator:
dependency: transitive
description:
name: animator
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.1.0"
async: async:
dependency: transitive dependency: transitive
description: description:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.5.0" version: "2.5.0"
auto_size_text_pk: auto_size_text_pk:
dependency: transitive dependency: transitive
description: description:
name: auto_size_text_pk name: auto_size_text_pk
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.0" version: "3.0.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
bot_toast: bot_toast:
dependency: "direct main" dependency: "direct main"
description: description:
name: bot_toast name: bot_toast
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.1" version: "4.0.1"
characters: characters:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.15.0" version: "1.15.0"
cross_file: cross_file:
dependency: transitive dependency: transitive
description: description:
name: cross_file name: cross_file
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.3.1+4" version: "0.3.1+4"
expandable: expandable:
dependency: "direct main" dependency: "direct main"
description: description:
name: expandable name: expandable
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "5.0.1" version: "5.0.1"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
name: fake_async name: fake_async
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
flutter: flutter:
@ -103,21 +96,21 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_easyrefresh name: flutter_easyrefresh
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.2.1" version: "2.2.1"
flutter_plugin_android_lifecycle: flutter_plugin_android_lifecycle:
dependency: transitive dependency: transitive
description: description:
name: flutter_plugin_android_lifecycle name: flutter_plugin_android_lifecycle
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.2" version: "2.0.2"
flutter_screenutil: flutter_screenutil:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_screenutil name: flutter_screenutil
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "5.0.0+2" version: "5.0.0+2"
flutter_test: flutter_test:
@ -134,98 +127,98 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: get name: get
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.1.4" version: "4.3.8"
http: http:
dependency: transitive dependency: transitive
description: description:
name: http name: http
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.13.3" version: "0.13.3"
http_parser: http_parser:
dependency: transitive dependency: transitive
description: description:
name: http_parser name: http_parser
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.0" version: "4.0.0"
image_picker: image_picker:
dependency: "direct main" dependency: "direct main"
description: description:
name: image_picker name: image_picker
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.7.5+4" version: "0.7.5+4"
image_picker_for_web: image_picker_for_web:
dependency: transitive dependency: transitive
description: description:
name: image_picker_for_web name: image_picker_for_web
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.3"
image_picker_platform_interface: image_picker_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: image_picker_platform_interface name: image_picker_platform_interface
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.2.0" version: "2.3.0"
intl: intl:
dependency: transitive dependency: transitive
description: description:
name: intl name: intl
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.17.0" version: "0.17.0"
js: js:
dependency: transitive dependency: transitive
description: description:
name: js name: js
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.3" version: "0.6.3"
lpinyin: lpinyin:
dependency: "direct main" dependency: "direct main"
description: description:
name: lpinyin name: lpinyin
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.3" version: "2.0.3"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.10" version: "0.12.10"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0"
pedantic: pedantic:
dependency: transitive dependency: transitive
description: description:
name: pedantic name: pedantic
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.11.1" version: "1.11.1"
plugin_platform_interface: plugin_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: plugin_platform_interface name: plugin_platform_interface
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.1" version: "2.0.1"
sky_engine: sky_engine:
@ -237,77 +230,70 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.10.0" version: "1.10.0"
states_rebuilder:
dependency: transitive
description:
name: states_rebuilder
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.3.0"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.19" version: "0.2.19"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
velocity_x: velocity_x:
dependency: "direct main" dependency: "direct main"
description: description:
name: velocity_x name: velocity_x
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.6.1" version: "3.3.0"
vxstate: vxstate:
dependency: transitive dependency: transitive
description: description:
name: vxstate name: vxstate
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
sdks: sdks:

@ -16,7 +16,7 @@ dependencies:
lpinyin: ^2.0.1 lpinyin: ^2.0.1
image_picker: ^0.7.2 image_picker: ^0.7.2
bot_toast: ^4.0.0+1 bot_toast: ^4.0.0+1
velocity_x: ^2.6.1 velocity_x: ^3.3.0
expandable: ^5.0.1 expandable: ^5.0.1
animated_collection: animated_collection:
git: git:

Loading…
Cancel
Save