Skip to content

Commit

Permalink
#Migrate to null safety v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AndroidHensen committed Aug 16, 2021
1 parent dd0f44b commit 11c7818
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 90 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,8 @@

## 1.0.21

* Add SpaceEvenly Gravity
* Add SpaceEvenly Gravity

## 1.1.0

* Migrate to null safety
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Global dialog function encapsulation, with a semantic way to fill the content in

```yaml
dependencies:
flutter_custom_dialog: ^1.0.21
flutter_custom_dialog: ^1.1.0
```
**2、import**
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

```yaml
dependencies:
flutter_custom_dialog: ^1.0.21
flutter_custom_dialog: ^1.1.0
```
**2、import**
Expand Down
2 changes: 1 addition & 1 deletion example/.flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -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"}
{"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"}
1 change: 0 additions & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,3 @@ packages:
version: "2.1.0"
sdks:
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.12.0"
138 changes: 69 additions & 69 deletions lib/flutter_custom_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ export 'package:flutter_custom_dialog/flutter_custom_dialog.dart';
class YYDialog {
//================================弹窗属性======================================
List<Widget> widgetList = []; //弹窗内部所有组件
static BuildContext _context; //弹窗上下文
BuildContext context; //弹窗上下文
static BuildContext? _context; //弹窗上下文
BuildContext? context; //弹窗上下文

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

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

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

Function() showCallBack; //展示的回调
Function() dismissCallBack; //消失的回调
Function()? showCallBack; //展示的回调
Function()? dismissCallBack; //消失的回调

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

YYDialog build([BuildContext ctx]) {
YYDialog build([BuildContext? ctx]) {
if (ctx == null && _context != null) {
this.context = _context;
return this;
Expand Down Expand Up @@ -101,7 +101,7 @@ class YYDialog {
fontSize1,
fontWeight1,
fontFamily1,
VoidCallback onTap1,
VoidCallback? onTap1,
buttonPadding1 = const EdgeInsets.all(0.0),
text2,
color2,
Expand Down Expand Up @@ -164,18 +164,18 @@ class YYDialog {
}

YYDialog listViewOfListTile({
List<ListTileItem> items,
double height,
List<ListTileItem>? items,
double? height,
isClickAutoDismiss = true,
Function(int) onClickItemListener,
Function(int)? onClickItemListener,
}) {
return this.widget(
Container(
height: height,
child: ListView.builder(
padding: EdgeInsets.all(0.0),
shrinkWrap: true,
itemCount: items.length,
itemCount: items?.length ?? 0,
itemBuilder: (BuildContext context, int index) {
return Material(
color: Colors.white,
Expand All @@ -189,15 +189,15 @@ class YYDialog {
dismiss();
}
},
contentPadding: items[index].padding ?? EdgeInsets.all(0.0),
leading: items[index].leading,
contentPadding: items?[index].padding ?? EdgeInsets.all(0.0),
leading: items?[index].leading,
title: Text(
items[index].text ?? "",
items?[index].text ?? "",
style: TextStyle(
color: items[index].color ?? null,
fontSize: items[index].fontSize ?? null,
fontWeight: items[index].fontWeight,
fontFamily: items[index].fontFamily,
color: items?[index].color ?? null,
fontSize: items?[index].fontSize ?? null,
fontWeight: items?[index].fontWeight,
fontFamily: items?[index].fontFamily,
),
),
),
Expand All @@ -210,14 +210,14 @@ class YYDialog {
}

YYDialog listViewOfRadioButton({
List<RadioItem> items,
double height,
Color color,
Color activeColor,
int intialValue,
Function(int) onClickItemListener,
List<RadioItem>? items,
double? height,
Color? color,
Color? activeColor,
int? intialValue,
Function(int)? onClickItemListener,
}) {
Size size = MediaQuery.of(context).size;
Size size = MediaQuery.of(context!).size;
return this.widget(
Container(
height: height,
Expand Down Expand Up @@ -270,7 +270,7 @@ class YYDialog {
CustomDialog(
gravity: gravity,
gravityAnimationEnable: gravityAnimationEnable,
context: this.context,
context: this.context!,
barrierColor: barrierColor,
animatedFunc: animatedFunc,
barrierDismissible: barrierDismissible,
Expand Down Expand Up @@ -300,13 +300,9 @@ class YYDialog {
isShowingChange: (bool isShowingChange) {
// showing or dismiss Callback
if (isShowingChange) {
if (showCallBack != null) {
showCallBack();
}
showCallBack?.call();
} else {
if (dismissCallBack != null) {
dismissCallBack();
}
dismissCallBack?.call();
}
_isShowing = isShowingChange;
},
Expand All @@ -321,7 +317,7 @@ class YYDialog {

void dismiss() {
if (_isShowing) {
Navigator.of(context, rootNavigator: useRootNavigator).pop();
Navigator.of(context!, rootNavigator: useRootNavigator).pop();
}
}

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

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

Expand All @@ -414,15 +410,19 @@ class CustomDialogChildren extends StatefulWidget {
class CustomDialogChildState extends State<CustomDialogChildren> {
@override
Widget build(BuildContext context) {
widget.isShowingChange(true);
if (widget.isShowingChange != null) {
widget.isShowingChange!(true);
}
return Column(
children: widget.widgetList,
);
}

@override
void dispose() {
widget.isShowingChange(false);
if (widget.isShowingChange != null) {
widget.isShowingChange!(false);
}
super.dispose();
}
}
Expand All @@ -431,24 +431,24 @@ class CustomDialogChildState extends State<CustomDialogChildren> {
class CustomDialog {
BuildContext _context;
Widget _child;
Duration _duration;
Color _barrierColor;
RouteTransitionsBuilder _transitionsBuilder;
bool _barrierDismissible;
Gravity _gravity;
Duration? _duration;
Color? _barrierColor;
RouteTransitionsBuilder? _transitionsBuilder;
bool? _barrierDismissible;
Gravity? _gravity;
bool _gravityAnimationEnable;
Function _animatedFunc;
Function? _animatedFunc;

CustomDialog({
@required Widget child,
@required BuildContext context,
Duration duration,
Color barrierColor,
RouteTransitionsBuilder transitionsBuilder,
Gravity gravity,
bool gravityAnimationEnable,
Function animatedFunc,
bool barrierDismissible,
required Widget child,
required BuildContext context,
Duration? duration,
Color? barrierColor,
RouteTransitionsBuilder? transitionsBuilder,
Gravity? gravity,
bool gravityAnimationEnable = false,
Function? animatedFunc,
bool? barrierDismissible,
}) : _child = child,
_context = context,
_gravity = gravity,
Expand Down Expand Up @@ -531,7 +531,7 @@ class CustomDialog {

//自定义动画
if (_animatedFunc != null) {
return _animatedFunc(child, animation);
return _animatedFunc!(child, animation);
}

//不需要默认动画
Expand Down Expand Up @@ -576,13 +576,13 @@ class ListTileItem {
this.fontFamily,
});

EdgeInsets padding;
Widget leading;
String text;
Color color;
double fontSize;
FontWeight fontWeight;
String fontFamily;
EdgeInsets? padding;
Widget? leading;
String? text;
Color? color;
double? fontSize;
FontWeight? fontWeight;
String? fontFamily;
}

class RadioItem {
Expand All @@ -595,11 +595,11 @@ class RadioItem {
this.onTap,
});

EdgeInsets padding;
String text;
Color color;
double fontSize;
FontWeight fontWeight;
Function(int) onTap;
EdgeInsets? padding;
String? text;
Color? color;
double? fontSize;
FontWeight? fontWeight;
Function(int)? onTap;
}
//============================================================================
29 changes: 16 additions & 13 deletions lib/flutter_custom_dialog_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export 'package:flutter_custom_dialog/flutter_custom_dialog_widget.dart';

class YYRadioListTile extends StatefulWidget {
YYRadioListTile({
Key key,
Key? key,
this.items,
this.intialValue,
this.color,
Expand All @@ -16,11 +16,11 @@ class YYRadioListTile extends StatefulWidget {
}) : assert(items != null),
super(key: key);

final List<RadioItem> items;
final Color color;
final Color activeColor;
final List<RadioItem>? items;
final Color? color;
final Color? activeColor;
final intialValue;
final Function(int) onChanged;
final Function(int)? onChanged;

@override
State<StatefulWidget> createState() {
Expand All @@ -47,25 +47,28 @@ class YYRadioListTileState extends State<YYRadioListTile> {
return ListView.builder(
padding: EdgeInsets.all(0.0),
shrinkWrap: true,
itemCount: widget.items.length,
itemCount: widget.items?.length ?? 0,
itemBuilder: (BuildContext context, int index) {
return Material(
color: widget.color,
child: RadioListTile(
title: Text(
widget.items[index].text,
widget.items?[index].text ?? "",
style: TextStyle(
fontSize: widget.items[index].fontSize,
fontWeight: widget.items[index].fontWeight,
color: widget.items[index].color),
fontSize: widget.items?[index].fontSize ?? 14,
fontWeight:
widget.items?[index].fontWeight ?? FontWeight.normal,
color: widget.items?[index].color ?? Colors.black),
),
value: index,
groupValue: groupId,
activeColor: widget.activeColor,
onChanged: (int value) {
onChanged: (int? value) {
setState(() {
widget.onChanged(value);
groupId = value;
if (widget.onChanged != null) {
widget.onChanged!(value ?? 0);
}
groupId = value ?? -1;
});
},
),
Expand Down
1 change: 0 additions & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,3 @@ packages:
version: "2.1.0"
sdks:
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.12.0"
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: flutter_custom_dialog
description: Semantic dialog | Made In YY.inc | Welcome to contribute
version: 1.0.21
version: 1.1.0
homepage: https://github.com/YYFlutter/flutter-custom-dialog.git
publish_to: 'https://pub.dev'

environment:
sdk: ">=2.1.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.10.0"

dependencies:
Expand Down

0 comments on commit 11c7818

Please sign in to comment.