Skip to content

Commit e9369be

Browse files
lrhnmatanlurey
authored andcommitted
Update implementations of the cast and the deprecated retype methods. (#70)
* Update ObservableList * Update observable_map.dart * Update pubspec.yaml
1 parent baa813d commit e9369be

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

lib/src/observable_list.dart

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ class ObservableList<E> extends ListBase<E> with Observable {
6060

6161
ObservableList._spy(List<E> other) : _list = other;
6262

63-
/// Returns a view of this list as a list of [T] instances, if necessary.
64-
///
65-
/// If this list is already a `ObservableList<T>`, it is returned unchanged.
63+
/// Returns a view of this list as a list of [T] instances.
6664
///
6765
/// If this list contains only instances of [T], all read operations
6866
/// will work correctly. If any operation tries to access an element
@@ -73,12 +71,7 @@ class ObservableList<E> extends ListBase<E> with Observable {
7371
/// and they must be instances of [E] as well to be accepted by
7472
/// this list as well.
7573
@override
76-
ObservableList<T> cast<T>() {
77-
if (this is ObservableList<T>) {
78-
return this as ObservableList<T>;
79-
}
80-
return retype<T>();
81-
}
74+
ObservableList<T> cast<T>() => ObservableList.castFrom<E, T>(this);
8275

8376
/// Returns a view of this list as a list of [T] instances.
8477
///
@@ -91,7 +84,8 @@ class ObservableList<E> extends ListBase<E> with Observable {
9184
/// and they must be instances of [E] as well to be accepted by
9285
/// this list as well.
9386
@override
94-
ObservableList<T> retype<T>() => ObservableList.castFrom<E, T>(this);
87+
// ignore: override_on_non_overriding_method
88+
ObservableList<T> retype<T>() => cast<T>();
9589

9690
/// The stream of summarized list changes, delivered asynchronously.
9791
///

lib/src/observable_map.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,11 @@ class ObservableMap<K, V> extends Observable implements Map<K, V> {
174174

175175
@override
176176
ObservableMap<K2, V2> cast<K2, V2>() {
177-
if (this is ObservableMap<K2, V2>) {
178-
return this as ObservableMap<K2, V2>;
179-
}
180177
return ObservableMap.castFrom<K, V, K2, V2>(this);
181178
}
182179

183180
@override
181+
// ignore: override_on_non_overriding_method
184182
ObservableMap<K2, V2> retype<K2, V2>() {
185183
return ObservableMap.castFrom<K, V, K2, V2>(this);
186184
}

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: observable
2-
version: 0.22.1+2
2+
version: 0.22.1+3
33
author: Dart Team <[email protected]>
44
description: Support for marking objects as observable
55
homepage: https://github.com/dart-lang/observable
66
environment:
7-
sdk: '>=2.0.0-dev.23.0 <2.0.0'
7+
sdk: '>=2.0.0-dev.55.0 <2.0.0'
88
dependencies:
99
collection: '^1.11.0'
1010
dart_internal: '^0.1.1'

0 commit comments

Comments
 (0)