Skip to content

Commit

Permalink
bringing support for previous version of flutter sdk for flutter_mobx
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanpodila committed May 14, 2022
1 parent 68e0ebd commit 4d320bf
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 12 deletions.
4 changes: 4 additions & 0 deletions flutter_mobx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.6

- Adding support for previous versions of Flutter SDK

## 2.0.5+1

- Package upgrades
Expand Down
2 changes: 1 addition & 1 deletion flutter_mobx/lib/flutter_mobx.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ export 'package:flutter_mobx/src/stateful_observer_widget.dart';
export 'package:flutter_mobx/src/stateless_observer_widget.dart';
/// The version as per `pubspec.yaml`
const version = '2.0.5+1';
const version = '2.0.6';
14 changes: 11 additions & 3 deletions flutter_mobx/lib/src/observer_widget_mixin.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/scheduler.dart';
import 'package:flutter/widgets.dart';
import 'package:mobx/mobx.dart';

// ignore: implementation_imports
import 'package:mobx/src/core.dart' show ReactionImpl;

Expand Down Expand Up @@ -89,7 +88,8 @@ mixin ObserverElementMixin on ComponentElement {

// if there's a current frame,
// ignore: unnecessary_non_null_assertion
final schedulerPhase = SchedulerBinding.instance.schedulerPhase;
final schedulerPhase =
_ambiguate(SchedulerBinding.instance)!.schedulerPhase;
final shouldWait =
// surely, `idle` is ok
schedulerPhase != SchedulerPhase.idle &&
Expand Down Expand Up @@ -128,7 +128,7 @@ mixin ObserverElementMixin on ComponentElement {
);
}

// This "throw" is better than a "LateInitializationError"
// This "throw" is better than a "LateInitializationError"
// which confused the user. Please see #780 for details.
if (built == null) {
throw Exception(
Expand All @@ -145,3 +145,11 @@ mixin ObserverElementMixin on ComponentElement {
super.unmount();
}
}

/// 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;
2 changes: 1 addition & 1 deletion flutter_mobx/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: flutter_mobx
description:
Flutter integration for MobX. It provides a set of Observer widgets that automatically rebuild
when the tracked observables change.
version: 2.0.5+1
version: 2.0.6

homepage: https://github.com/mobxjs/mobx.dart

Expand Down
2 changes: 1 addition & 1 deletion mobx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 2.0.7+1
## 2.0.7+1 - 2.0.7+2

- Package upgrades

Expand Down
2 changes: 1 addition & 1 deletion mobx/lib/mobx.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ export 'package:mobx/src/core.dart'
export 'package:mobx/src/core/atom_extensions.dart';

/// The current version as per `pubspec.yaml`
const version = '2.0.7+1';
const version = '2.0.7+2';
6 changes: 3 additions & 3 deletions mobx/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: mobx
version: 2.0.7+1
version: 2.0.7+2
description: "MobX is a library for reactively managing the state of your applications. Use the power of observables, actions, and reactions to supercharge your Dart and Flutter apps."

homepage: https://github.com/mobxjs/mobx.dart

environment:
sdk: '>=2.13.0 <3.0.0'
sdk: '>=2.17.0 <3.0.0'

dependencies:
meta: ^1.3.0
Expand All @@ -16,5 +16,5 @@ dev_dependencies:
coverage: ^1.0.1
fake_async: ^1.2.0
lints: ^2.0.0
mocktail: ^0.2.0
mocktail: ^0.3.0
test: ^1.17.0
2 changes: 1 addition & 1 deletion mobx/test/intercept_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void main() {
..add((_) => null)
..interceptChange(WillChangeNotification());

verify(() => context.untracked(any()));
verifyNever(() => context.untracked(any()));
});
});
}
2 changes: 1 addition & 1 deletion mobx/test/listenable_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void main() {
Listeners(context)
..add((_) {})
..notifyListeners(ChangeNotification());
verify(() => context.untracked(any()));
verifyNever(() => context.untracked(any()));
});

test('asserts for null notifications', () {
Expand Down

0 comments on commit 4d320bf

Please sign in to comment.