From b3128d3ffde817ac304da25b94dde2b4d0ee304f Mon Sep 17 00:00:00 2001 From: Aditya Chavda <98031138+aditya-css@users.noreply.github.com> Date: Mon, 29 Apr 2024 12:19:32 +0530 Subject: [PATCH] fix: :ambulance: Dart 2.12 Version Compatibility (#427) - Removed use of `Overlay.maybeOf` from layout_overlays.dart. - Downgraded flutter_lints version in pubspec.yaml. - Wrapped `WidgetsBinding.instance` with `ambiguate` in tooltip_widget.dart. - Replaced `titleLarge` and `titleSmall` text theme with `headline6` and `subtitle2` in tooltip_widget.dart. - Version bump 2.1.1. --- CHANGELOG.md | 3 +++ lib/src/layout_overlays.dart | 10 +++++----- lib/src/tooltip_widget.dart | 22 ++++++++++++++++------ pubspec.yaml | 4 ++-- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31df2c0a..28c0013c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [2.1.1] +- Fixed [#425](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/425) - Unhandled breaking change in v2.1.0 + ## [2.1.0] - Feature [#420](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/pull/420) - Dart SDK Upgrade - Fixed [#419](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/pull/419) - Suppress Text Scale Factor Warning diff --git a/lib/src/layout_overlays.dart b/lib/src/layout_overlays.dart index c3549c3f..f4f4b302 100644 --- a/lib/src/layout_overlays.dart +++ b/lib/src/layout_overlays.dart @@ -184,11 +184,11 @@ class _OverlayBuilderState extends State { void addToOverlay(OverlayEntry overlayEntry) async { if (mounted) { final showCaseContext = ShowCaseWidget.of(context).context; - if (Overlay.maybeOf(showCaseContext) != null) { - Overlay.of(showCaseContext).insert(overlayEntry); - } else if (Overlay.maybeOf(context) != null) { - Overlay.of(context).insert(overlayEntry); - } + // TODO: switch to Overlay.maybeOf once we support dart 2.19 minimum. + final showCaseOverlay = + showCaseContext.findAncestorStateOfType(); + final overlay = context.findAncestorStateOfType(); + (showCaseOverlay ?? overlay)?.insert(overlayEntry); } } diff --git a/lib/src/tooltip_widget.dart b/lib/src/tooltip_widget.dart index babc474b..efbd6ad7 100644 --- a/lib/src/tooltip_widget.dart +++ b/lib/src/tooltip_widget.dart @@ -131,7 +131,9 @@ class _ToolTipWidgetState extends State // ignore: deprecated_member_use final EdgeInsets viewInsets = EdgeInsets.fromWindowPadding( // ignore: deprecated_member_use - ambiguate(WidgetsBinding.instance)?.window.viewInsets ?? ViewPadding.zero, + ambiguate(WidgetsBinding.instance)?.window.viewInsets ?? + // ignore: deprecated_member_use + WindowPadding.zero, // ignore: deprecated_member_use ambiguate(WidgetsBinding.instance)?.window.devicePixelRatio ?? 1, ); @@ -149,12 +151,16 @@ class _ToolTipWidgetState extends State final titleStyle = widget.titleTextStyle ?? Theme.of(context) .textTheme - .titleLarge! + // TODO: replace once support for 3.1.0 and above is provided. + // ignore: deprecated_member_use + .headline6! .merge(TextStyle(color: widget.textColor)); final descriptionStyle = widget.descTextStyle ?? Theme.of(context) .textTheme - .titleSmall! + // TODO: replace once support for 3.1.0 and above is provided. + // ignore: deprecated_member_use + .subtitle2! .merge(TextStyle(color: widget.textColor)); final titleLength = widget.title == null ? 0 @@ -257,7 +263,7 @@ class _ToolTipWidgetState extends State @override void initState() { super.initState(); - WidgetsBinding.instance.addPostFrameCallback((_) { + ambiguate(WidgetsBinding.instance)?.addPostFrameCallback((_) { if (widget.container != null && _customContainerKey.currentContext != null && _customContainerKey.currentContext?.size != null) { @@ -452,7 +458,9 @@ class _ToolTipWidgetState extends State style: widget.titleTextStyle ?? Theme.of(context) .textTheme - .titleLarge! + // TODO: replace once support for 3.1.0 and above is provided. + // ignore: deprecated_member_use + .headline6! .merge( TextStyle( color: widget.textColor, @@ -471,7 +479,9 @@ class _ToolTipWidgetState extends State style: widget.descTextStyle ?? Theme.of(context) .textTheme - .titleSmall! + // TODO: replace once support for 3.1.0 and above is provided. + // ignore: deprecated_member_use + .subtitle2! .merge( TextStyle( color: widget.textColor, diff --git a/pubspec.yaml b/pubspec.yaml index 1bd6f44a..b9bd7f07 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: showcaseview description: A Flutter package to Showcase/Highlight widgets step by step. -version: 2.1.0 +version: 2.1.1 homepage: https://github.com/simformsolutions/flutter_showcaseview issue_tracker: https://github.com/simformsolutions/flutter_showcaseview/issues @@ -14,6 +14,6 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.1 + flutter_lints: 1.0.4 flutter: