Skip to content

Commit dbc82b7

Browse files
authored
💚 Fix build (#103)
1 parent ef06c5d commit dbc82b7

File tree

9 files changed

+43
-22
lines changed

9 files changed

+43
-22
lines changed

‎.github/workflows/runnable.yml

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: [ ubuntu-latest ]
18+
version: [
19+
'', # Stable
20+
'3.0.0' # Minimum
21+
]
1822
steps:
1923
- uses: actions/checkout@v3
2024
- uses: actions/setup-java@v3
@@ -23,6 +27,8 @@ jobs:
2327
java-version: '11.x'
2428
- uses: subosito/flutter-action@v2
2529
with:
30+
cache: true
31+
flutter-version: ${{ matrix.version }}
2632
channel: 'stable'
2733
- name: Log Dart/Flutter versions
2834
run: |

‎CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change log
22

3+
## 3.3.2+1
4+
5+
- Fix `Theatre` constructor and get rid of `View` for compatibilities. (#103)
6+
37
## 3.3.2
48

59
- Fix position offset do not work when `movingOnWindowChange` is false. (#100)

‎example/lib/main.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ class _MyHomePageState extends State<MyHomePage> {
139139
Center(
140140
child: Text(
141141
'$_counter',
142-
style: Theme.of(context).textTheme.headlineMedium,
142+
style: const TextStyle(
143+
fontSize: 20.0,
144+
fontWeight: FontWeight.w600,
145+
),
143146
),
144147
),
145148
Padding(

‎lib/src/core/toast.dart

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ library oktoast;
22

33
import 'dart:async';
44
import 'dart:collection';
5+
import 'dart:ui' as ui;
56

67
import 'package:flutter/material.dart' hide Overlay, OverlayEntry, OverlayState;
78
import 'package:flutter/scheduler.dart';

‎lib/src/widget/container.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ class _ToastContainerState extends State<ToastContainer>
9191

9292
final EdgeInsets windowInsets;
9393
if (movingOnWindowChange) {
94-
final currentView = View.of(context);
95-
windowInsets = EdgeInsets.only(
96-
bottom: MediaQueryData.fromView(currentView).viewInsets.bottom,
97-
);
94+
// ignore: deprecated_member_use
95+
final mediaQuery = MediaQueryData.fromWindow(ui.window);
96+
// final mediaQuery = MediaQueryData.fromView(currentView);
97+
windowInsets = EdgeInsets.only(bottom: mediaQuery.viewInsets.bottom);
9898
} else {
9999
windowInsets = EdgeInsets.zero;
100100
}

‎lib/src/widget/oktoast.dart

+1-11
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,7 @@ class _OKToastState extends State<OKToast> {
9494
child: overlay,
9595
);
9696

97-
final Typography typography = Typography.material2018();
98-
final TextTheme defaultTextTheme = typography.white;
99-
100-
final TextStyle textStyle = widget.textStyle ??
101-
defaultTextTheme.bodyMedium?.copyWith(
102-
fontSize: 15.0,
103-
fontWeight: FontWeight.normal,
104-
color: Colors.white,
105-
) ??
106-
_defaultTextStyle;
107-
97+
final TextStyle textStyle = widget.textStyle ?? _defaultTextStyle;
10898
final TextAlign textAlign = widget.textAlign ?? TextAlign.center;
10999
final EdgeInsets textPadding = widget.textPadding ??
110100
const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0);

‎lib/src/widget/overlay.dart

+2-1
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,8 @@ class OverlayState extends State<Overlay> with TickerProviderStateMixin {
579579
///
580580
/// The first [skipCount] children are considered "offstage".
581581
class Theatre extends MultiChildRenderObjectWidget {
582-
const Theatre({
582+
// ignore: prefer_const_constructors_in_immutables
583+
Theatre({
583584
super.key,
584585
this.skipCount = 0,
585586
this.clipBehavior = Clip.hardEdge,

‎pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: oktoast
22
description: A pure flutter toast library, support custom style/widget, easy achieve the same effect with native toasts.
33
repository: https://github.com/OpenFlutter/flutter_oktoast
4-
version: 3.3.2
4+
version: 3.3.2+1
55

66
environment:
77
sdk: '>=2.17.0 <3.0.0'

‎test/toast_test.dart

+20-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,26 @@ void main() {
5454

5555
await tester.tap(find.byKey(_wButtonKey));
5656
await tester.pumpAndSettle();
57-
final AnimatedPadding widget =
58-
tester.firstWidget(find.byType(AnimatedPadding)) as AnimatedPadding;
59-
final view = tester.viewOf(find.byType(AnimatedPadding));
60-
final windowInsets = EdgeInsets.only(bottom: view.viewInsets.bottom);
57+
final AnimatedPadding widget = tester.firstWidget(
58+
find.byType(AnimatedPadding),
59+
) as AnimatedPadding;
60+
final findMediaQuery = find.ancestor(
61+
of: find.byType(AnimatedPadding),
62+
matching: find.byType(MediaQuery),
63+
);
64+
final MediaQueryData mediaQueryData;
65+
if (tester.any(findMediaQuery)) {
66+
mediaQueryData = tester.widget<MediaQuery>(findMediaQuery).data;
67+
} else {
68+
// ignore: deprecated_member_use
69+
mediaQueryData = MediaQueryData.fromWindow(
70+
// ignore: deprecated_member_use
71+
TestWidgetsFlutterBinding.instance.window,
72+
);
73+
}
74+
final windowInsets = EdgeInsets.only(
75+
bottom: mediaQueryData.viewInsets.bottom,
76+
);
6177
expect(
6278
const EdgeInsets.only(top: verticalOffset) + windowInsets,
6379
widget.padding,

0 commit comments

Comments
 (0)