Skip to content

Commit

Permalink
💚 Fix build (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Oct 17, 2023
1 parent ef06c5d commit dbc82b7
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 22 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/runnable.yml
Expand Up @@ -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
Expand All @@ -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: |
Expand Down
4 changes: 4 additions & 0 deletions 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)
Expand Down
5 changes: 4 additions & 1 deletion example/lib/main.dart
Expand Up @@ -139,7 +139,10 @@ class _MyHomePageState extends State<MyHomePage> {
Center(
child: Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
style: const TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w600,
),
),
),
Padding(
Expand Down
1 change: 1 addition & 0 deletions lib/src/core/toast.dart
Expand Up @@ -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';
Expand Down
8 changes: 4 additions & 4 deletions lib/src/widget/container.dart
Expand Up @@ -91,10 +91,10 @@ class _ToastContainerState extends State<ToastContainer>

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;
}
Expand Down
12 changes: 1 addition & 11 deletions lib/src/widget/oktoast.dart
Expand Up @@ -94,17 +94,7 @@ class _OKToastState extends State<OKToast> {
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);
Expand Down
3 changes: 2 additions & 1 deletion lib/src/widget/overlay.dart
Expand Up @@ -579,7 +579,8 @@ class OverlayState extends State<Overlay> 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,
Expand Down
2 changes: 1 addition & 1 deletion 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'
Expand Down
24 changes: 20 additions & 4 deletions test/toast_test.dart
Expand Up @@ -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<MediaQuery>(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,
Expand Down

0 comments on commit dbc82b7

Please sign in to comment.