From 4dff5c51cb482637da209eab61a25436faf6838e Mon Sep 17 00:00:00 2001 From: Amos Date: Wed, 18 Sep 2024 01:33:49 +0800 Subject: [PATCH] Fix: Error when analyzing code --- example/lib/demo/issue181_overstep.dart | 5 ++++- example/lib/demo/issue183_visibility.dart | 2 +- example/lib/demo/issue188_quick_close.dart | 2 +- example/lib/demo/issue190_release.dart | 2 +- example/lib/demo/issue191_toast.dart | 2 +- example/lib/demo/issue200_loading.dart | 17 ++++++++--------- example/lib/demo/issue205_dark_model.dart | 7 +++++-- example/lib/demo/issue209.dart | 8 ++++---- example/lib/main.dart | 5 ++++- lib/flutter_smart_dialog.dart | 1 + lib/src/data/loading_info.dart | 3 --- .../helper/pop_monitor/boost_route_monitor.dart | 7 ++++++- lib/src/kit/typedef.dart | 2 +- lib/src/widget/helper/attach_widget.dart | 17 ++++++++++++----- lib/src/widget/helper/smart_overlay_entry.dart | 2 +- 15 files changed, 50 insertions(+), 32 deletions(-) diff --git a/example/lib/demo/issue181_overstep.dart b/example/lib/demo/issue181_overstep.dart index fe26214..210cc21 100644 --- a/example/lib/demo/issue181_overstep.dart +++ b/example/lib/demo/issue181_overstep.dart @@ -80,7 +80,10 @@ class _TestingDialogState extends State<_TestingDialog> alignment: Alignment.bottomCenter, children: [ // 这里,点击事件也可以传递到遮罩 - SizedBox(height: MediaQuery.of(context).size.height,width: MediaQuery.of(context).size.width), + SizedBox( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + ), Container(height: 300, color: Colors.blue), AnimatedBuilder( animation: animationController, diff --git a/example/lib/demo/issue183_visibility.dart b/example/lib/demo/issue183_visibility.dart index 11b0bd6..bafe74b 100644 --- a/example/lib/demo/issue183_visibility.dart +++ b/example/lib/demo/issue183_visibility.dart @@ -141,4 +141,4 @@ class Page1 extends StatelessWidget { ], ); } -} \ No newline at end of file +} diff --git a/example/lib/demo/issue188_quick_close.dart b/example/lib/demo/issue188_quick_close.dart index b0cf961..a32252f 100644 --- a/example/lib/demo/issue188_quick_close.dart +++ b/example/lib/demo/issue188_quick_close.dart @@ -22,7 +22,7 @@ class MyApp extends StatelessWidget { ); } - void _show() async{ + void _show() async { SmartDialog.show( builder: (_) { return Container( diff --git a/example/lib/demo/issue190_release.dart b/example/lib/demo/issue190_release.dart index 442a5a8..8dad284 100644 --- a/example/lib/demo/issue190_release.dart +++ b/example/lib/demo/issue190_release.dart @@ -33,7 +33,7 @@ class MyApp extends StatelessWidget { ); }, animationType: SmartAnimationType.centerFade_otherSlide, - backDismiss: true, + backType: SmartBackType.normal, keepSingle: true, debounce: true, ); diff --git a/example/lib/demo/issue191_toast.dart b/example/lib/demo/issue191_toast.dart index 50937d8..3435c92 100644 --- a/example/lib/demo/issue191_toast.dart +++ b/example/lib/demo/issue191_toast.dart @@ -42,7 +42,7 @@ class MyApp extends StatelessWidget { }, displayTime: const Duration(milliseconds: 2000), keepSingle: true, - backDismiss: false, + backType: SmartBackType.block, ); // SmartDialog.showLoading(); diff --git a/example/lib/demo/issue200_loading.dart b/example/lib/demo/issue200_loading.dart index 5cd7f11..8a80a72 100644 --- a/example/lib/demo/issue200_loading.dart +++ b/example/lib/demo/issue200_loading.dart @@ -16,7 +16,6 @@ class MyApp extends StatelessWidget { } } - /// @Describe: 测试 /// /// @Author: LiWeNHuI @@ -63,7 +62,7 @@ class _DemoPageState extends State { maskColor: Colors.transparent, clickMaskDismiss: false, displayTime: const Duration(milliseconds: 1500), - backDismiss: false, + backType: SmartBackType.block, ); } @@ -74,7 +73,7 @@ class _DemoPageState extends State { builder: (BuildContext ctx) { return Dialog( insetPadding: - const EdgeInsets.symmetric(vertical: 24, horizontal: 32), + const EdgeInsets.symmetric(vertical: 24, horizontal: 32), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), child: PopScope( canPop: false, @@ -113,7 +112,7 @@ class _DemoPageState extends State { animationBuilder: (_, Widget child, ___) => TestAnimation(animationParam: ___, child: child), displayTime: const Duration(milliseconds: 2300), - backDismiss: false, + backType: SmartBackType.block, keepSingle: true, ); }, @@ -165,12 +164,12 @@ class _TestAnimationState extends State duration: const Duration(milliseconds: 300), vsync: this, )..addListener(() { - if (controller.value > .3 && !isStart) { - isStart = true; + if (controller.value > .3 && !isStart) { + isStart = true; - bodyController.forward(); - } - }); + bodyController.forward(); + } + }); bodyController = AnimationController( duration: const Duration(milliseconds: 8000), diff --git a/example/lib/demo/issue205_dark_model.dart b/example/lib/demo/issue205_dark_model.dart index 6c7298b..73107f2 100644 --- a/example/lib/demo/issue205_dark_model.dart +++ b/example/lib/demo/issue205_dark_model.dart @@ -18,7 +18,10 @@ class MyApp extends StatelessWidget { useMaterial3: true, ), darkTheme: ThemeData( - colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple, brightness: Brightness.dark), + colorScheme: ColorScheme.fromSeed( + seedColor: Colors.deepPurple, + brightness: Brightness.dark, + ), brightness: Brightness.dark, useMaterial3: true, ), @@ -76,4 +79,4 @@ class _MyHomePageState extends State { ), // This trailing comma makes auto-formatting nicer for build methods. ); } -} \ No newline at end of file +} diff --git a/example/lib/demo/issue209.dart b/example/lib/demo/issue209.dart index 9af16b8..f3ac60b 100644 --- a/example/lib/demo/issue209.dart +++ b/example/lib/demo/issue209.dart @@ -23,10 +23,10 @@ class MyApp extends StatelessWidget { } void _show() async { - print("before:${DateTime.now().millisecondsSinceEpoch}"); + debugPrint("before:${DateTime.now().millisecondsSinceEpoch}"); var result = await SmartDialog.show( tag: 'tag', - backDismiss: false, + backType: SmartBackType.block, clickMaskDismiss: false, builder: (_) { return ElevatedButton( @@ -37,12 +37,12 @@ class MyApp extends StatelessWidget { ); }, onDismiss: () { - print("onDismiss:${DateTime.now().millisecondsSinceEpoch}"); + debugPrint("onDismiss:${DateTime.now().millisecondsSinceEpoch}"); // showLoading()放在这里能正常显示 // SmartDialog.showLoading(); }); - print("aftermiss:${DateTime.now().millisecondsSinceEpoch}"); + debugPrint("aftermiss:${DateTime.now().millisecondsSinceEpoch}"); if (result == true) { // showLoading() 放在这里需要加一点延时才能显示Loading // await Future.delayed(const Duration(seconds: 1)); diff --git a/example/lib/main.dart b/example/lib/main.dart index 87a1d9c..f058aa2 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -15,7 +15,10 @@ class MyApp extends StatelessWidget { navigatorObservers: [FlutterSmartDialog.observer], builder: FlutterSmartDialog.init(), darkTheme: ThemeData( - colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple, brightness: Brightness.dark), + colorScheme: ColorScheme.fromSeed( + seedColor: Colors.deepPurple, + brightness: Brightness.dark, + ), brightness: Brightness.dark, useMaterial3: true, ), diff --git a/lib/flutter_smart_dialog.dart b/lib/flutter_smart_dialog.dart index 7989425..d495f49 100644 --- a/lib/flutter_smart_dialog.dart +++ b/lib/flutter_smart_dialog.dart @@ -9,6 +9,7 @@ export 'src/config/smart_config_notify.dart'; export 'src/config/smart_config_toast.dart'; export 'src/data/animation_param.dart' show AnimationParam; export 'src/data/notify_style.dart'; + /// dialog export 'src/init_dialog.dart'; export 'src/smart_dialog.dart'; diff --git a/lib/src/data/loading_info.dart b/lib/src/data/loading_info.dart index 6fc5cdf..6936c41 100644 --- a/lib/src/data/loading_info.dart +++ b/lib/src/data/loading_info.dart @@ -1,9 +1,6 @@ -import 'dart:async'; - import '../../flutter_smart_dialog.dart'; import '../custom/custom_loading.dart'; import '../kit/typedef.dart'; -import 'base_dialog.dart'; class LoadingInfo { late CustomLoading loadingWidget; diff --git a/lib/src/helper/pop_monitor/boost_route_monitor.dart b/lib/src/helper/pop_monitor/boost_route_monitor.dart index 658e80f..f4c6a27 100644 --- a/lib/src/helper/pop_monitor/boost_route_monitor.dart +++ b/lib/src/helper/pop_monitor/boost_route_monitor.dart @@ -35,12 +35,17 @@ class BoostRouteMonitor { if (route is ModalRoute) { willPopCallback() async { if (_handleSmartDialog()) { - DialogProxy.instance.dismiss(status: SmartStatus.smart, closeType: CloseType.back); + DialogProxy.instance.dismiss( + status: SmartStatus.smart, + closeType: CloseType.back, + ); return false; } return true; } + // TODO: `addScopedWillPopCallback()` was deprecated after v3.12.0-1.0.pre. + // ignore: deprecated_member_use route.addScopedWillPopCallback(willPopCallback); DialogProxy.contextNavigator = route.subtreeContext; } diff --git a/lib/src/kit/typedef.dart b/lib/src/kit/typedef.dart index 8dba90b..7cf62f3 100644 --- a/lib/src/kit/typedef.dart +++ b/lib/src/kit/typedef.dart @@ -2,4 +2,4 @@ import 'dart:async'; typedef FutureVoidCallback = Future Function(); -typedef SmartOnBack = FutureOr Function(); \ No newline at end of file +typedef SmartOnBack = FutureOr Function(); diff --git a/lib/src/widget/helper/attach_widget.dart b/lib/src/widget/helper/attach_widget.dart index 1701a3f..3a7f7a2 100644 --- a/lib/src/widget/helper/attach_widget.dart +++ b/lib/src/widget/helper/attach_widget.dart @@ -85,8 +85,10 @@ class _AttachWidgetState extends State { return Opacity(opacity: _postFrameOpacity, child: _originChild); }); - List below = widget.belowBuilder?.call(targetOffset, targetSize) ?? []; - List above = widget.aboveBuilder?.call(targetOffset, targetSize) ?? []; + List below = + widget.belowBuilder?.call(targetOffset, targetSize) ?? []; + List above = + widget.aboveBuilder?.call(targetOffset, targetSize) ?? []; return Stack(children: [ //blow for (var belowWidget in below) belowWidget, @@ -152,7 +154,9 @@ class _AttachWidgetState extends State { } else if (alignment == Alignment.topRight) { _targetRect = _adjustReactInfo( bottom: screen.height - targetOffset.dy, - left: targetOffset.dx + targetSize.width + _calculateDx(alignment, selfSize), + left: targetOffset.dx + + targetSize.width + + _calculateDx(alignment, selfSize), fixedVertical: true, ); } else if (alignment == Alignment.centerLeft) { @@ -188,7 +192,9 @@ class _AttachWidgetState extends State { } else if (alignment == Alignment.bottomRight) { _targetRect = _adjustReactInfo( top: targetOffset.dy + targetSize.height, - left: targetOffset.dx + targetSize.width + _calculateDx(alignment, selfSize), + left: targetOffset.dx + + targetSize.width + + _calculateDx(alignment, selfSize), fixedVertical: true, ); } @@ -227,7 +233,8 @@ class _AttachWidgetState extends State { } else { offset = -(selfSize.width / 2); } - } else if (alignment == Alignment.topRight || alignment == Alignment.bottomRight) { + } else if (alignment == Alignment.topRight || + alignment == Alignment.bottomRight) { if (type == SmartAttachAlignmentType.inside) { offset = -selfSize.width; } else if (type == SmartAttachAlignmentType.outside) { diff --git a/lib/src/widget/helper/smart_overlay_entry.dart b/lib/src/widget/helper/smart_overlay_entry.dart index 2d7021b..040d5cc 100644 --- a/lib/src/widget/helper/smart_overlay_entry.dart +++ b/lib/src/widget/helper/smart_overlay_entry.dart @@ -15,7 +15,7 @@ class SmartOverlayEntry extends OverlayEntry { @override void remove() { - if(!mounted) { + if (!mounted) { return; } super.remove();