Switch to Iterable.cast instance method (#150185)

Switch away from the `Iterable.castFrom` static method to the `Iterable.cast` instance method which is more readable and more consistent with other iterable usages.
This commit is contained in:
Parker Lougheed 2024-06-13 20:05:24 -05:00 committed by GitHub
parent 43e71ae64f
commit d802df49d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 7 deletions

View File

@ -1209,8 +1209,7 @@ class _NestedScrollController extends ScrollController {
}
Iterable<_NestedScrollPosition> get nestedPositions {
// TODO(vegorov): use instance method version of castFrom when it is available.
return Iterable.castFrom<ScrollPosition, _NestedScrollPosition>(positions);
return positions.cast<_NestedScrollPosition>();
}
}

View File

@ -111,11 +111,11 @@ List<TimelineEvent>? _parseEvents(Map<String, dynamic> json) {
return null;
}
final List<TimelineEvent> timelineEvents =
Iterable.castFrom<dynamic, Map<String, dynamic>>(jsonEvents)
.map<TimelineEvent>(
(Map<String, dynamic> eventJson) => TimelineEvent(eventJson))
.toList();
final List<TimelineEvent> timelineEvents = jsonEvents
.cast<Map<String, dynamic>>()
.map<TimelineEvent>(
(Map<String, dynamic> eventJson) => TimelineEvent(eventJson))
.toList();
timelineEvents.sort((TimelineEvent e1, TimelineEvent e2) {
return switch ((e1.timestampMicros, e2.timestampMicros)) {