-
Notifications
You must be signed in to change notification settings - Fork 29.4k
Closed
Labels
c: regressionIt was better in the past than it is nowIt was better in the past than it is nowf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.f: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 1.20Found to occur in 1.20Found to occur in 1.20frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
This is a pagination case. If a user in overscroll (maxExtended - position < 0) while new data coming into the list and didn't unpin it's finger, CustomScrollView with BouncingScrollPhysics will kick you into the end of the list.
Flutter channel: stable.
Flutter version: v1.20.0
Example:
import 'package:flutter/material.dart';
void main() {
runApp(MyHomePage());
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final list = [0, 1, 2];
var loading = false;
final colors = [
Colors.cyan,
Colors.indigo,
Colors.pink,
Colors.red,
Colors.blue,
Colors.yellowAccent
];
final sc = ScrollController();
@override
void initState() {
super.initState();
sc.addListener(_onScroll);
}
Future<void> loadMore() async {
if(list.length < 6){
await Future.delayed(const Duration(seconds: 3));
list.addAll([3, 4, 5]);
}
}
void _onScroll() {
final maxExtended = sc.position.maxScrollExtent;
final position = sc.position.pixels;
final dif = maxExtended - position;
if (dif == 0.0 && !loading) {
loading = true;
loadMore().then((value) {
setState(() {});
loading = false;
});
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: CustomScrollView(
controller: sc,
physics: BouncingScrollPhysics(),
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(_, index) => SizedBox(
width: double.infinity,
child: Container(
height: 400,
color: colors[index],
child: Text(
index.toString(),
style: TextStyle(
fontSize: 30,
),
),
)),
childCount: list.length))
],
),
);
}
@override
void dispose() {
sc.dispose();
super.dispose();
}
}arteminthesky, dsrenesanse, rxynrg, cupofme, Stalder and 16 moredsrenesanse and newbalancem5
Metadata
Metadata
Assignees
Labels
c: regressionIt was better in the past than it is nowIt was better in the past than it is nowf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.f: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 1.20Found to occur in 1.20Found to occur in 1.20frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
