diff --git a/examples/flutter_gallery/lib/demo/colors_demo.dart b/examples/flutter_gallery/lib/demo/colors_demo.dart index 9ac109e17e..4b201710e7 100644 --- a/examples/flutter_gallery/lib/demo/colors_demo.dart +++ b/examples/flutter_gallery/lib/demo/colors_demo.dart @@ -115,9 +115,11 @@ class PaletteTabView extends StatelessWidget { }).toList()); } - return ListView( - itemExtent: kColorItemHeight, - children: colorItems, + return Scrollbar( + child: ListView( + itemExtent: kColorItemHeight, + children: colorItems, + ) ); } } diff --git a/examples/flutter_gallery/lib/demo/cupertino/cupertino_alert_demo.dart b/examples/flutter_gallery/lib/demo/cupertino/cupertino_alert_demo.dart index 17fc4cc6d8..ce0d749fd6 100644 --- a/examples/flutter_gallery/lib/demo/cupertino/cupertino_alert_demo.dart +++ b/examples/flutter_gallery/lib/demo/cupertino/cupertino_alert_demo.dart @@ -54,136 +54,138 @@ class _CupertinoAlertDemoState extends State { child: Builder( builder: (BuildContext context) { final List stackChildren = [ - ListView( - // Add more padding to the normal safe area. - padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0) - + MediaQuery.of(context).padding, - children: [ - CupertinoButton.filled( - child: const Text('Alert'), - onPressed: () { - showDemoDialog( - context: context, - child: CupertinoAlertDialog( - title: const Text('Discard draft?'), - actions: [ - CupertinoDialogAction( - child: const Text('Discard'), - isDestructiveAction: true, - onPressed: () { - Navigator.pop(context, 'Discard'); - }, - ), - CupertinoDialogAction( + CupertinoScrollbar( + child: ListView( + // Add more padding to the normal safe area. + padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0) + + MediaQuery.of(context).padding, + children: [ + CupertinoButton.filled( + child: const Text('Alert'), + onPressed: () { + showDemoDialog( + context: context, + child: CupertinoAlertDialog( + title: const Text('Discard draft?'), + actions: [ + CupertinoDialogAction( + child: const Text('Discard'), + isDestructiveAction: true, + onPressed: () { + Navigator.pop(context, 'Discard'); + }, + ), + CupertinoDialogAction( + child: const Text('Cancel'), + isDefaultAction: true, + onPressed: () { + Navigator.pop(context, 'Cancel'); + }, + ), + ], + ), + ); + }, + ), + const Padding(padding: EdgeInsets.all(8.0)), + CupertinoButton.filled( + child: const Text('Alert with Title'), + padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0), + onPressed: () { + showDemoDialog( + context: context, + child: CupertinoAlertDialog( + title: const Text('Allow "Maps" to access your location while you are using the app?'), + content: const Text('Your current location will be displayed on the map and used ' + 'for directions, nearby search results, and estimated travel times.'), + actions: [ + CupertinoDialogAction( + child: const Text('Don\'t Allow'), + onPressed: () { + Navigator.pop(context, 'Disallow'); + }, + ), + CupertinoDialogAction( + child: const Text('Allow'), + onPressed: () { + Navigator.pop(context, 'Allow'); + }, + ), + ], + ), + ); + }, + ), + const Padding(padding: EdgeInsets.all(8.0)), + CupertinoButton.filled( + child: const Text('Alert with Buttons'), + padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0), + onPressed: () { + showDemoDialog( + context: context, + child: const CupertinoDessertDialog( + title: Text('Select Favorite Dessert'), + content: Text('Please select your favorite type of dessert from the ' + 'list below. Your selection will be used to customize the suggested ' + 'list of eateries in your area.'), + ), + ); + }, + ), + const Padding(padding: EdgeInsets.all(8.0)), + CupertinoButton.filled( + child: const Text('Alert Buttons Only'), + padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0), + onPressed: () { + showDemoDialog( + context: context, + child: const CupertinoDessertDialog(), + ); + }, + ), + const Padding(padding: EdgeInsets.all(8.0)), + CupertinoButton.filled( + child: const Text('Action Sheet'), + padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0), + onPressed: () { + showDemoActionSheet( + context: context, + child: CupertinoActionSheet( + title: const Text('Favorite Dessert'), + message: const Text('Please select the best dessert from the options below.'), + actions: [ + CupertinoActionSheetAction( + child: const Text('Profiteroles'), + onPressed: () { + Navigator.pop(context, 'Profiteroles'); + }, + ), + CupertinoActionSheetAction( + child: const Text('Cannolis'), + onPressed: () { + Navigator.pop(context, 'Cannolis'); + }, + ), + CupertinoActionSheetAction( + child: const Text('Trifle'), + onPressed: () { + Navigator.pop(context, 'Trifle'); + }, + ), + ], + cancelButton: CupertinoActionSheetAction( child: const Text('Cancel'), isDefaultAction: true, onPressed: () { Navigator.pop(context, 'Cancel'); }, ), - ], - ), - ); - }, - ), - const Padding(padding: EdgeInsets.all(8.0)), - CupertinoButton.filled( - child: const Text('Alert with Title'), - padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0), - onPressed: () { - showDemoDialog( - context: context, - child: CupertinoAlertDialog( - title: const Text('Allow "Maps" to access your location while you are using the app?'), - content: const Text('Your current location will be displayed on the map and used ' - 'for directions, nearby search results, and estimated travel times.'), - actions: [ - CupertinoDialogAction( - child: const Text('Don\'t Allow'), - onPressed: () { - Navigator.pop(context, 'Disallow'); - }, - ), - CupertinoDialogAction( - child: const Text('Allow'), - onPressed: () { - Navigator.pop(context, 'Allow'); - }, - ), - ], - ), - ); - }, - ), - const Padding(padding: EdgeInsets.all(8.0)), - CupertinoButton.filled( - child: const Text('Alert with Buttons'), - padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0), - onPressed: () { - showDemoDialog( - context: context, - child: const CupertinoDessertDialog( - title: Text('Select Favorite Dessert'), - content: Text('Please select your favorite type of dessert from the ' - 'list below. Your selection will be used to customize the suggested ' - 'list of eateries in your area.'), - ), - ); - }, - ), - const Padding(padding: EdgeInsets.all(8.0)), - CupertinoButton.filled( - child: const Text('Alert Buttons Only'), - padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0), - onPressed: () { - showDemoDialog( - context: context, - child: const CupertinoDessertDialog(), - ); - }, - ), - const Padding(padding: EdgeInsets.all(8.0)), - CupertinoButton.filled( - child: const Text('Action Sheet'), - padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0), - onPressed: () { - showDemoActionSheet( - context: context, - child: CupertinoActionSheet( - title: const Text('Favorite Dessert'), - message: const Text('Please select the best dessert from the options below.'), - actions: [ - CupertinoActionSheetAction( - child: const Text('Profiteroles'), - onPressed: () { - Navigator.pop(context, 'Profiteroles'); - }, - ), - CupertinoActionSheetAction( - child: const Text('Cannolis'), - onPressed: () { - Navigator.pop(context, 'Cannolis'); - }, - ), - CupertinoActionSheetAction( - child: const Text('Trifle'), - onPressed: () { - Navigator.pop(context, 'Trifle'); - }, - ), - ], - cancelButton: CupertinoActionSheetAction( - child: const Text('Cancel'), - isDefaultAction: true, - onPressed: () { - Navigator.pop(context, 'Cancel'); - }, ), - ), - ); - }, - ), - ], + ); + }, + ), + ], + ), ), ]; diff --git a/examples/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart b/examples/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart index 24a5ece57d..43eb73fd5f 100644 --- a/examples/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart +++ b/examples/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart @@ -430,10 +430,12 @@ class CupertinoDemoTab2 extends StatelessWidget { navigationBar: CupertinoNavigationBar( trailing: trailingButtons, ), - child: ListView( - children: [ - Tab2Header(), - ]..addAll(buildTab2Conversation()), + child: CupertinoScrollbar( + child: ListView( + children: [ + Tab2Header(), + ]..addAll(buildTab2Conversation()), + ), ), ); } diff --git a/examples/flutter_gallery/lib/demo/cupertino/cupertino_text_field_demo.dart b/examples/flutter_gallery/lib/demo/cupertino/cupertino_text_field_demo.dart index 3c8f48f4cc..fc36ccecce 100644 --- a/examples/flutter_gallery/lib/demo/cupertino/cupertino_text_field_demo.dart +++ b/examples/flutter_gallery/lib/demo/cupertino/cupertino_text_field_demo.dart @@ -166,25 +166,27 @@ class _CupertinoTextFieldDemoState extends State { previousPageTitle: 'Cupertino', middle: Text('Text Fields'), ), - child: ListView( - children: [ - Padding( - padding: const EdgeInsets.symmetric(vertical: 32.0, horizontal: 16.0), - child: Column( - children: [ - _buildNameField(), - _buildEmailField(), - _buildLocationField(), - _buildPinField(), - _buildTagsField(), - ], + child: CupertinoScrollbar( + child: ListView( + children: [ + Padding( + padding: const EdgeInsets.symmetric(vertical: 32.0, horizontal: 16.0), + child: Column( + children: [ + _buildNameField(), + _buildEmailField(), + _buildLocationField(), + _buildPinField(), + _buildTagsField(), + ], + ), ), - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 32.0, horizontal: 16.0), - child: _buildChatTextField(), - ), - ], + Padding( + padding: const EdgeInsets.symmetric(vertical: 32.0, horizontal: 16.0), + child: _buildChatTextField(), + ), + ], + ), ), ), ); diff --git a/examples/flutter_gallery/lib/demo/material/backdrop_demo.dart b/examples/flutter_gallery/lib/demo/material/backdrop_demo.dart index 67d0a61408..0d2c785c43 100644 --- a/examples/flutter_gallery/lib/demo/material/backdrop_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/backdrop_demo.dart @@ -102,43 +102,45 @@ class CategoryView extends StatelessWidget { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - return ListView( - key: PageStorageKey(category), - padding: const EdgeInsets.symmetric( - vertical: 16.0, - horizontal: 64.0, - ), - children: category.assets.map((String asset) { - return Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Card( - child: Container( - width: 144.0, - alignment: Alignment.center, - child: Column( - children: [ - Image.asset( - asset, - package: 'flutter_gallery_assets', - fit: BoxFit.contain, - ), - Container( - padding: const EdgeInsets.only(bottom: 16.0), - alignment: AlignmentDirectional.center, - child: Text( + return Scrollbar( + child: ListView( + key: PageStorageKey(category), + padding: const EdgeInsets.symmetric( + vertical: 16.0, + horizontal: 64.0, + ), + children: category.assets.map((String asset) { + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Card( + child: Container( + width: 144.0, + alignment: Alignment.center, + child: Column( + children: [ + Image.asset( asset, - style: theme.textTheme.caption, + package: 'flutter_gallery_assets', + fit: BoxFit.contain, ), - ), - ], + Container( + padding: const EdgeInsets.only(bottom: 16.0), + alignment: AlignmentDirectional.center, + child: Text( + asset, + style: theme.textTheme.caption, + ), + ), + ], + ), ), ), - ), - const SizedBox(height: 24.0), - ], - ); - }).toList(), + const SizedBox(height: 24.0), + ], + ); + }).toList(), + ) ); } } diff --git a/examples/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart b/examples/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart index 7f2d8250b3..ac0c0d8125 100644 --- a/examples/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart @@ -156,34 +156,36 @@ class _BottomAppBarDemoState extends State { ), ], ), - body: ListView( - padding: const EdgeInsets.only(bottom: 88.0), - children: [ - const _Heading('FAB Shape'), + body: Scrollbar( + child: ListView( + padding: const EdgeInsets.only(bottom: 88.0), + children: [ + const _Heading('FAB Shape'), - _RadioItem(kCircularFab, _fabShape, _onFabShapeChanged), - _RadioItem(kDiamondFab, _fabShape, _onFabShapeChanged), - _RadioItem(kNoFab, _fabShape, _onFabShapeChanged), + _RadioItem(kCircularFab, _fabShape, _onFabShapeChanged), + _RadioItem(kDiamondFab, _fabShape, _onFabShapeChanged), + _RadioItem(kNoFab, _fabShape, _onFabShapeChanged), - const Divider(), - const _Heading('Notch'), + const Divider(), + const _Heading('Notch'), - _RadioItem(kShowNotchTrue, _showNotch, _onShowNotchChanged), - _RadioItem(kShowNotchFalse, _showNotch, _onShowNotchChanged), + _RadioItem(kShowNotchTrue, _showNotch, _onShowNotchChanged), + _RadioItem(kShowNotchFalse, _showNotch, _onShowNotchChanged), - const Divider(), - const _Heading('FAB Position'), + const Divider(), + const _Heading('FAB Position'), - _RadioItem(kFabEndDocked, _fabLocation, _onFabLocationChanged), - _RadioItem(kFabCenterDocked, _fabLocation, _onFabLocationChanged), - _RadioItem(kFabEndFloat, _fabLocation, _onFabLocationChanged), - _RadioItem(kFabCenterFloat, _fabLocation, _onFabLocationChanged), + _RadioItem(kFabEndDocked, _fabLocation, _onFabLocationChanged), + _RadioItem(kFabCenterDocked, _fabLocation, _onFabLocationChanged), + _RadioItem(kFabEndFloat, _fabLocation, _onFabLocationChanged), + _RadioItem(kFabCenterFloat, _fabLocation, _onFabLocationChanged), - const Divider(), - const _Heading('App bar color'), + const Divider(), + const _Heading('App bar color'), - _ColorsItem(kBabColors, _babColor, _onBabColorChanged), - ], + _ColorsItem(kBabColors, _babColor, _onBabColorChanged), + ], + ), ), floatingActionButton: _fabShape.value, floatingActionButtonLocation: _fabLocation.value, diff --git a/examples/flutter_gallery/lib/demo/material/cards_demo.dart b/examples/flutter_gallery/lib/demo/material/cards_demo.dart index dfc03f3c2f..4e3b788065 100644 --- a/examples/flutter_gallery/lib/demo/material/cards_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/cards_demo.dart @@ -388,27 +388,29 @@ class _CardsDemoState extends State { ), ], ), - body: ListView( - padding: const EdgeInsets.only(top: 8.0, left: 8.0, right: 8.0), - children: destinations.map((TravelDestination destination) { - Widget child; - switch (destination.type) { - case CardDemoType.standard: - child = TravelDestinationItem(destination: destination, shape: _shape); - break; - case CardDemoType.tappable: - child = TappableTravelDestinationItem(destination: destination, shape: _shape); - break; - case CardDemoType.selectable: - child = SelectableTravelDestinationItem(destination: destination, shape: _shape); - break; - } + body: Scrollbar( + child: ListView( + padding: const EdgeInsets.only(top: 8.0, left: 8.0, right: 8.0), + children: destinations.map((TravelDestination destination) { + Widget child; + switch (destination.type) { + case CardDemoType.standard: + child = TravelDestinationItem(destination: destination, shape: _shape); + break; + case CardDemoType.tappable: + child = TappableTravelDestinationItem(destination: destination, shape: _shape); + break; + case CardDemoType.selectable: + child = SelectableTravelDestinationItem(destination: destination, shape: _shape); + break; + } - return Container( - margin: const EdgeInsets.only(bottom: 8.0), - child: child, - ); - }).toList(), + return Container( + margin: const EdgeInsets.only(bottom: 8.0), + child: child, + ); + }).toList(), + ), ), ); } diff --git a/examples/flutter_gallery/lib/demo/material/chip_demo.dart b/examples/flutter_gallery/lib/demo/material/chip_demo.dart index fc1f497a72..38f5fb13f0 100644 --- a/examples/flutter_gallery/lib/demo/material/chip_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/chip_demo.dart @@ -324,7 +324,7 @@ class _ChipDemoState extends State { borderRadius: BorderRadius.circular(10.0), )) : theme.chipTheme, - child: ListView(children: tiles), + child: Scrollbar(child: ListView(children: tiles)), ), floatingActionButton: FloatingActionButton( onPressed: () => setState(_reset), diff --git a/examples/flutter_gallery/lib/demo/material/data_table_demo.dart b/examples/flutter_gallery/lib/demo/material/data_table_demo.dart index 5c0454ade4..5611829d53 100644 --- a/examples/flutter_gallery/lib/demo/material/data_table_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/data_table_demo.dart @@ -172,62 +172,64 @@ class _DataTableDemoState extends State { MaterialDemoDocumentationButton(DataTableDemo.routeName), ], ), - body: ListView( - padding: const EdgeInsets.all(20.0), - children: [ - PaginatedDataTable( - header: const Text('Nutrition'), - rowsPerPage: _rowsPerPage, - onRowsPerPageChanged: (int value) { setState(() { _rowsPerPage = value; }); }, - sortColumnIndex: _sortColumnIndex, - sortAscending: _sortAscending, - onSelectAll: _dessertsDataSource._selectAll, - columns: [ - DataColumn( - label: const Text('Dessert (100g serving)'), - onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.name, columnIndex, ascending), - ), - DataColumn( - label: const Text('Calories'), - tooltip: 'The total amount of food energy in the given serving size.', - numeric: true, - onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.calories, columnIndex, ascending), - ), - DataColumn( - label: const Text('Fat (g)'), - numeric: true, - onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.fat, columnIndex, ascending), - ), - DataColumn( - label: const Text('Carbs (g)'), - numeric: true, - onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.carbs, columnIndex, ascending), - ), - DataColumn( - label: const Text('Protein (g)'), - numeric: true, - onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.protein, columnIndex, ascending), - ), - DataColumn( - label: const Text('Sodium (mg)'), - numeric: true, - onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.sodium, columnIndex, ascending), - ), - DataColumn( - label: const Text('Calcium (%)'), - tooltip: 'The amount of calcium as a percentage of the recommended daily amount.', - numeric: true, - onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.calcium, columnIndex, ascending), - ), - DataColumn( - label: const Text('Iron (%)'), - numeric: true, - onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.iron, columnIndex, ascending), - ), - ], - source: _dessertsDataSource, - ), - ], + body: Scrollbar( + child: ListView( + padding: const EdgeInsets.all(20.0), + children: [ + PaginatedDataTable( + header: const Text('Nutrition'), + rowsPerPage: _rowsPerPage, + onRowsPerPageChanged: (int value) { setState(() { _rowsPerPage = value; }); }, + sortColumnIndex: _sortColumnIndex, + sortAscending: _sortAscending, + onSelectAll: _dessertsDataSource._selectAll, + columns: [ + DataColumn( + label: const Text('Dessert (100g serving)'), + onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.name, columnIndex, ascending), + ), + DataColumn( + label: const Text('Calories'), + tooltip: 'The total amount of food energy in the given serving size.', + numeric: true, + onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.calories, columnIndex, ascending), + ), + DataColumn( + label: const Text('Fat (g)'), + numeric: true, + onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.fat, columnIndex, ascending), + ), + DataColumn( + label: const Text('Carbs (g)'), + numeric: true, + onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.carbs, columnIndex, ascending), + ), + DataColumn( + label: const Text('Protein (g)'), + numeric: true, + onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.protein, columnIndex, ascending), + ), + DataColumn( + label: const Text('Sodium (mg)'), + numeric: true, + onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.sodium, columnIndex, ascending), + ), + DataColumn( + label: const Text('Calcium (%)'), + tooltip: 'The amount of calcium as a percentage of the recommended daily amount.', + numeric: true, + onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.calcium, columnIndex, ascending), + ), + DataColumn( + label: const Text('Iron (%)'), + numeric: true, + onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.iron, columnIndex, ascending), + ), + ], + source: _dessertsDataSource, + ), + ], + ), ), ); } diff --git a/examples/flutter_gallery/lib/demo/material/elevation_demo.dart b/examples/flutter_gallery/lib/demo/material/elevation_demo.dart index f8898082a6..0198657bba 100644 --- a/examples/flutter_gallery/lib/demo/material/elevation_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/elevation_demo.dart @@ -57,9 +57,7 @@ class _ElevationDemoState extends State { ), ], ), - body: ListView( - children: buildCards(), - ), + body: Scrollbar(child: ListView(children: buildCards())), ); } } diff --git a/examples/flutter_gallery/lib/demo/material/expansion_tile_list_demo.dart b/examples/flutter_gallery/lib/demo/material/expansion_tile_list_demo.dart index 9011e80395..10ad11f2f4 100644 --- a/examples/flutter_gallery/lib/demo/material/expansion_tile_list_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/expansion_tile_list_demo.dart @@ -16,22 +16,24 @@ class ExpansionTileListDemo extends StatelessWidget { title: const Text('Expand/collapse list control'), actions: [MaterialDemoDocumentationButton(routeName)], ), - body: ListView( - children: [ - const ListTile(title: Text('Top')), - ExpansionTile( - title: const Text('Sublist'), - backgroundColor: Theme.of(context).accentColor.withOpacity(0.025), - children: const [ - ListTile(title: Text('One')), - ListTile(title: Text('Two')), - // https://en.wikipedia.org/wiki/Free_Four - ListTile(title: Text('Free')), - ListTile(title: Text('Four')), - ], - ), - const ListTile(title: Text('Bottom')), - ], + body: Scrollbar( + child: ListView( + children: [ + const ListTile(title: Text('Top')), + ExpansionTile( + title: const Text('Sublist'), + backgroundColor: Theme.of(context).accentColor.withOpacity(0.025), + children: const [ + ListTile(title: Text('One')), + ListTile(title: Text('Two')), + // https://en.wikipedia.org/wiki/Free_Four + ListTile(title: Text('Free')), + ListTile(title: Text('Four')), + ], + ), + const ListTile(title: Text('Bottom')), + ], + ), ), ); } diff --git a/examples/flutter_gallery/lib/demo/material/full_screen_dialog_demo.dart b/examples/flutter_gallery/lib/demo/material/full_screen_dialog_demo.dart index c29e6ef05c..ab4a29592f 100644 --- a/examples/flutter_gallery/lib/demo/material/full_screen_dialog_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/full_screen_dialog_demo.dart @@ -162,86 +162,69 @@ class FullScreenDialogDemoState extends State { ), body: Form( onWillPop: _onWillPop, - child: ListView( - padding: const EdgeInsets.all(16.0), - children: [ - Container( - padding: const EdgeInsets.symmetric(vertical: 8.0), - alignment: Alignment.bottomLeft, - child: TextField( - decoration: const InputDecoration( - labelText: 'Event name', - filled: true, - ), - style: theme.textTheme.headline, - onChanged: (String value) { - setState(() { - _hasName = value.isNotEmpty; - if (_hasName) { - _eventName = value; - } - }); - }, - ), - ), - Container( - padding: const EdgeInsets.symmetric(vertical: 8.0), - alignment: Alignment.bottomLeft, - child: TextField( - decoration: const InputDecoration( - labelText: 'Location', - hintText: 'Where is the event?', - filled: true, - ), - onChanged: (String value) { - setState(() { - _hasLocation = value.isNotEmpty; - }); - }, - ), - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('From', style: theme.textTheme.caption), - DateTimeItem( - dateTime: _fromDateTime, - onChanged: (DateTime value) { + child: Scrollbar( + child: ListView( + padding: const EdgeInsets.all(16.0), + children: [ + Container( + padding: const EdgeInsets.symmetric(vertical: 8.0), + alignment: Alignment.bottomLeft, + child: TextField( + decoration: const InputDecoration( + labelText: 'Event name', + filled: true, + ), + style: theme.textTheme.headline, + onChanged: (String value) { setState(() { - _fromDateTime = value; - _saveNeeded = true; + _hasName = value.isNotEmpty; + if (_hasName) { + _eventName = value; + } }); }, ), - ], - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('To', style: theme.textTheme.caption), - DateTimeItem( - dateTime: _toDateTime, - onChanged: (DateTime value) { + ), + Container( + padding: const EdgeInsets.symmetric(vertical: 8.0), + alignment: Alignment.bottomLeft, + child: TextField( + decoration: const InputDecoration( + labelText: 'Location', + hintText: 'Where is the event?', + filled: true, + ), + onChanged: (String value) { setState(() { - _toDateTime = value; - _saveNeeded = true; + _hasLocation = value.isNotEmpty; }); }, ), - const Text('All-day'), - ], - ), - Container( - decoration: BoxDecoration( - border: Border(bottom: BorderSide(color: theme.dividerColor)) ), - child: Row( - children: [ - Checkbox( - value: _allDayValue, - onChanged: (bool value) { + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('From', style: theme.textTheme.caption), + DateTimeItem( + dateTime: _fromDateTime, + onChanged: (DateTime value) { setState(() { - _allDayValue = value; + _fromDateTime = value; + _saveNeeded = true; + }); + }, + ), + ], + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('To', style: theme.textTheme.caption), + DateTimeItem( + dateTime: _toDateTime, + onChanged: (DateTime value) { + setState(() { + _toDateTime = value; _saveNeeded = true; }); }, @@ -249,16 +232,35 @@ class FullScreenDialogDemoState extends State { const Text('All-day'), ], ), - ), - ] - .map((Widget child) { - return Container( - padding: const EdgeInsets.symmetric(vertical: 8.0), - height: 96.0, - child: child, - ); - }) - .toList(), + Container( + decoration: BoxDecoration( + border: Border(bottom: BorderSide(color: theme.dividerColor)) + ), + child: Row( + children: [ + Checkbox( + value: _allDayValue, + onChanged: (bool value) { + setState(() { + _allDayValue = value; + _saveNeeded = true; + }); + }, + ), + const Text('All-day'), + ], + ), + ), + ] + .map((Widget child) { + return Container( + padding: const EdgeInsets.symmetric(vertical: 8.0), + height: 96.0, + child: child, + ); + }) + .toList(), + ), ), ), ); diff --git a/examples/flutter_gallery/lib/demo/material/icons_demo.dart b/examples/flutter_gallery/lib/demo/material/icons_demo.dart index 21e3f1f6cc..b35a290a70 100644 --- a/examples/flutter_gallery/lib/demo/material/icons_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/icons_demo.dart @@ -58,13 +58,15 @@ class IconsDemoState extends State { child: SafeArea( top: false, bottom: false, - child: ListView( - padding: const EdgeInsets.all(24.0), - children: [ - _IconsDemoCard(handleIconButtonPress, Icons.face), // direction-agnostic icon - const SizedBox(height: 24.0), - _IconsDemoCard(handleIconButtonPress, Icons.battery_unknown), // direction-aware icon - ], + child: Scrollbar( + child: ListView( + padding: const EdgeInsets.all(24.0), + children: [ + _IconsDemoCard(handleIconButtonPress, Icons.face), // direction-agnostic icon + const SizedBox(height: 24.0), + _IconsDemoCard(handleIconButtonPress, Icons.battery_unknown), // direction-aware icon + ], + ), ), ), ), diff --git a/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart b/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart index 15763ebeb7..4ab956253e 100644 --- a/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart @@ -130,16 +130,18 @@ class LeaveBehindDemoState extends State { ), ); } else { - body = ListView( - children: leaveBehindItems.map((LeaveBehindItem item) { - return _LeaveBehindListItem( - confirmDismiss: _confirmDismiss, - item: item, - onArchive: _handleArchive, - onDelete: _handleDelete, - dismissDirection: _dismissDirection, - ); - }).toList(), + body = Scrollbar( + child: ListView( + children: leaveBehindItems.map((LeaveBehindItem item) { + return _LeaveBehindListItem( + confirmDismiss: _confirmDismiss, + item: item, + onArchive: _handleArchive, + onDelete: _handleDelete, + dismissDirection: _dismissDirection, + ); + }).toList(), + ), ); } diff --git a/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart b/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart index c758afa35f..cb9ebfc26f 100644 --- a/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart @@ -62,18 +62,20 @@ class OverscrollDemoState extends State { body: RefreshIndicator( key: _refreshIndicatorKey, onRefresh: _handleRefresh, - child: ListView.builder( - padding: kMaterialListPadding, - itemCount: _items.length, - itemBuilder: (BuildContext context, int index) { - final String item = _items[index]; - return ListTile( - isThreeLine: true, - leading: CircleAvatar(child: Text(item)), - title: Text('This item represents $item.'), - subtitle: const Text('Even more additional list item information appears on line three.'), - ); - }, + child: Scrollbar( + child: ListView.builder( + padding: kMaterialListPadding, + itemCount: _items.length, + itemBuilder: (BuildContext context, int index) { + final String item = _items[index]; + return ListTile( + isThreeLine: true, + leading: CircleAvatar(child: Text(item)), + title: Text('This item represents $item.'), + subtitle: const Text('Even more additional list item information appears on line three.'), + ); + }, + ), ), ), ); diff --git a/examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart b/examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart index 2ffe124fc2..d69e9313b4 100644 --- a/examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart @@ -182,116 +182,118 @@ class TextFormFieldDemoState extends State { key: _formKey, autovalidate: _autovalidate, onWillPop: _warnUserAboutInvalidData, - child: SingleChildScrollView( - dragStartBehavior: DragStartBehavior.down, - padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - const SizedBox(height: 24.0), - TextFormField( - textCapitalization: TextCapitalization.words, - decoration: const InputDecoration( - border: UnderlineInputBorder(), - filled: true, - icon: Icon(Icons.person), - hintText: 'What do people call you?', - labelText: 'Name *', + child: Scrollbar( + child: SingleChildScrollView( + dragStartBehavior: DragStartBehavior.down, + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const SizedBox(height: 24.0), + TextFormField( + textCapitalization: TextCapitalization.words, + decoration: const InputDecoration( + border: UnderlineInputBorder(), + filled: true, + icon: Icon(Icons.person), + hintText: 'What do people call you?', + labelText: 'Name *', + ), + onSaved: (String value) { person.name = value; }, + validator: _validateName, ), - onSaved: (String value) { person.name = value; }, - validator: _validateName, - ), - const SizedBox(height: 24.0), - TextFormField( - decoration: const InputDecoration( - border: UnderlineInputBorder(), - filled: true, - icon: Icon(Icons.phone), - hintText: 'Where can we reach you?', - labelText: 'Phone Number *', - prefixText: '+1', + const SizedBox(height: 24.0), + TextFormField( + decoration: const InputDecoration( + border: UnderlineInputBorder(), + filled: true, + icon: Icon(Icons.phone), + hintText: 'Where can we reach you?', + labelText: 'Phone Number *', + prefixText: '+1', + ), + keyboardType: TextInputType.phone, + onSaved: (String value) { person.phoneNumber = value; }, + validator: _validatePhoneNumber, + // TextInputFormatters are applied in sequence. + inputFormatters: [ + WhitelistingTextInputFormatter.digitsOnly, + // Fit the validating format. + _phoneNumberFormatter, + ], ), - keyboardType: TextInputType.phone, - onSaved: (String value) { person.phoneNumber = value; }, - validator: _validatePhoneNumber, - // TextInputFormatters are applied in sequence. - inputFormatters: [ - WhitelistingTextInputFormatter.digitsOnly, - // Fit the validating format. - _phoneNumberFormatter, - ], - ), - const SizedBox(height: 24.0), - TextFormField( - decoration: const InputDecoration( - border: UnderlineInputBorder(), - filled: true, - icon: Icon(Icons.email), - hintText: 'Your email address', - labelText: 'E-mail', + const SizedBox(height: 24.0), + TextFormField( + decoration: const InputDecoration( + border: UnderlineInputBorder(), + filled: true, + icon: Icon(Icons.email), + hintText: 'Your email address', + labelText: 'E-mail', + ), + keyboardType: TextInputType.emailAddress, + onSaved: (String value) { person.email = value; }, ), - keyboardType: TextInputType.emailAddress, - onSaved: (String value) { person.email = value; }, - ), - const SizedBox(height: 24.0), - TextFormField( - decoration: const InputDecoration( - border: OutlineInputBorder(), - hintText: 'Tell us about yourself (e.g., write down what you do or what hobbies you have)', - helperText: 'Keep it short, this is just a demo.', - labelText: 'Life story', + const SizedBox(height: 24.0), + TextFormField( + decoration: const InputDecoration( + border: OutlineInputBorder(), + hintText: 'Tell us about yourself (e.g., write down what you do or what hobbies you have)', + helperText: 'Keep it short, this is just a demo.', + labelText: 'Life story', + ), + maxLines: 3, ), - maxLines: 3, - ), - const SizedBox(height: 24.0), - TextFormField( - keyboardType: TextInputType.number, - decoration: const InputDecoration( - border: OutlineInputBorder(), - labelText: 'Salary', - prefixText: '\$', - suffixText: 'USD', - suffixStyle: TextStyle(color: Colors.green), + const SizedBox(height: 24.0), + TextFormField( + keyboardType: TextInputType.number, + decoration: const InputDecoration( + border: OutlineInputBorder(), + labelText: 'Salary', + prefixText: '\$', + suffixText: 'USD', + suffixStyle: TextStyle(color: Colors.green), + ), + maxLines: 1, ), - maxLines: 1, - ), - const SizedBox(height: 24.0), - PasswordField( - fieldKey: _passwordFieldKey, - helperText: 'No more than 8 characters.', - labelText: 'Password *', - onFieldSubmitted: (String value) { - setState(() { - person.password = value; - }); - }, - ), - const SizedBox(height: 24.0), - TextFormField( - enabled: person.password != null && person.password.isNotEmpty, - decoration: const InputDecoration( - border: UnderlineInputBorder(), - filled: true, - labelText: 'Re-type password', + const SizedBox(height: 24.0), + PasswordField( + fieldKey: _passwordFieldKey, + helperText: 'No more than 8 characters.', + labelText: 'Password *', + onFieldSubmitted: (String value) { + setState(() { + person.password = value; + }); + }, ), - maxLength: 8, - obscureText: true, - validator: _validatePassword, - ), - const SizedBox(height: 24.0), - Center( - child: RaisedButton( - child: const Text('SUBMIT'), - onPressed: _handleSubmitted, + const SizedBox(height: 24.0), + TextFormField( + enabled: person.password != null && person.password.isNotEmpty, + decoration: const InputDecoration( + border: UnderlineInputBorder(), + filled: true, + labelText: 'Re-type password', + ), + maxLength: 8, + obscureText: true, + validator: _validatePassword, ), - ), - const SizedBox(height: 24.0), - Text( - '* indicates required field', - style: Theme.of(context).textTheme.caption, - ), - const SizedBox(height: 24.0), - ], + const SizedBox(height: 24.0), + Center( + child: RaisedButton( + child: const Text('SUBMIT'), + onPressed: _handleSubmitted, + ), + ), + const SizedBox(height: 24.0), + Text( + '* indicates required field', + style: Theme.of(context).textTheme.caption, + ), + const SizedBox(height: 24.0), + ], + ), ), ), ), diff --git a/examples/flutter_gallery/lib/demo/typography_demo.dart b/examples/flutter_gallery/lib/demo/typography_demo.dart index 5f9c58bf91..18c3e3a966 100644 --- a/examples/flutter_gallery/lib/demo/typography_demo.dart +++ b/examples/flutter_gallery/lib/demo/typography_demo.dart @@ -73,7 +73,7 @@ class TypographyDemo extends StatelessWidget { body: SafeArea( top: false, bottom: false, - child: ListView(children: styleItems), + child: Scrollbar(child: ListView(children: styleItems)), ), ); } diff --git a/examples/flutter_gallery/lib/demo/video_demo.dart b/examples/flutter_gallery/lib/demo/video_demo.dart index 66d78410a1..81f7bfcec8 100644 --- a/examples/flutter_gallery/lib/demo/video_demo.dart +++ b/examples/flutter_gallery/lib/demo/video_demo.dart @@ -405,19 +405,21 @@ class _VideoDemoState extends State with SingleTickerProviderStateMix ), body: isSupported ? ConnectivityOverlay( - child: ListView( - children: [ - VideoCard( - title: 'Butterfly', - subtitle: '… flutters by', - controller: butterflyController, - ), - VideoCard( - title: 'Bee', - subtitle: '… gently buzzing', - controller: beeController, - ), - ], + child: Scrollbar( + child: ListView( + children: [ + VideoCard( + title: 'Butterfly', + subtitle: '… flutters by', + controller: butterflyController, + ), + VideoCard( + title: 'Bee', + subtitle: '… gently buzzing', + controller: beeController, + ), + ], + ), ), connectedCompleter: connectedCompleter, scaffoldKey: scaffoldKey,