Avoid potential ConcurrentModificationError (#8534)
Also make locals final where possible.
Followup to 5271546794.
This commit is contained in:
@@ -70,7 +70,7 @@ class ScrollController {
|
||||
@required Curve curve,
|
||||
}) {
|
||||
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++)
|
||||
animations[i] = _positions[i].animateTo(offset, duration: duration, curve: curve);
|
||||
return Future.wait<Null>(animations).then((List<Null> _) => null);
|
||||
@@ -90,8 +90,8 @@ class ScrollController {
|
||||
/// value was out of range.
|
||||
void jumpTo(double value) {
|
||||
assert(_positions.isNotEmpty, 'ScrollController not attached to any scroll views.');
|
||||
for (ScrollPosition p in _positions)
|
||||
p.jumpTo(value);
|
||||
for (ScrollPosition position in new List<ScrollPosition>.from(_positions))
|
||||
position.jumpTo(value);
|
||||
}
|
||||
|
||||
/// Register the given position with this controller.
|
||||
|
||||
@@ -72,13 +72,13 @@ abstract class ScrollView extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> slivers = buildSlivers(context);
|
||||
AxisDirection axisDirection = getDirection(context);
|
||||
final List<Widget> slivers = buildSlivers(context);
|
||||
final AxisDirection axisDirection = getDirection(context);
|
||||
|
||||
ScrollController scrollController = primary
|
||||
final ScrollController scrollController = primary
|
||||
? PrimaryScrollController.of(context)
|
||||
: controller;
|
||||
Scrollable scrollable = new Scrollable(
|
||||
final Scrollable scrollable = new Scrollable(
|
||||
axisDirection: axisDirection,
|
||||
controller: scrollController,
|
||||
physics: physics,
|
||||
|
||||
@@ -96,10 +96,10 @@ class SingleChildScrollView extends StatelessWidget {
|
||||
Widget contents = child;
|
||||
if (padding != null)
|
||||
contents = new Padding(padding: padding, child: contents);
|
||||
ScrollController scrollController = primary
|
||||
final ScrollController scrollController = primary
|
||||
? PrimaryScrollController.of(context)
|
||||
: controller;
|
||||
Scrollable scrollable = new Scrollable(
|
||||
final Scrollable scrollable = new Scrollable(
|
||||
axisDirection: axisDirection,
|
||||
controller: scrollController,
|
||||
physics: physics,
|
||||
|
||||
Reference in New Issue
Block a user