From dbc82b7b6a4c787354956aebd7bf0b9ebe409397 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Tue, 17 Oct 2023 18:18:25 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=9A=20Fix=20build=20(#103)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/runnable.yml | 6 ++++++ CHANGELOG.md | 4 ++++ example/lib/main.dart | 5 ++++- lib/src/core/toast.dart | 1 + lib/src/widget/container.dart | 8 ++++---- lib/src/widget/oktoast.dart | 12 +----------- lib/src/widget/overlay.dart | 3 ++- pubspec.yaml | 2 +- test/toast_test.dart | 24 ++++++++++++++++++++---- 9 files changed, 43 insertions(+), 22 deletions(-) diff --git a/.github/workflows/runnable.yml b/.github/workflows/runnable.yml index 902ea32..8c6a9b8 100644 --- a/.github/workflows/runnable.yml +++ b/.github/workflows/runnable.yml @@ -15,6 +15,10 @@ jobs: strategy: matrix: os: [ ubuntu-latest ] + version: [ + '', # Stable + '3.0.0' # Minimum + ] steps: - uses: actions/checkout@v3 - uses: actions/setup-java@v3 @@ -23,6 +27,8 @@ jobs: java-version: '11.x' - uses: subosito/flutter-action@v2 with: + cache: true + flutter-version: ${{ matrix.version }} channel: 'stable' - name: Log Dart/Flutter versions run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 33abf38..eb18783 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change log +## 3.3.2+1 + +- Fix `Theatre` constructor and get rid of `View` for compatibilities. (#103) + ## 3.3.2 - Fix position offset do not work when `movingOnWindowChange` is false. (#100) diff --git a/example/lib/main.dart b/example/lib/main.dart index e1fd5b0..e3bc11f 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -139,7 +139,10 @@ class _MyHomePageState extends State { Center( child: Text( '$_counter', - style: Theme.of(context).textTheme.headlineMedium, + style: const TextStyle( + fontSize: 20.0, + fontWeight: FontWeight.w600, + ), ), ), Padding( diff --git a/lib/src/core/toast.dart b/lib/src/core/toast.dart index 480a1e0..30a91b6 100644 --- a/lib/src/core/toast.dart +++ b/lib/src/core/toast.dart @@ -2,6 +2,7 @@ library oktoast; import 'dart:async'; import 'dart:collection'; +import 'dart:ui' as ui; import 'package:flutter/material.dart' hide Overlay, OverlayEntry, OverlayState; import 'package:flutter/scheduler.dart'; diff --git a/lib/src/widget/container.dart b/lib/src/widget/container.dart index d6d5ac7..ad13ec2 100644 --- a/lib/src/widget/container.dart +++ b/lib/src/widget/container.dart @@ -91,10 +91,10 @@ class _ToastContainerState extends State final EdgeInsets windowInsets; if (movingOnWindowChange) { - final currentView = View.of(context); - windowInsets = EdgeInsets.only( - bottom: MediaQueryData.fromView(currentView).viewInsets.bottom, - ); + // ignore: deprecated_member_use + final mediaQuery = MediaQueryData.fromWindow(ui.window); + // final mediaQuery = MediaQueryData.fromView(currentView); + windowInsets = EdgeInsets.only(bottom: mediaQuery.viewInsets.bottom); } else { windowInsets = EdgeInsets.zero; } diff --git a/lib/src/widget/oktoast.dart b/lib/src/widget/oktoast.dart index b6cff7a..87bd02b 100644 --- a/lib/src/widget/oktoast.dart +++ b/lib/src/widget/oktoast.dart @@ -94,17 +94,7 @@ class _OKToastState extends State { child: overlay, ); - final Typography typography = Typography.material2018(); - final TextTheme defaultTextTheme = typography.white; - - final TextStyle textStyle = widget.textStyle ?? - defaultTextTheme.bodyMedium?.copyWith( - fontSize: 15.0, - fontWeight: FontWeight.normal, - color: Colors.white, - ) ?? - _defaultTextStyle; - + final TextStyle textStyle = widget.textStyle ?? _defaultTextStyle; final TextAlign textAlign = widget.textAlign ?? TextAlign.center; final EdgeInsets textPadding = widget.textPadding ?? const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0); diff --git a/lib/src/widget/overlay.dart b/lib/src/widget/overlay.dart index 16cad41..30e8e3e 100644 --- a/lib/src/widget/overlay.dart +++ b/lib/src/widget/overlay.dart @@ -579,7 +579,8 @@ class OverlayState extends State with TickerProviderStateMixin { /// /// The first [skipCount] children are considered "offstage". class Theatre extends MultiChildRenderObjectWidget { - const Theatre({ + // ignore: prefer_const_constructors_in_immutables + Theatre({ super.key, this.skipCount = 0, this.clipBehavior = Clip.hardEdge, diff --git a/pubspec.yaml b/pubspec.yaml index d8d4dfc..9ca3395 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: oktoast description: A pure flutter toast library, support custom style/widget, easy achieve the same effect with native toasts. repository: https://github.com/OpenFlutter/flutter_oktoast -version: 3.3.2 +version: 3.3.2+1 environment: sdk: '>=2.17.0 <3.0.0' diff --git a/test/toast_test.dart b/test/toast_test.dart index ff59c23..9fe863c 100644 --- a/test/toast_test.dart +++ b/test/toast_test.dart @@ -54,10 +54,26 @@ void main() { await tester.tap(find.byKey(_wButtonKey)); await tester.pumpAndSettle(); - final AnimatedPadding widget = - tester.firstWidget(find.byType(AnimatedPadding)) as AnimatedPadding; - final view = tester.viewOf(find.byType(AnimatedPadding)); - final windowInsets = EdgeInsets.only(bottom: view.viewInsets.bottom); + final AnimatedPadding widget = tester.firstWidget( + find.byType(AnimatedPadding), + ) as AnimatedPadding; + final findMediaQuery = find.ancestor( + of: find.byType(AnimatedPadding), + matching: find.byType(MediaQuery), + ); + final MediaQueryData mediaQueryData; + if (tester.any(findMediaQuery)) { + mediaQueryData = tester.widget(findMediaQuery).data; + } else { + // ignore: deprecated_member_use + mediaQueryData = MediaQueryData.fromWindow( + // ignore: deprecated_member_use + TestWidgetsFlutterBinding.instance.window, + ); + } + final windowInsets = EdgeInsets.only( + bottom: mediaQueryData.viewInsets.bottom, + ); expect( const EdgeInsets.only(top: verticalOffset) + windowInsets, widget.padding,