Last active
May 3, 2022 13:16
-
-
Save tecteun/a36a652c4ee98e1f5a63e85a16aff5fe to your computer and use it in GitHub Desktop.
big scroll test
This file contains 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 'dart:math'; | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp( | |
MyApp( | |
items: List<String>.generate(130, (i) => 'Item $i'), | |
), | |
); | |
} | |
class MyApp extends StatelessWidget { | |
final List<String> items; | |
final _scrollController = ScrollController(); | |
MyApp({Key? key, required this.items}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
const title = 'Long List'; | |
return MaterialApp( | |
title: title, | |
home: Scaffold( | |
appBar: AppBar( | |
title: const Text(title), | |
), | |
body: ListView.builder( | |
clipBehavior: Clip.none, | |
itemCount: items.length, | |
padding: const EdgeInsets.all(0), | |
itemBuilder: (context, index) { | |
return ListTile( | |
minVerticalPadding: 0, | |
contentPadding: const EdgeInsets.all(0), | |
title: Container( | |
color: | |
Colors.primaries[Random().nextInt(Colors.primaries.length)], | |
padding: EdgeInsets.zero, | |
height: 100.0, | |
child: ListView.builder( | |
scrollDirection: Axis.horizontal, | |
controller: _scrollController, | |
itemCount: 120, | |
padding: const EdgeInsets.all(0), | |
itemBuilder: (context, index) { | |
return Container( | |
padding: EdgeInsets.zero, | |
width: 50 + Random().nextDouble() * 100.0, | |
child: Card( | |
color: Colors.primaries[ | |
Random().nextInt(Colors.primaries.length)], | |
child: Text(items[index]), | |
margin: const EdgeInsets.all(0), | |
shape: const Border( | |
right: BorderSide(color: Colors.white24, width: 5)), | |
), | |
); | |
}, | |
), | |
), | |
); | |
}, | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment