diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies new file mode 100644 index 0000000..48675a0 --- /dev/null +++ b/example/.flutter-plugins-dependencies @@ -0,0 +1 @@ +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_custom_dialog","path":"/Users/etornam/Projects/FlutterProjects/flutter-custom-dialog/","dependencies":[]}],"android":[{"name":"flutter_custom_dialog","path":"/Users/etornam/Projects/FlutterProjects/flutter-custom-dialog/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_custom_dialog","dependencies":[]}],"date_created":"2021-03-20 20:25:08.631143","version":"2.0.3"} \ No newline at end of file diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig index 592ceee..ec97fc6 100644 --- a/example/ios/Flutter/Debug.xcconfig +++ b/example/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig index 592ceee..c4855bf 100644 --- a/example/ios/Flutter/Release.xcconfig +++ b/example/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index 29b4ef4..0440f17 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -1,8 +1,13 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=C:\FlutterSDK\flutter" -export "FLUTTER_APPLICATION_PATH=C:\YYLive4-OpenSource\flutter-custom-dialog\flutter_custom_dialog\example" -export "FLUTTER_TARGET=lib\main.dart" +export "FLUTTER_ROOT=/Users/etornam/flutter" +export "FLUTTER_APPLICATION_PATH=/Users/etornam/Projects/FlutterProjects/flutter-custom-dialog/example" +export "FLUTTER_TARGET=lib/main.dart" export "FLUTTER_BUILD_DIR=build" -export "SYMROOT=${SOURCE_ROOT}/../build\ios" -export "FLUTTER_FRAMEWORK_DIR=C:\FlutterSDK\flutter\bin\cache\artifacts\engine\ios" +export "SYMROOT=${SOURCE_ROOT}/../build/ios" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=false" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=.packages" diff --git a/example/ios/Podfile b/example/ios/Podfile new file mode 100644 index 0000000..f7d6a5e --- /dev/null +++ b/example/ios/Podfile @@ -0,0 +1,38 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/example/pubspec.lock b/example/pubspec.lock index aa5283a..11975c1 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,28 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.2.0" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: @@ -36,6 +50,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.2" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -47,7 +68,7 @@ packages: path: ".." relative: true source: path - version: "1.0.19" + version: "1.0.20" flutter_test: dependency: "direct dev" description: flutter @@ -59,35 +80,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.5" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.7" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0+1" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.5" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -99,55 +106,55 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.5.5" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.5" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0" sdks: - dart: ">=2.2.2 <3.0.0" + dart: ">=2.12.0 <3.0.0" diff --git a/lib/flutter_custom_dialog.dart b/lib/flutter_custom_dialog.dart index fd072e9..8972c8e 100644 --- a/lib/flutter_custom_dialog.dart +++ b/lib/flutter_custom_dialog.dart @@ -7,17 +7,17 @@ export 'package:flutter_custom_dialog/flutter_custom_dialog.dart'; class YYDialog { //================================弹窗属性====================================== List 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 animation) animatedFunc; //弹窗出现的动画 + BoxConstraints? constraints; //弹窗约束 + Function(Widget child, Animation animation)? animatedFunc; //弹窗出现的动画 bool barrierDismissible = true; //是否点击弹出外部消失 EdgeInsets margin = EdgeInsets.all(0.0); //弹窗布局的外边距 @@ -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; @@ -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; @@ -101,7 +101,7 @@ class YYDialog { fontSize1, fontWeight1, fontFamily1, - VoidCallback onTap1, + VoidCallback? onTap1, text2, color2, fontSize2, @@ -162,10 +162,10 @@ class YYDialog { } YYDialog listViewOfListTile({ - List items, - double height, + required List items, + double? height, isClickAutoDismiss = true, - Function(int) onClickItemListener, + Function(int)? onClickItemListener, }) { return this.widget( Container( @@ -208,14 +208,14 @@ class YYDialog { } YYDialog listViewOfRadioButton({ - List items, - double height, - Color color, - Color activeColor, - int intialValue, - Function(int) onClickItemListener, + required List 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, @@ -236,13 +236,13 @@ class YYDialog { } YYDialog circularProgress( - {padding, backgroundColor, valueColor, strokeWidth}) { + {required padding, backgroundColor, valueColor, strokeWidth}) { return this.widget(Padding( padding: padding, child: CircularProgressIndicator( strokeWidth: strokeWidth ?? 4.0, backgroundColor: backgroundColor, - valueColor: AlwaysStoppedAnimation(valueColor), + valueColor: AlwaysStoppedAnimation(valueColor), ), )); } @@ -299,11 +299,11 @@ class YYDialog { // showing or dismiss Callback if (isShowingChange) { if (showCallBack != null) { - showCallBack(); + showCallBack!(); } } else { if (dismissCallBack != null) { - dismissCallBack(); + dismissCallBack!(); } } _isShowing = isShowingChange; @@ -319,7 +319,7 @@ class YYDialog { void dismiss() { if (_isShowing) { - Navigator.of(context, rootNavigator: useRootNavigator).pop(); + Navigator.of(context!, rootNavigator: useRootNavigator).pop(); } } @@ -398,7 +398,7 @@ class YYDialog { ///弹窗的内容作为可变组件 class CustomDialogChildren extends StatefulWidget { final List widgetList; //弹窗内部所有组件 - final Function(bool) isShowingChange; + final Function(bool)? isShowingChange; CustomDialogChildren({this.widgetList = const [], this.isShowingChange}); @@ -409,7 +409,7 @@ class CustomDialogChildren extends StatefulWidget { class CustomDialogChildState extends State { @override Widget build(BuildContext context) { - widget.isShowingChange(true); + widget.isShowingChange!(true); return Column( children: widget.widgetList, ); @@ -417,33 +417,33 @@ class CustomDialogChildState extends State { @override void dispose() { - widget.isShowingChange(false); + widget.isShowingChange!(false); super.dispose(); } } ///弹窗API的封装 class CustomDialog { - BuildContext _context; + BuildContext? _context; Widget _child; - Duration _duration; - Color _barrierColor; - RouteTransitionsBuilder _transitionsBuilder; - bool _barrierDismissible; - Gravity _gravity; - bool _gravityAnimationEnable; - Function _animatedFunc; + Duration? _duration; + Color? _barrierColor; + RouteTransitionsBuilder? _transitionsBuilder; + bool? _barrierDismissible; + Gravity? _gravity; + bool? _gravityAnimationEnable; + 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, + Function? animatedFunc, + bool? barrierDismissible, }) : _child = child, _context = context, _gravity = gravity, @@ -463,12 +463,12 @@ class CustomDialog { } showGeneralDialog( - context: _context, + context: _context!, barrierColor: _barrierColor ?? Colors.black.withOpacity(.3), barrierDismissible: _barrierDismissible ?? true, barrierLabel: "", transitionDuration: _duration ?? Duration(milliseconds: 250), - transitionBuilder: _transitionsBuilder ?? _buildMaterialDialogTransitions, + transitionBuilder: _transitionsBuilder ?? _buildMaterialDialogTransitions as Widget Function(BuildContext, Animation, Animation, Widget)?, pageBuilder: (BuildContext buildContext, Animation animation, Animation secondaryAnimation) { return Builder( @@ -480,7 +480,7 @@ class CustomDialog { ); } - Widget _buildMaterialDialogTransitions( + Widget? _buildMaterialDialogTransitions( BuildContext context, Animation animation, Animation secondaryAnimation, @@ -526,11 +526,11 @@ class CustomDialog { //自定义动画 if (_animatedFunc != null) { - return _animatedFunc(child, animation); + return _animatedFunc!(child, animation); } //不需要默认动画 - if (!_gravityAnimationEnable) { + if (!_gravityAnimationEnable!) { custom = Tween( begin: Offset(0.0, 0.0), end: Offset(0.0, 0.0), @@ -570,13 +570,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 { @@ -589,11 +589,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; } //============================================================================ diff --git a/lib/flutter_custom_dialog_widget.dart b/lib/flutter_custom_dialog_widget.dart index 4978476..c608246 100644 --- a/lib/flutter_custom_dialog_widget.dart +++ b/lib/flutter_custom_dialog_widget.dart @@ -5,8 +5,8 @@ export 'package:flutter_custom_dialog/flutter_custom_dialog_widget.dart'; class YYRadioListTile extends StatefulWidget { YYRadioListTile({ - Key key, - this.items, + Key? key, + required this.items, this.intialValue, this.color, this.activeColor, @@ -15,10 +15,10 @@ class YYRadioListTile extends StatefulWidget { super(key: key); final List items; - final Color color; - final Color activeColor; + final Color? color; + final Color? activeColor; final intialValue; - final Function(int) onChanged; + final Function(int?)? onChanged; @override State createState() { @@ -27,7 +27,7 @@ class YYRadioListTile extends StatefulWidget { } class YYRadioListTileState extends State { - var groupId = -1; + int? groupId = -1; void intialSelectedItem() { //intialValue: @@ -50,13 +50,13 @@ class YYRadioListTileState extends State { return Material( color: widget.color, child: RadioListTile( - title: Text(widget.items[index].text), + title: Text(widget.items[index].text!), value: index, groupValue: groupId, activeColor: widget.activeColor, - onChanged: (int value) { + onChanged: (int? value) { setState(() { - widget.onChanged(value); + widget.onChanged!(value); groupId = value; }); }, diff --git a/pubspec.lock b/pubspec.lock index aebdafa..49a0ce6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,28 +7,49 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.2.0" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" + version: "1.15.0" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -45,35 +66,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.5" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.7" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0+1" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.5" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -85,55 +92,55 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.5.5" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.5" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0" sdks: - dart: ">=2.2.2 <3.0.0" + dart: ">=2.12.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 9d4e183..bd571e6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ author: AndroidHensen homepage: https://github.com/YYFlutter/flutter-custom-dialog.git environment: - sdk: ">=2.1.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: