Created
September 5, 2021 19:14
-
-
Save csells/cccc4308fb8d16eb816fb0f0599a0a4f to your computer and use it in GitHub Desktop.
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'; | |
| void main() => runApp(const App()); | |
| class App extends StatelessWidget { | |
| static const title = 'Flutter App'; | |
| const App({Key? key}) : super(key: key); | |
| @override | |
| Widget build(BuildContext context) => const MaterialApp( | |
| title: title, | |
| home: HomePage(), | |
| ); | |
| } | |
| class HomePage extends StatefulWidget { | |
| const HomePage({Key? key}) : super(key: key); | |
| @override | |
| State<HomePage> createState() => _HomePageState(); | |
| } | |
| class _HomePageState extends State<HomePage> { | |
| int _count = 0; | |
| @override | |
| Widget build(BuildContext context) => Scaffold( | |
| appBar: AppBar(title: const Text(App.title)), | |
| body: Scrollbar( | |
| isAlwaysShown: true, | |
| child: ListView( | |
| shrinkWrap: true, | |
| children: [ | |
| for (var i = 0; i != _count; ++i) ListTile(title: Text('item $i')) | |
| ], | |
| ), | |
| ), | |
| floatingActionButton: Row( | |
| mainAxisAlignment: MainAxisAlignment.end, | |
| children: [ | |
| Padding( | |
| padding: const EdgeInsets.all(8.0), | |
| child: FloatingActionButton( | |
| onPressed: () => setState(() => _count--), | |
| child: const Text('-'), | |
| ), | |
| ), | |
| Padding( | |
| padding: const EdgeInsets.all(8.0), | |
| child: FloatingActionButton( | |
| onPressed: () => setState(() => _count++), | |
| child: const Text('+'), | |
| ), | |
| ), | |
| ], | |
| ), | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Chris, your manual scrollbar has
isAlwaysShown: true, the automatically applied one on desktop does not have this set by default, which is why you cannot see it without scrolling.You can set this using the theme, and I believe the automatically applied scrollbar will show up as you expect: