Commit 8916b101 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Avoid potential ConcurrentModificationError (#8534)

Also make locals final where possible.

Followup to 52715467.
parent 0421b4f3
...@@ -70,7 +70,7 @@ class ScrollController { ...@@ -70,7 +70,7 @@ class ScrollController {
@required Curve curve, @required Curve curve,
}) { }) {
assert(_positions.isNotEmpty, 'ScrollController not attached to any scroll views.'); assert(_positions.isNotEmpty, 'ScrollController not attached to any scroll views.');
List<Future<Null>> animations = new List<Future<Null>>(_positions.length); final List<Future<Null>> animations = new List<Future<Null>>(_positions.length);
for (int i = 0; i < _positions.length; i++) for (int i = 0; i < _positions.length; i++)
animations[i] = _positions[i].animateTo(offset, duration: duration, curve: curve); animations[i] = _positions[i].animateTo(offset, duration: duration, curve: curve);
return Future.wait<Null>(animations).then((List<Null> _) => null); return Future.wait<Null>(animations).then((List<Null> _) => null);
...@@ -90,8 +90,8 @@ class ScrollController { ...@@ -90,8 +90,8 @@ class ScrollController {
/// value was out of range. /// value was out of range.
void jumpTo(double value) { void jumpTo(double value) {
assert(_positions.isNotEmpty, 'ScrollController not attached to any scroll views.'); assert(_positions.isNotEmpty, 'ScrollController not attached to any scroll views.');
for (ScrollPosition p in _positions) for (ScrollPosition position in new List<ScrollPosition>.from(_positions))
p.jumpTo(value); position.jumpTo(value);
} }
/// Register the given position with this controller. /// Register the given position with this controller.
......
...@@ -72,13 +72,13 @@ abstract class ScrollView extends StatelessWidget { ...@@ -72,13 +72,13 @@ abstract class ScrollView extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
List<Widget> slivers = buildSlivers(context); final List<Widget> slivers = buildSlivers(context);
AxisDirection axisDirection = getDirection(context); final AxisDirection axisDirection = getDirection(context);
ScrollController scrollController = primary final ScrollController scrollController = primary
? PrimaryScrollController.of(context) ? PrimaryScrollController.of(context)
: controller; : controller;
Scrollable scrollable = new Scrollable( final Scrollable scrollable = new Scrollable(
axisDirection: axisDirection, axisDirection: axisDirection,
controller: scrollController, controller: scrollController,
physics: physics, physics: physics,
......
...@@ -96,10 +96,10 @@ class SingleChildScrollView extends StatelessWidget { ...@@ -96,10 +96,10 @@ class SingleChildScrollView extends StatelessWidget {
Widget contents = child; Widget contents = child;
if (padding != null) if (padding != null)
contents = new Padding(padding: padding, child: contents); contents = new Padding(padding: padding, child: contents);
ScrollController scrollController = primary final ScrollController scrollController = primary
? PrimaryScrollController.of(context) ? PrimaryScrollController.of(context)
: controller; : controller;
Scrollable scrollable = new Scrollable( final Scrollable scrollable = new Scrollable(
axisDirection: axisDirection, axisDirection: axisDirection,
controller: scrollController, controller: scrollController,
physics: physics, physics: physics,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment