-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
c: regressionIt was better in the past than it is nowIt was better in the past than it is nowf: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.
Description
It should be safe for a snapOffsetCallback() to just return its scrollOffset parameter. This can fail:
Waiting for application to start...
Restart performed in 4331 ms.
I/flutter : ══╡ EXCEPTION CAUGHT BY GESTURE LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter : The following assertion was thrown while routing a pointer event:
I/flutter : 'package:flutter/src/physics/friction_simulation.dart': Failed assertion: line 40 pos 12:
I/flutter : 'startVelocity.abs() >= endVelocity.abs()' is not true.
I/flutter : When the exception was thrown, this was the stack:
I/flutter : #2 FrictionSimulation.FrictionSimulation.through (package:flutter/src/physics/friction_simulation.dart:40:12)
I/flutter : #3 _createSnapScrollSimulation (package:flutter/src/widgets/scroll_behavior.dart:16:14)
I/flutter : #4 OverscrollBehavior.createSnapScrollSimulation (package:flutter/src/widgets/scroll_behavior.dart:257:12)
I/flutter : #5 ScrollableState._createSnapSimulation (package:flutter/src/widgets/scrollable.dart:622:50)
I/flutter : #6 ScrollableState._startToEndAnimation (package:flutter/src/widgets/scrollable.dart:587:19)
I/flutter : #7 ScrollableState.fling (package:flutter/src/widgets/scrollable.dart:564:14)
class AnimationDemo extends StatefulWidget {
static const String routeName = '/animation';
@override
AnimationDemoState createState() => new AnimationDemoState();
}
class AnimationDemoState extends State<AnimationDemo> {
final GlobalKey<ScrollableState> _scrollableKey = new GlobalKey<ScrollableState>();
final List<Color> colors = [
Colors.red[100],
Colors.red[200],
Colors.red[300],
Colors.red[400],
Colors.red[500],
Colors.red[600],
];
Widget _createPage(int i) {
final double pageWidth = MediaQuery.of(context).size.width;
return new Container(
decoration: new BoxDecoration(
backgroundColor: colors[i]
),
child: new SizedBox(
width: pageWidth,
child: new Center(
child: new Text('Page $i'),
),
),
);
}
double _snapScrollOffset(double flingScrollOffset, Size containerSize) {
return flingScrollOffset;
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Travel stream'),
),
body: new ScrollableViewport(
scrollableKey: _scrollableKey,
scrollDirection: Axis.horizontal,
snapOffsetCallback: _snapScrollOffset,
child: new Row(
children: [0, 1, 2, 3, 4, 5].map(_createPage).toList(),
),
),
);
}
}
Metadata
Metadata
Assignees
Labels
c: regressionIt was better in the past than it is nowIt was better in the past than it is nowf: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.