Created
December 5, 2023 22:49
-
-
Save Piinks/35ff7fdfaad3a6d8f3bcc3e084abf59f to your computer and use it in GitHub Desktop.
Test scroll
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
// Run this sample as a: | |
// - Web app on Windows | |
// - Desktop app on Windows | |
// - Web app on Linux | |
// - Desktop app on Linux | |
// For each: | |
// - scroll with a physical mouse wheel | |
// (magic mouse from Apple does not count! It is treated as a trackpad) | |
// - scroll with trackpad | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const MyWidget()); | |
} | |
class MyWidget extends StatefulWidget { | |
const MyWidget({super.key}); | |
@override | |
State<StatefulWidget> createState() => MyWidgetState(); | |
} | |
class MyWidgetState extends State<StatefulWidget> { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
body: Builder( | |
builder: (context) { | |
return ScrollConfiguration( | |
// This is what is being tested. If we are not properly catching trackpad input, | |
// scrolling would get stuck. | |
behavior: ScrollConfiguration.of(context).copyWith(animatePointerScroll: true), | |
child: ListView.builder( | |
itemBuilder: (context, index) { | |
return Container( | |
height: (index * 10) + 50, | |
color: Colors.primaries[index % Colors.primaries.length], | |
child: Center( | |
child: Text( | |
index.toString(), | |
style: const TextStyle(fontSize: 40), | |
), | |
), | |
); | |
}, | |
itemCount: 20, | |
), | |
); | |
} | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment