Repository navigation
Stretching overscroll with RTl Stretches in incorrect direction #113185
Copy link
Copy link
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4Found to occur in 3.4frameworkflutter/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 onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Activity
- addedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on Oct 10, 2022 Triage report
I can reproduce this issue. I have removed the deprecated use of
androidOverscrollIndicatorfromThemeDataand instead useduseMaterial3, but the issue still persists.Adding a custom
ScrollBehaviorwith theaxisDirectionset toAxisDirection.rightfixes the issue.Code Sample updated for the fix
import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData.dark().copyWith(), debugShowCheckedModeBanner: false, home: const Directionality( textDirection: TextDirection.rtl, // textDirection: TextDirection.ltr, child: Scaffold( body: SafeArea( child: Center( child: MyWidget(), ), ), ), ), ); } } class MyWidget extends StatelessWidget { const MyWidget({super.key}); @override Widget build(BuildContext context) { return SizedBox( height: 100, child: ScrollConfiguration( behavior: MyBehaviour(), child: ListView.builder( itemBuilder: (context, index) => Container( width: 50, height: 100, color: Colors.amber[(index % 9 + 1) * 100], child: Center(child: Text('Entry $index')), ), itemCount: 10, padding: const EdgeInsets.all(8), scrollDirection: Axis.horizontal, ), ), ); } } class MyBehaviour extends ScrollBehavior { @override Widget buildOverscrollIndicator( BuildContext context, Widget child, ScrollableDetails details) { return StretchingOverscrollIndicator( axisDirection: AxisDirection.right, child: child, ); } }
- addedframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesf: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onfound in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4Found to occur in 3.4and removedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on Oct 10, 2022 @exaby73 after further investigation now i know where is the issue here
AlignmentDirectional is used but it is reversed with AxisDirection.leftCode sample
AlignmentDirectional _getAlignmentForAxisDirection(double overscroll) { // Accounts for reversed scrollables by checking the AxisDirection switch (widget.axisDirection) { case AxisDirection.up: return overscroll > 0 ? AlignmentDirectional.topCenter : AlignmentDirectional.bottomCenter; case AxisDirection.right: return overscroll > 0 ? AlignmentDirectional.centerEnd : AlignmentDirectional.centerStart; case AxisDirection.down: return overscroll > 0 ? AlignmentDirectional.bottomCenter : AlignmentDirectional.topCenter; case AxisDirection.left: return overscroll > 0 ? AlignmentDirectional.centerStart : AlignmentDirectional.centerEnd; } }
Fix
AlignmentDirectional _getAlignmentForAxisDirection(double overscroll) { // Accounts for reversed scrollables by checking the AxisDirection switch (widget.axisDirection) { case AxisDirection.up: return overscroll > 0 ? AlignmentDirectional.topCenter : AlignmentDirectional.bottomCenter; case AxisDirection.left: case AxisDirection.right: return overscroll > 0 ? AlignmentDirectional.centerEnd : AlignmentDirectional.centerStart; case AxisDirection.down: return overscroll > 0 ? AlignmentDirectional.bottomCenter : AlignmentDirectional.topCenter; } }
fix in #113214
- addedP2Important issues not at the top of the work listImportant issues not at the top of the work list
on Oct 20, 2022 As stated above, this issue was fixed! 🎉
- addedr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
on Dec 23, 2022 This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Mar 4, 2023
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4Found to occur in 3.4frameworkflutter/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 onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Steps to Reproduce
Expected results: Scroll stretch to be same as native android and stretch effect stretches towards the drag position
Actual results: stretch effect stretches towards opposite of the drag position
Code sample
here two different videos when rtl support is added and another when ltr support is used
RTL 👇
Android.Emulator.-.Pixel_4_API_31_5554.2022-10-09.14-56-31.1.mp4
LTR 👇
Android.Emulator.-.Pixel_4_API_31_5554.2022-10-09.14-56-55.1.mp4