Created
July 22, 2022 19:09
-
-
Save SharbelOkzan/83f3cc061baabb4136ce6e59411a83fa to your computer and use it in GitHub Desktop.
Right to Left Horizontal ListView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| import 'package:flutter/gestures.dart'; | |
| main() { | |
| runApp( | |
| MaterialApp( | |
| // ignore this line if running on mobile | |
| scrollBehavior: MyCustomScrollBehavior(), | |
| debugShowCheckedModeBanner: false, | |
| home: RtLListView(), | |
| ), | |
| ); | |
| } | |
| class RtLListView extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| appBar: AppBar( | |
| title: const Text('Right to Left Horizontal ListView builder'), | |
| ), | |
| body: Directionality( | |
| textDirection: TextDirection.rtl, | |
| child: ListView.builder( | |
| itemBuilder: (_, i) => | |
| Padding(padding: EdgeInsets.all(20), child: Text('$i')), | |
| scrollDirection: Axis.horizontal, | |
| itemCount: 50, | |
| ), | |
| ), | |
| ); | |
| } | |
| } | |
| class MyCustomScrollBehavior extends MaterialScrollBehavior { | |
| // Override behavior methods and getters like dragDevices | |
| @override | |
| Set<PointerDeviceKind> get dragDevices => { | |
| PointerDeviceKind.touch, | |
| PointerDeviceKind.mouse, | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment