Skip to content

Commit 8a0f911

Browse files
authored
Remove unused generic type from BottomSheet (#137791)
Fixes flutter/flutter#137424. The generic type argument was unused.
1 parent 6f5ca85 commit 8a0f911

File tree

19 files changed

+65
-69
lines changed

19 files changed

+65
-69
lines changed

dev/benchmarks/macrobenchmarks/lib/src/web/material3.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,7 @@ class BottomSheetSection extends StatefulWidget {
15791579

15801580
class _BottomSheetSectionState extends State<BottomSheetSection> {
15811581
bool isNonModalBottomSheetOpen = false;
1582-
PersistentBottomSheetController<void>? _nonModalBottomSheetController;
1582+
PersistentBottomSheetController? _nonModalBottomSheetController;
15831583

15841584
@override
15851585
Widget build(BuildContext context) {
@@ -1663,7 +1663,7 @@ class _BottomSheetSectionState extends State<BottomSheetSection> {
16631663
});
16641664
}
16651665

1666-
_nonModalBottomSheetController = showBottomSheet<void>(
1666+
_nonModalBottomSheetController = showBottomSheet(
16671667
elevation: 8.0,
16681668
context: context,
16691669
constraints: const BoxConstraints(maxWidth: 640),

dev/benchmarks/test_apps/stocks/lib/stock_home.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class StockHomeState extends State<StockHome> {
265265
Navigator.pushNamed(context, '/stock', arguments: stock.symbol);
266266
},
267267
onShow: (Stock stock) {
268-
_scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) => StockSymbolBottomSheet(stock: stock));
268+
_scaffoldKey.currentState!.showBottomSheet((BuildContext context) => StockSymbolBottomSheet(stock: stock));
269269
},
270270
);
271271
}

dev/integration_tests/flutter_gallery/lib/demo/material/list_demo.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ListDemo extends StatefulWidget {
3232
class _ListDemoState extends State<ListDemo> {
3333
static final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
3434

35-
PersistentBottomSheetController<void>? _bottomSheet;
35+
PersistentBottomSheetController? _bottomSheet;
3636
_MaterialListType? _itemType = _MaterialListType.threeLine;
3737
bool? _dense = false;
3838
bool? _showAvatars = true;
@@ -51,7 +51,7 @@ class _ListDemoState extends State<ListDemo> {
5151
}
5252

5353
void _showConfigurationSheet() {
54-
final PersistentBottomSheetController<void> bottomSheet = scaffoldKey.currentState!.showBottomSheet<void>((BuildContext bottomSheetContext) {
54+
final PersistentBottomSheetController bottomSheet = scaffoldKey.currentState!.showBottomSheet((BuildContext bottomSheetContext) {
5555
return Container(
5656
decoration: const BoxDecoration(
5757
border: Border(top: BorderSide(color: Colors.black26)),

dev/integration_tests/flutter_gallery/lib/demo/material/persistent_bottom_sheet_demo.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
3030
setState(() { // disable the button
3131
_showBottomSheetCallback = null;
3232
});
33-
_scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
33+
_scaffoldKey.currentState!.showBottomSheet((BuildContext context) {
3434
final ThemeData themeData = Theme.of(context);
3535
return Container(
3636
decoration: BoxDecoration(

dev/integration_tests/flutter_gallery/lib/demo/material/reorderable_list_demo.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class _ListItem {
3737
class _ListDemoState extends State<ReorderableListDemo> {
3838
static final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
3939

40-
PersistentBottomSheetController<void>? _bottomSheet;
40+
PersistentBottomSheetController? _bottomSheet;
4141
_ReorderableListType? _itemType = _ReorderableListType.threeLine;
4242
bool? _reverse = false;
4343
bool _reverseSort = false;
@@ -71,7 +71,7 @@ class _ListDemoState extends State<ReorderableListDemo> {
7171

7272
void _showConfigurationSheet() {
7373
setState(() {
74-
_bottomSheet = scaffoldKey.currentState!.showBottomSheet<void>((BuildContext bottomSheetContext) {
74+
_bottomSheet = scaffoldKey.currentState!.showBottomSheet((BuildContext bottomSheetContext) {
7575
return DecoratedBox(
7676
decoration: const BoxDecoration(
7777
border: Border(top: BorderSide(color: Colors.black26)),

dev/integration_tests/flutter_gallery/lib/demo/material/tabs_fab_demo.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat
7171
}
7272

7373
void _showExplanatoryText() {
74-
_scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
74+
_scaffoldKey.currentState!.showBottomSheet((BuildContext context) {
7575
return Container(
7676
decoration: BoxDecoration(
7777
border: Border(top: BorderSide(color: Theme.of(context).dividerColor))

examples/api/lib/material/navigation_bar/navigation_bar.2.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ class RootPage extends StatelessWidget {
220220
return ElevatedButton(
221221
style: buttonStyle,
222222
onPressed: () {
223-
showBottomSheet<void>(
223+
showBottomSheet(
224224
context: context,
225225
builder: (BuildContext context) {
226226
return Container(

examples/api/lib/material/scaffold/scaffold.of.0.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class MyScaffoldBody extends StatelessWidget {
3636
child: ElevatedButton(
3737
child: const Text('SHOW BOTTOM SHEET'),
3838
onPressed: () {
39-
Scaffold.of(context).showBottomSheet<void>(
39+
Scaffold.of(context).showBottomSheet(
4040
(BuildContext context) {
4141
return Container(
4242
alignment: Alignment.center,

examples/api/lib/material/scaffold/scaffold.of.1.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class OfExample extends StatelessWidget {
3434
child: ElevatedButton(
3535
child: const Text('SHOW BOTTOM SHEET'),
3636
onPressed: () {
37-
Scaffold.of(context).showBottomSheet<void>(
37+
Scaffold.of(context).showBottomSheet(
3838
(BuildContext context) {
3939
return Container(
4040
alignment: Alignment.center,

examples/api/lib/material/scaffold/scaffold_state.show_bottom_sheet.0.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ShowBottomSheetExample extends StatelessWidget {
3131
child: ElevatedButton(
3232
child: const Text('showBottomSheet'),
3333
onPressed: () {
34-
Scaffold.of(context).showBottomSheet<void>(
34+
Scaffold.of(context).showBottomSheet(
3535
(BuildContext context) {
3636
return Container(
3737
height: 200,

packages/flutter/lib/src/material/bottom_sheet.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ Future<T?> showModalBottomSheet<T>({
13241324
/// * [Scaffold.of], for information about how to obtain the [BuildContext].
13251325
/// * The Material 2 spec at <https://m2.material.io/components/sheets-bottom>.
13261326
/// * The Material 3 spec at <https://m3.material.io/components/bottom-sheets/overview>.
1327-
PersistentBottomSheetController<T> showBottomSheet<T>({
1327+
PersistentBottomSheetController showBottomSheet({
13281328
required BuildContext context,
13291329
required WidgetBuilder builder,
13301330
Color? backgroundColor,
@@ -1337,7 +1337,7 @@ PersistentBottomSheetController<T> showBottomSheet<T>({
13371337
}) {
13381338
assert(debugCheckHasScaffold(context));
13391339

1340-
return Scaffold.of(context).showBottomSheet<T>(
1340+
return Scaffold.of(context).showBottomSheet(
13411341
builder,
13421342
backgroundColor: backgroundColor,
13431343
elevation: elevation,

packages/flutter/lib/src/material/scaffold.dart

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,7 +2121,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
21212121
/// appropriate [IconButton], and handles the edge-swipe gesture, to show the
21222122
/// drawer.
21232123
///
2124-
/// To close the drawer, use either [ScaffoldState.closeEndDrawer] or
2124+
/// To close the drawer, use either [ScaffoldState.closeDrawer] or
21252125
/// [Navigator.pop].
21262126
///
21272127
/// See [Scaffold.of] for information about how to obtain the [ScaffoldState].
@@ -2196,7 +2196,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
21962196
// Important if the app/user takes an action that could repeatedly show a
21972197
// bottom sheet.
21982198
final List<_StandardBottomSheet> _dismissedBottomSheets = <_StandardBottomSheet>[];
2199-
PersistentBottomSheetController<dynamic>? _currentBottomSheet;
2199+
PersistentBottomSheetController? _currentBottomSheet;
22002200
final GlobalKey _currentBottomSheetKey = GlobalKey();
22012201
LocalHistoryEntry? _persistentSheetHistoryEntry;
22022202

@@ -2234,7 +2234,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
22342234
assert(_dismissedBottomSheets.isEmpty);
22352235
}
22362236

2237-
_currentBottomSheet = _buildBottomSheet<void>(
2237+
_currentBottomSheet = _buildBottomSheet(
22382238
(BuildContext context) {
22392239
return NotificationListener<DraggableScrollableNotification>(
22402240
onNotification: persistentBottomSheetExtentChanged,
@@ -2290,7 +2290,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
22902290
_currentBottomSheetKey.currentState!.setState(() {});
22912291
}
22922292

2293-
PersistentBottomSheetController<T> _buildBottomSheet<T>(
2293+
PersistentBottomSheetController _buildBottomSheet(
22942294
WidgetBuilder builder, {
22952295
required bool isPersistent,
22962296
required AnimationController animationController,
@@ -2313,7 +2313,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
23132313
return true;
23142314
}());
23152315

2316-
final Completer<T> completer = Completer<T>();
2316+
final Completer<void> completer = Completer<void>();
23172317
final GlobalKey<_StandardBottomSheetState> bottomSheetKey = GlobalKey<_StandardBottomSheetState>();
23182318
late _StandardBottomSheet bottomSheet;
23192319

@@ -2351,10 +2351,6 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
23512351
if (animationController.status != AnimationStatus.dismissed) {
23522352
_dismissedBottomSheets.add(bottomSheet);
23532353
}
2354-
// TODO(srawlins): Ensure that this Completer has a nullable type (or more
2355-
// likely, `void`).
2356-
// https://github.com/flutter/flutter/issues/137294).
2357-
// ignore: null_argument_to_non_null_type
23582354
completer.complete();
23592355
}
23602356

@@ -2412,7 +2408,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
24122408
ModalRoute.of(context)!.addLocalHistoryEntry(entry!);
24132409
}
24142410

2415-
return PersistentBottomSheetController<T>._(
2411+
return PersistentBottomSheetController._(
24162412
bottomSheet,
24172413
completer,
24182414
entry != null
@@ -2471,7 +2467,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
24712467
/// * [Scaffold.of], for information about how to obtain the [ScaffoldState].
24722468
/// * The Material 2 spec at <https://m2.material.io/components/sheets-bottom>.
24732469
/// * The Material 3 spec at <https://m3.material.io/components/bottom-sheets/overview>.
2474-
PersistentBottomSheetController<T> showBottomSheet<T>(
2470+
PersistentBottomSheetController showBottomSheet(
24752471
WidgetBuilder builder, {
24762472
Color? backgroundColor,
24772473
double? elevation,
@@ -2496,7 +2492,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
24962492
_closeCurrentBottomSheet();
24972493
final AnimationController controller = (transitionAnimationController ?? BottomSheet.createAnimationController(this))..forward();
24982494
setState(() {
2499-
_currentBottomSheet = _buildBottomSheet<T>(
2495+
_currentBottomSheet = _buildBottomSheet(
25002496
builder,
25012497
isPersistent: false,
25022498
animationController: controller,
@@ -2509,7 +2505,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
25092505
shouldDisposeAnimationController: transitionAnimationController == null,
25102506
);
25112507
});
2512-
return _currentBottomSheet! as PersistentBottomSheetController<T>;
2508+
return _currentBottomSheet!;
25132509
}
25142510

25152511
// Floating Action Button API
@@ -3274,7 +3270,7 @@ class _StandardBottomSheetState extends State<_StandardBottomSheet> {
32743270
/// This controller is used to display both standard and persistent bottom
32753271
/// sheets. A bottom sheet is only persistent if it is set as the
32763272
/// [Scaffold.bottomSheet].
3277-
class PersistentBottomSheetController<T> extends ScaffoldFeatureController<_StandardBottomSheet, T> {
3273+
class PersistentBottomSheetController extends ScaffoldFeatureController<_StandardBottomSheet, void> {
32783274
const PersistentBottomSheetController._(
32793275
super.widget,
32803276
super.completer,

packages/flutter/lib/src/widgets/framework.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2178,7 +2178,7 @@ typedef ConditionalElementVisitor = bool Function(Element element);
21782178
/// return TextButton(
21792179
/// child: const Text('BUTTON'),
21802180
/// onPressed: () {
2181-
/// Scaffold.of(context).showBottomSheet<void>(
2181+
/// Scaffold.of(context).showBottomSheet(
21822182
/// (BuildContext context) {
21832183
/// return Container(
21842184
/// alignment: Alignment.center,

0 commit comments

Comments
 (0)