Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 11c7818

Browse files
#Migrate to null safety v1.1.0
1 parent dd0f44b commit 11c7818

File tree

9 files changed

+95
-90
lines changed

9 files changed

+95
-90
lines changed

‎CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,8 @@
8585

8686
## 1.0.21
8787

88-
* Add SpaceEvenly Gravity
88+
* Add SpaceEvenly Gravity
89+
90+
## 1.1.0
91+
92+
* Migrate to null safety

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Global dialog function encapsulation, with a semantic way to fill the content in
1717

1818
```yaml
1919
dependencies:
20-
flutter_custom_dialog: ^1.0.21
20+
flutter_custom_dialog: ^1.1.0
2121
```
2222
2323
**2、import**

‎README_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
```yaml
1717
dependencies:
18-
flutter_custom_dialog: ^1.0.21
18+
flutter_custom_dialog: ^1.1.0
1919
```
2020
2121
**2、import**

‎example/.flutter-plugins-dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_custom_dialog","path":"C:\\\\YYLive4-OpenSource\\\\flutter-custom-dialog\\\\","dependencies":[]}],"android":[{"name":"flutter_custom_dialog","path":"C:\\\\YYLive4-OpenSource\\\\flutter-custom-dialog\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_custom_dialog","dependencies":[]}],"date_created":"2021年08月16日 18:33:17.928565","version":"2.2.3"}
1+
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_custom_dialog","path":"C:\\\\YYLive4-OpenSource\\\\flutter-custom-dialog\\\\","dependencies":[]}],"android":[{"name":"flutter_custom_dialog","path":"C:\\\\YYLive4-OpenSource\\\\flutter-custom-dialog\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_custom_dialog","dependencies":[]}],"date_created":"2021年08月16日 20:01:06.563734","version":"2.2.3"}

‎example/pubspec.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,3 @@ packages:
158158
version: "2.1.0"
159159
sdks:
160160
dart: ">=2.12.0 <3.0.0"
161-
flutter: ">=1.12.0"

‎lib/flutter_custom_dialog.dart

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ export 'package:flutter_custom_dialog/flutter_custom_dialog.dart';
77
class YYDialog {
88
//================================弹窗属性======================================
99
List<Widget> widgetList = []; //弹窗内部所有组件
10-
static BuildContext _context; //弹窗上下文
11-
BuildContext context; //弹窗上下文
10+
static BuildContext? _context; //弹窗上下文
11+
BuildContext? context; //弹窗上下文
1212

13-
double width; //弹窗宽度
14-
double height; //弹窗高度
13+
double? width; //弹窗宽度
14+
double? height; //弹窗高度
1515
Duration duration = Duration(milliseconds: 250); //弹窗动画出现的时间
1616
Gravity gravity = Gravity.center; //弹窗出现的位置
1717
bool gravityAnimationEnable = false; //弹窗出现的位置带有的默认动画是否可用
1818
Color barrierColor = Colors.black.withOpacity(.3); //弹窗外的背景色
19-
BoxConstraints constraints; //弹窗约束
20-
Function(Widget child, Animation<double> animation) animatedFunc; //弹窗出现的动画
19+
BoxConstraints? constraints; //弹窗约束
20+
Function(Widget child, Animation<double> animation)? animatedFunc; //弹窗出现的动画
2121
bool barrierDismissible = true; //是否点击弹出外部消失
2222
EdgeInsets margin = EdgeInsets.all(0.0); //弹窗布局的外边距
2323

@@ -26,12 +26,12 @@ class YYDialog {
2626
/// @params useRootNavigator=true,push是用的嵌套根布局的context
2727
bool useRootNavigator = true;
2828

29-
Decoration decoration; //弹窗内的装饰,与backgroundColor和borderRadius互斥
29+
Decoration? decoration; //弹窗内的装饰,与backgroundColor和borderRadius互斥
3030
Color backgroundColor = Colors.white; //弹窗内的背景色
3131
double borderRadius = 0.0; //弹窗圆角
3232

33-
Function() showCallBack; //展示的回调
34-
Function() dismissCallBack; //消失的回调
33+
Function()? showCallBack; //展示的回调
34+
Function()? dismissCallBack; //消失的回调
3535

3636
get isShowing => _isShowing; //当前 弹窗是否可见
3737
bool _isShowing = false;
@@ -41,7 +41,7 @@ class YYDialog {
4141
_context = ctx;
4242
}
4343

44-
YYDialog build([BuildContext ctx]) {
44+
YYDialog build([BuildContext? ctx]) {
4545
if (ctx == null && _context != null) {
4646
this.context = _context;
4747
return this;
@@ -101,7 +101,7 @@ class YYDialog {
101101
fontSize1,
102102
fontWeight1,
103103
fontFamily1,
104-
VoidCallback onTap1,
104+
VoidCallback? onTap1,
105105
buttonPadding1 = const EdgeInsets.all(0.0),
106106
text2,
107107
color2,
@@ -164,18 +164,18 @@ class YYDialog {
164164
}
165165

166166
YYDialog listViewOfListTile({
167-
List<ListTileItem> items,
168-
double height,
167+
List<ListTileItem>? items,
168+
double? height,
169169
isClickAutoDismiss = true,
170-
Function(int) onClickItemListener,
170+
Function(int)? onClickItemListener,
171171
}) {
172172
return this.widget(
173173
Container(
174174
height: height,
175175
child: ListView.builder(
176176
padding: EdgeInsets.all(0.0),
177177
shrinkWrap: true,
178-
itemCount: items.length,
178+
itemCount: items?.length??0,
179179
itemBuilder: (BuildContext context, int index) {
180180
return Material(
181181
color: Colors.white,
@@ -189,15 +189,15 @@ class YYDialog {
189189
dismiss();
190190
}
191191
},
192-
contentPadding: items[index].padding ?? EdgeInsets.all(0.0),
193-
leading: items[index].leading,
192+
contentPadding: items?[index].padding ?? EdgeInsets.all(0.0),
193+
leading: items?[index].leading,
194194
title: Text(
195-
items[index].text ?? "",
195+
items?[index].text ?? "",
196196
style: TextStyle(
197-
color: items[index].color ?? null,
198-
fontSize: items[index].fontSize ?? null,
199-
fontWeight: items[index].fontWeight,
200-
fontFamily: items[index].fontFamily,
197+
color: items?[index].color ?? null,
198+
fontSize: items?[index].fontSize ?? null,
199+
fontWeight: items?[index].fontWeight,
200+
fontFamily: items?[index].fontFamily,
201201
),
202202
),
203203
),
@@ -210,14 +210,14 @@ class YYDialog {
210210
}
211211

212212
YYDialog listViewOfRadioButton({
213-
List<RadioItem> items,
214-
double height,
215-
Color color,
216-
Color activeColor,
217-
int intialValue,
218-
Function(int) onClickItemListener,
213+
List<RadioItem>? items,
214+
double? height,
215+
Color? color,
216+
Color? activeColor,
217+
int? intialValue,
218+
Function(int)? onClickItemListener,
219219
}) {
220-
Size size = MediaQuery.of(context).size;
220+
Size size = MediaQuery.of(context!).size;
221221
return this.widget(
222222
Container(
223223
height: height,
@@ -270,7 +270,7 @@ class YYDialog {
270270
CustomDialog(
271271
gravity: gravity,
272272
gravityAnimationEnable: gravityAnimationEnable,
273-
context: this.context,
273+
context: this.context!,
274274
barrierColor: barrierColor,
275275
animatedFunc: animatedFunc,
276276
barrierDismissible: barrierDismissible,
@@ -300,13 +300,9 @@ class YYDialog {
300300
isShowingChange: (bool isShowingChange) {
301301
// showing or dismiss Callback
302302
if (isShowingChange) {
303-
if (showCallBack != null) {
304-
showCallBack();
305-
}
303+
showCallBack?.call();
306304
} else {
307-
if (dismissCallBack != null) {
308-
dismissCallBack();
309-
}
305+
dismissCallBack?.call();
310306
}
311307
_isShowing = isShowingChange;
312308
},
@@ -321,7 +317,7 @@ class YYDialog {
321317

322318
void dismiss() {
323319
if (_isShowing) {
324-
Navigator.of(context, rootNavigator: useRootNavigator).pop();
320+
Navigator.of(context!, rootNavigator: useRootNavigator).pop();
325321
}
326322
}
327323

@@ -403,7 +399,7 @@ class YYDialog {
403399
///弹窗的内容作为可变组件
404400
class CustomDialogChildren extends StatefulWidget {
405401
final List<Widget> widgetList; //弹窗内部所有组件
406-
final Function(bool) isShowingChange;
402+
final Function(bool)? isShowingChange;
407403

408404
CustomDialogChildren({this.widgetList = const [], this.isShowingChange});
409405

@@ -414,15 +410,19 @@ class CustomDialogChildren extends StatefulWidget {
414410
class CustomDialogChildState extends State<CustomDialogChildren> {
415411
@override
416412
Widget build(BuildContext context) {
417-
widget.isShowingChange(true);
413+
if (widget.isShowingChange != null) {
414+
widget.isShowingChange!(true);
415+
}
418416
return Column(
419417
children: widget.widgetList,
420418
);
421419
}
422420

423421
@override
424422
void dispose() {
425-
widget.isShowingChange(false);
423+
if (widget.isShowingChange != null) {
424+
widget.isShowingChange!(false);
425+
}
426426
super.dispose();
427427
}
428428
}
@@ -431,24 +431,24 @@ class CustomDialogChildState extends State<CustomDialogChildren> {
431431
class CustomDialog {
432432
BuildContext _context;
433433
Widget _child;
434-
Duration _duration;
435-
Color _barrierColor;
436-
RouteTransitionsBuilder _transitionsBuilder;
437-
bool _barrierDismissible;
438-
Gravity _gravity;
434+
Duration? _duration;
435+
Color? _barrierColor;
436+
RouteTransitionsBuilder? _transitionsBuilder;
437+
bool? _barrierDismissible;
438+
Gravity? _gravity;
439439
bool _gravityAnimationEnable;
440-
Function _animatedFunc;
440+
Function? _animatedFunc;
441441

442442
CustomDialog({
443-
@required Widget child,
444-
@required BuildContext context,
445-
Duration duration,
446-
Color barrierColor,
447-
RouteTransitionsBuilder transitionsBuilder,
448-
Gravity gravity,
449-
bool gravityAnimationEnable,
450-
Function animatedFunc,
451-
bool barrierDismissible,
443+
required Widget child,
444+
required BuildContext context,
445+
Duration? duration,
446+
Color? barrierColor,
447+
RouteTransitionsBuilder? transitionsBuilder,
448+
Gravity? gravity,
449+
bool gravityAnimationEnable=false,
450+
Function? animatedFunc,
451+
bool? barrierDismissible,
452452
}) : _child = child,
453453
_context = context,
454454
_gravity = gravity,
@@ -531,7 +531,7 @@ class CustomDialog {
531531

532532
//自定义动画
533533
if (_animatedFunc != null) {
534-
return _animatedFunc(child, animation);
534+
return _animatedFunc!(child, animation);
535535
}
536536

537537
//不需要默认动画
@@ -576,13 +576,13 @@ class ListTileItem {
576576
this.fontFamily,
577577
});
578578

579-
EdgeInsets padding;
580-
Widget leading;
581-
String text;
582-
Color color;
583-
double fontSize;
584-
FontWeight fontWeight;
585-
String fontFamily;
579+
EdgeInsets? padding;
580+
Widget? leading;
581+
String? text;
582+
Color? color;
583+
double? fontSize;
584+
FontWeight? fontWeight;
585+
String? fontFamily;
586586
}
587587

588588
class RadioItem {
@@ -595,11 +595,11 @@ class RadioItem {
595595
this.onTap,
596596
});
597597

598-
EdgeInsets padding;
599-
String text;
600-
Color color;
601-
double fontSize;
602-
FontWeight fontWeight;
603-
Function(int) onTap;
598+
EdgeInsets? padding;
599+
String? text;
600+
Color? color;
601+
double? fontSize;
602+
FontWeight? fontWeight;
603+
Function(int)? onTap;
604604
}
605605
//============================================================================

‎lib/flutter_custom_dialog_widget.dart

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export 'package:flutter_custom_dialog/flutter_custom_dialog_widget.dart';
77

88
class YYRadioListTile extends StatefulWidget {
99
YYRadioListTile({
10-
Key key,
10+
Key? key,
1111
this.items,
1212
this.intialValue,
1313
this.color,
@@ -16,11 +16,11 @@ class YYRadioListTile extends StatefulWidget {
1616
}) : assert(items != null),
1717
super(key: key);
1818

19-
final List<RadioItem> items;
20-
final Color color;
21-
final Color activeColor;
19+
final List<RadioItem>? items;
20+
final Color? color;
21+
final Color? activeColor;
2222
final intialValue;
23-
final Function(int) onChanged;
23+
final Function(int)? onChanged;
2424

2525
@override
2626
State<StatefulWidget> createState() {
@@ -47,25 +47,28 @@ class YYRadioListTileState extends State<YYRadioListTile> {
4747
return ListView.builder(
4848
padding: EdgeInsets.all(0.0),
4949
shrinkWrap: true,
50-
itemCount: widget.items.length,
50+
itemCount: widget.items?.length??0,
5151
itemBuilder: (BuildContext context, int index) {
5252
return Material(
5353
color: widget.color,
5454
child: RadioListTile(
5555
title: Text(
56-
widget.items[index].text,
56+
widget.items?[index].text??"",
5757
style: TextStyle(
58-
fontSize: widget.items[index].fontSize,
59-
fontWeight: widget.items[index].fontWeight,
60-
color: widget.items[index].color),
58+
fontSize: widget.items?[index].fontSize ?? 14,
59+
fontWeight:
60+
widget.items?[index].fontWeight ?? FontWeight.normal,
61+
color: widget.items?[index].color ?? Colors.black),
6162
),
6263
value: index,
6364
groupValue: groupId,
6465
activeColor: widget.activeColor,
65-
onChanged: (int value) {
66+
onChanged: (int? value) {
6667
setState(() {
67-
widget.onChanged(value);
68-
groupId = value;
68+
if (widget.onChanged != null) {
69+
widget.onChanged!(value ?? 0);
70+
}
71+
groupId = value ?? -1;
6972
});
7073
},
7174
),

‎pubspec.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,3 @@ packages:
144144
version: "2.1.0"
145145
sdks:
146146
dart: ">=2.12.0 <3.0.0"
147-
flutter: ">=1.12.0"

‎pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: flutter_custom_dialog
22
description: Semantic dialog | Made In YY.inc | Welcome to contribute
3-
version: 1.0.21
3+
version: 1.1.0
44
homepage: https://github.com/YYFlutter/flutter-custom-dialog.git
55
publish_to: 'https://pub.dev'
66

77
environment:
8-
sdk: ">=2.1.0 <3.0.0"
8+
sdk: ">=2.12.0 <3.0.0"
99
flutter: ">=1.10.0"
1010

1111
dependencies:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /