Skip to content

Commit

Permalink
compat with flutter2. fix #80
Browse files Browse the repository at this point in the history
  • Loading branch information
boyan01 committed Jun 3, 2022
1 parent a0c470d commit a739e1e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 2.0.1

* compat with version before flutter3.

## 2.0.0

* update dart sdk min version to `2.14.0`.
Expand Down
11 changes: 10 additions & 1 deletion lib/src/overlay_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ class _OverlaySupportEntryImpl implements OverlaySupportEntry {
} else {
//we need show animation before remove this entry
//so need ensure entry has been inserted into screen
WidgetsBinding.instance.scheduleFrameCallback((_) => animateRemove());
_ambiguate(WidgetsBinding.instance)
?.scheduleFrameCallback((_) => animateRemove());
}
}

Expand All @@ -118,6 +119,14 @@ class _OverlaySupportEntryImpl implements OverlaySupportEntry {
}
}

/// This allows a value of type T or T?
/// to be treated as a value of type T?.
///
/// We use this so that APIs that have become
/// non-nullable can still be used with `!` and `?`
/// to support older versions of the API as well.
T? _ambiguate<T>(T? value) => value;

class _OverlaySupportEntryEmpty implements OverlaySupportEntry {
@override
void dismiss({bool animate = true}) {}
Expand Down
9 changes: 3 additions & 6 deletions lib/src/overlay_keys.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/widgets.dart';
import 'package:overlay_support/overlay_support.dart';

/// A widget that builds its child.
/// The same as [KeyedSubtree]
Expand Down Expand Up @@ -32,9 +33,7 @@ class ModalKey<T> extends ValueKey<T> {

@override
bool operator ==(other) {
if (other.runtimeType != runtimeType) return false;
final typedOther = other as ModalKey<T>;
return value == typedOther.value;
return other is ModalKey<T> && value == other.value;
}

@override
Expand Down Expand Up @@ -64,9 +63,7 @@ class TransientKey<T> extends ValueKey<T> {

@override
bool operator ==(other) {
if (other.runtimeType != runtimeType) return false;
final typedOther = other as TransientKey<T>;
return value == typedOther.value;
return other is TransientKey<T> && value == other.value;
}

@override
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: overlay_support
description: provider support for overlay, easy to build toast and internal notification
version: 2.0.0
version: 2.0.1
homepage: https://github.com/boyan01/overlay_support

environment:
Expand Down

0 comments on commit a739e1e

Please sign in to comment.