Skip to content

Commit

Permalink
Switch to Iterable.cast instance method (#150185)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
parlough authored Jun 14, 2024
1 parent 43e71ae commit d802df4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions packages/flutter/lib/src/widgets/nested_scroll_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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>();
}
}

Expand Down
10 changes: 5 additions & 5 deletions packages/flutter_driver/lib/src/driver/timeline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit d802df4

Please sign in to comment.