Remove unused generic type from BottomSheet (#137791)
Fixes https://github.com/flutter/flutter/issues/137424. The generic type argument was unused.
This commit is contained in:
parent
6f5ca8542c
commit
8a0f9118ea
@ -1579,7 +1579,7 @@ class BottomSheetSection extends StatefulWidget {
|
|||||||
|
|
||||||
class _BottomSheetSectionState extends State<BottomSheetSection> {
|
class _BottomSheetSectionState extends State<BottomSheetSection> {
|
||||||
bool isNonModalBottomSheetOpen = false;
|
bool isNonModalBottomSheetOpen = false;
|
||||||
PersistentBottomSheetController<void>? _nonModalBottomSheetController;
|
PersistentBottomSheetController? _nonModalBottomSheetController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -1663,7 +1663,7 @@ class _BottomSheetSectionState extends State<BottomSheetSection> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_nonModalBottomSheetController = showBottomSheet<void>(
|
_nonModalBottomSheetController = showBottomSheet(
|
||||||
elevation: 8.0,
|
elevation: 8.0,
|
||||||
context: context,
|
context: context,
|
||||||
constraints: const BoxConstraints(maxWidth: 640),
|
constraints: const BoxConstraints(maxWidth: 640),
|
||||||
|
@ -265,7 +265,7 @@ class StockHomeState extends State<StockHome> {
|
|||||||
Navigator.pushNamed(context, '/stock', arguments: stock.symbol);
|
Navigator.pushNamed(context, '/stock', arguments: stock.symbol);
|
||||||
},
|
},
|
||||||
onShow: (Stock stock) {
|
onShow: (Stock stock) {
|
||||||
_scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) => StockSymbolBottomSheet(stock: stock));
|
_scaffoldKey.currentState!.showBottomSheet((BuildContext context) => StockSymbolBottomSheet(stock: stock));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ class ListDemo extends StatefulWidget {
|
|||||||
class _ListDemoState extends State<ListDemo> {
|
class _ListDemoState extends State<ListDemo> {
|
||||||
static final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
static final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
PersistentBottomSheetController<void>? _bottomSheet;
|
PersistentBottomSheetController? _bottomSheet;
|
||||||
_MaterialListType? _itemType = _MaterialListType.threeLine;
|
_MaterialListType? _itemType = _MaterialListType.threeLine;
|
||||||
bool? _dense = false;
|
bool? _dense = false;
|
||||||
bool? _showAvatars = true;
|
bool? _showAvatars = true;
|
||||||
@ -51,7 +51,7 @@ class _ListDemoState extends State<ListDemo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _showConfigurationSheet() {
|
void _showConfigurationSheet() {
|
||||||
final PersistentBottomSheetController<void> bottomSheet = scaffoldKey.currentState!.showBottomSheet<void>((BuildContext bottomSheetContext) {
|
final PersistentBottomSheetController bottomSheet = scaffoldKey.currentState!.showBottomSheet((BuildContext bottomSheetContext) {
|
||||||
return Container(
|
return Container(
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
border: Border(top: BorderSide(color: Colors.black26)),
|
border: Border(top: BorderSide(color: Colors.black26)),
|
||||||
|
@ -30,7 +30,7 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
|
|||||||
setState(() { // disable the button
|
setState(() { // disable the button
|
||||||
_showBottomSheetCallback = null;
|
_showBottomSheetCallback = null;
|
||||||
});
|
});
|
||||||
_scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
|
_scaffoldKey.currentState!.showBottomSheet((BuildContext context) {
|
||||||
final ThemeData themeData = Theme.of(context);
|
final ThemeData themeData = Theme.of(context);
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
@ -37,7 +37,7 @@ class _ListItem {
|
|||||||
class _ListDemoState extends State<ReorderableListDemo> {
|
class _ListDemoState extends State<ReorderableListDemo> {
|
||||||
static final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
static final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
PersistentBottomSheetController<void>? _bottomSheet;
|
PersistentBottomSheetController? _bottomSheet;
|
||||||
_ReorderableListType? _itemType = _ReorderableListType.threeLine;
|
_ReorderableListType? _itemType = _ReorderableListType.threeLine;
|
||||||
bool? _reverse = false;
|
bool? _reverse = false;
|
||||||
bool _reverseSort = false;
|
bool _reverseSort = false;
|
||||||
@ -71,7 +71,7 @@ class _ListDemoState extends State<ReorderableListDemo> {
|
|||||||
|
|
||||||
void _showConfigurationSheet() {
|
void _showConfigurationSheet() {
|
||||||
setState(() {
|
setState(() {
|
||||||
_bottomSheet = scaffoldKey.currentState!.showBottomSheet<void>((BuildContext bottomSheetContext) {
|
_bottomSheet = scaffoldKey.currentState!.showBottomSheet((BuildContext bottomSheetContext) {
|
||||||
return DecoratedBox(
|
return DecoratedBox(
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
border: Border(top: BorderSide(color: Colors.black26)),
|
border: Border(top: BorderSide(color: Colors.black26)),
|
||||||
|
@ -71,7 +71,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _showExplanatoryText() {
|
void _showExplanatoryText() {
|
||||||
_scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
|
_scaffoldKey.currentState!.showBottomSheet((BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(top: BorderSide(color: Theme.of(context).dividerColor))
|
border: Border(top: BorderSide(color: Theme.of(context).dividerColor))
|
||||||
|
@ -220,7 +220,7 @@ class RootPage extends StatelessWidget {
|
|||||||
return ElevatedButton(
|
return ElevatedButton(
|
||||||
style: buttonStyle,
|
style: buttonStyle,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showBottomSheet<void>(
|
showBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
|
@ -36,7 +36,7 @@ class MyScaffoldBody extends StatelessWidget {
|
|||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
child: const Text('SHOW BOTTOM SHEET'),
|
child: const Text('SHOW BOTTOM SHEET'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Scaffold.of(context).showBottomSheet<void>(
|
Scaffold.of(context).showBottomSheet(
|
||||||
(BuildContext context) {
|
(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
|
@ -34,7 +34,7 @@ class OfExample extends StatelessWidget {
|
|||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
child: const Text('SHOW BOTTOM SHEET'),
|
child: const Text('SHOW BOTTOM SHEET'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Scaffold.of(context).showBottomSheet<void>(
|
Scaffold.of(context).showBottomSheet(
|
||||||
(BuildContext context) {
|
(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
|
@ -31,7 +31,7 @@ class ShowBottomSheetExample extends StatelessWidget {
|
|||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
child: const Text('showBottomSheet'),
|
child: const Text('showBottomSheet'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Scaffold.of(context).showBottomSheet<void>(
|
Scaffold.of(context).showBottomSheet(
|
||||||
(BuildContext context) {
|
(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
height: 200,
|
height: 200,
|
||||||
|
@ -1324,7 +1324,7 @@ Future<T?> showModalBottomSheet<T>({
|
|||||||
/// * [Scaffold.of], for information about how to obtain the [BuildContext].
|
/// * [Scaffold.of], for information about how to obtain the [BuildContext].
|
||||||
/// * The Material 2 spec at <https://m2.material.io/components/sheets-bottom>.
|
/// * The Material 2 spec at <https://m2.material.io/components/sheets-bottom>.
|
||||||
/// * The Material 3 spec at <https://m3.material.io/components/bottom-sheets/overview>.
|
/// * The Material 3 spec at <https://m3.material.io/components/bottom-sheets/overview>.
|
||||||
PersistentBottomSheetController<T> showBottomSheet<T>({
|
PersistentBottomSheetController showBottomSheet({
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required WidgetBuilder builder,
|
required WidgetBuilder builder,
|
||||||
Color? backgroundColor,
|
Color? backgroundColor,
|
||||||
@ -1337,7 +1337,7 @@ PersistentBottomSheetController<T> showBottomSheet<T>({
|
|||||||
}) {
|
}) {
|
||||||
assert(debugCheckHasScaffold(context));
|
assert(debugCheckHasScaffold(context));
|
||||||
|
|
||||||
return Scaffold.of(context).showBottomSheet<T>(
|
return Scaffold.of(context).showBottomSheet(
|
||||||
builder,
|
builder,
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
elevation: elevation,
|
elevation: elevation,
|
||||||
|
@ -2121,7 +2121,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
|||||||
/// appropriate [IconButton], and handles the edge-swipe gesture, to show the
|
/// appropriate [IconButton], and handles the edge-swipe gesture, to show the
|
||||||
/// drawer.
|
/// drawer.
|
||||||
///
|
///
|
||||||
/// To close the drawer, use either [ScaffoldState.closeEndDrawer] or
|
/// To close the drawer, use either [ScaffoldState.closeDrawer] or
|
||||||
/// [Navigator.pop].
|
/// [Navigator.pop].
|
||||||
///
|
///
|
||||||
/// See [Scaffold.of] for information about how to obtain the [ScaffoldState].
|
/// See [Scaffold.of] for information about how to obtain the [ScaffoldState].
|
||||||
@ -2196,7 +2196,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
|||||||
// Important if the app/user takes an action that could repeatedly show a
|
// Important if the app/user takes an action that could repeatedly show a
|
||||||
// bottom sheet.
|
// bottom sheet.
|
||||||
final List<_StandardBottomSheet> _dismissedBottomSheets = <_StandardBottomSheet>[];
|
final List<_StandardBottomSheet> _dismissedBottomSheets = <_StandardBottomSheet>[];
|
||||||
PersistentBottomSheetController<dynamic>? _currentBottomSheet;
|
PersistentBottomSheetController? _currentBottomSheet;
|
||||||
final GlobalKey _currentBottomSheetKey = GlobalKey();
|
final GlobalKey _currentBottomSheetKey = GlobalKey();
|
||||||
LocalHistoryEntry? _persistentSheetHistoryEntry;
|
LocalHistoryEntry? _persistentSheetHistoryEntry;
|
||||||
|
|
||||||
@ -2234,7 +2234,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
|||||||
assert(_dismissedBottomSheets.isEmpty);
|
assert(_dismissedBottomSheets.isEmpty);
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentBottomSheet = _buildBottomSheet<void>(
|
_currentBottomSheet = _buildBottomSheet(
|
||||||
(BuildContext context) {
|
(BuildContext context) {
|
||||||
return NotificationListener<DraggableScrollableNotification>(
|
return NotificationListener<DraggableScrollableNotification>(
|
||||||
onNotification: persistentBottomSheetExtentChanged,
|
onNotification: persistentBottomSheetExtentChanged,
|
||||||
@ -2290,7 +2290,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
|||||||
_currentBottomSheetKey.currentState!.setState(() {});
|
_currentBottomSheetKey.currentState!.setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
PersistentBottomSheetController<T> _buildBottomSheet<T>(
|
PersistentBottomSheetController _buildBottomSheet(
|
||||||
WidgetBuilder builder, {
|
WidgetBuilder builder, {
|
||||||
required bool isPersistent,
|
required bool isPersistent,
|
||||||
required AnimationController animationController,
|
required AnimationController animationController,
|
||||||
@ -2313,7 +2313,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
|||||||
return true;
|
return true;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
final Completer<T> completer = Completer<T>();
|
final Completer<void> completer = Completer<void>();
|
||||||
final GlobalKey<_StandardBottomSheetState> bottomSheetKey = GlobalKey<_StandardBottomSheetState>();
|
final GlobalKey<_StandardBottomSheetState> bottomSheetKey = GlobalKey<_StandardBottomSheetState>();
|
||||||
late _StandardBottomSheet bottomSheet;
|
late _StandardBottomSheet bottomSheet;
|
||||||
|
|
||||||
@ -2351,10 +2351,6 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
|||||||
if (animationController.status != AnimationStatus.dismissed) {
|
if (animationController.status != AnimationStatus.dismissed) {
|
||||||
_dismissedBottomSheets.add(bottomSheet);
|
_dismissedBottomSheets.add(bottomSheet);
|
||||||
}
|
}
|
||||||
// TODO(srawlins): Ensure that this Completer has a nullable type (or more
|
|
||||||
// likely, `void`).
|
|
||||||
// https://github.com/flutter/flutter/issues/137294).
|
|
||||||
// ignore: null_argument_to_non_null_type
|
|
||||||
completer.complete();
|
completer.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2412,7 +2408,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
|||||||
ModalRoute.of(context)!.addLocalHistoryEntry(entry!);
|
ModalRoute.of(context)!.addLocalHistoryEntry(entry!);
|
||||||
}
|
}
|
||||||
|
|
||||||
return PersistentBottomSheetController<T>._(
|
return PersistentBottomSheetController._(
|
||||||
bottomSheet,
|
bottomSheet,
|
||||||
completer,
|
completer,
|
||||||
entry != null
|
entry != null
|
||||||
@ -2471,7 +2467,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
|||||||
/// * [Scaffold.of], for information about how to obtain the [ScaffoldState].
|
/// * [Scaffold.of], for information about how to obtain the [ScaffoldState].
|
||||||
/// * The Material 2 spec at <https://m2.material.io/components/sheets-bottom>.
|
/// * The Material 2 spec at <https://m2.material.io/components/sheets-bottom>.
|
||||||
/// * The Material 3 spec at <https://m3.material.io/components/bottom-sheets/overview>.
|
/// * The Material 3 spec at <https://m3.material.io/components/bottom-sheets/overview>.
|
||||||
PersistentBottomSheetController<T> showBottomSheet<T>(
|
PersistentBottomSheetController showBottomSheet(
|
||||||
WidgetBuilder builder, {
|
WidgetBuilder builder, {
|
||||||
Color? backgroundColor,
|
Color? backgroundColor,
|
||||||
double? elevation,
|
double? elevation,
|
||||||
@ -2496,7 +2492,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
|||||||
_closeCurrentBottomSheet();
|
_closeCurrentBottomSheet();
|
||||||
final AnimationController controller = (transitionAnimationController ?? BottomSheet.createAnimationController(this))..forward();
|
final AnimationController controller = (transitionAnimationController ?? BottomSheet.createAnimationController(this))..forward();
|
||||||
setState(() {
|
setState(() {
|
||||||
_currentBottomSheet = _buildBottomSheet<T>(
|
_currentBottomSheet = _buildBottomSheet(
|
||||||
builder,
|
builder,
|
||||||
isPersistent: false,
|
isPersistent: false,
|
||||||
animationController: controller,
|
animationController: controller,
|
||||||
@ -2509,7 +2505,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
|||||||
shouldDisposeAnimationController: transitionAnimationController == null,
|
shouldDisposeAnimationController: transitionAnimationController == null,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
return _currentBottomSheet! as PersistentBottomSheetController<T>;
|
return _currentBottomSheet!;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Floating Action Button API
|
// Floating Action Button API
|
||||||
@ -3274,7 +3270,7 @@ class _StandardBottomSheetState extends State<_StandardBottomSheet> {
|
|||||||
/// This controller is used to display both standard and persistent bottom
|
/// This controller is used to display both standard and persistent bottom
|
||||||
/// sheets. A bottom sheet is only persistent if it is set as the
|
/// sheets. A bottom sheet is only persistent if it is set as the
|
||||||
/// [Scaffold.bottomSheet].
|
/// [Scaffold.bottomSheet].
|
||||||
class PersistentBottomSheetController<T> extends ScaffoldFeatureController<_StandardBottomSheet, T> {
|
class PersistentBottomSheetController extends ScaffoldFeatureController<_StandardBottomSheet, void> {
|
||||||
const PersistentBottomSheetController._(
|
const PersistentBottomSheetController._(
|
||||||
super.widget,
|
super.widget,
|
||||||
super.completer,
|
super.completer,
|
||||||
|
@ -2178,7 +2178,7 @@ typedef ConditionalElementVisitor = bool Function(Element element);
|
|||||||
/// return TextButton(
|
/// return TextButton(
|
||||||
/// child: const Text('BUTTON'),
|
/// child: const Text('BUTTON'),
|
||||||
/// onPressed: () {
|
/// onPressed: () {
|
||||||
/// Scaffold.of(context).showBottomSheet<void>(
|
/// Scaffold.of(context).showBottomSheet(
|
||||||
/// (BuildContext context) {
|
/// (BuildContext context) {
|
||||||
/// return Container(
|
/// return Container(
|
||||||
/// alignment: Alignment.center,
|
/// alignment: Alignment.center,
|
||||||
|
@ -106,7 +106,7 @@ void main() {
|
|||||||
expect(showBottomSheetThenCalled, isFalse);
|
expect(showBottomSheetThenCalled, isFalse);
|
||||||
expect(find.text('BottomSheet'), findsNothing);
|
expect(find.text('BottomSheet'), findsNothing);
|
||||||
|
|
||||||
scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
|
scaffoldKey.currentState!.showBottomSheet((BuildContext context) {
|
||||||
return const SizedBox(
|
return const SizedBox(
|
||||||
height: 200.0,
|
height: 200.0,
|
||||||
child: Text('BottomSheet'),
|
child: Text('BottomSheet'),
|
||||||
@ -141,7 +141,7 @@ void main() {
|
|||||||
expect(showBottomSheetThenCalled, isFalse);
|
expect(showBottomSheetThenCalled, isFalse);
|
||||||
expect(find.text('BottomSheet'), findsNothing);
|
expect(find.text('BottomSheet'), findsNothing);
|
||||||
|
|
||||||
scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
|
scaffoldKey.currentState!.showBottomSheet((BuildContext context) {
|
||||||
return const SizedBox(
|
return const SizedBox(
|
||||||
height: 200.0,
|
height: 200.0,
|
||||||
child: Text('BottomSheet'),
|
child: Text('BottomSheet'),
|
||||||
@ -178,7 +178,7 @@ void main() {
|
|||||||
expect(showBottomSheetThenCalled, isFalse);
|
expect(showBottomSheetThenCalled, isFalse);
|
||||||
expect(find.text('BottomSheet'), findsNothing);
|
expect(find.text('BottomSheet'), findsNothing);
|
||||||
|
|
||||||
scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
|
scaffoldKey.currentState!.showBottomSheet((BuildContext context) {
|
||||||
return const SizedBox(
|
return const SizedBox(
|
||||||
height: 200.0,
|
height: 200.0,
|
||||||
child: Text('BottomSheet'),
|
child: Text('BottomSheet'),
|
||||||
@ -216,7 +216,7 @@ void main() {
|
|||||||
expect(buildCount, 0);
|
expect(buildCount, 0);
|
||||||
expect(find.text('BottomSheet'), findsNothing);
|
expect(find.text('BottomSheet'), findsNothing);
|
||||||
|
|
||||||
scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
|
scaffoldKey.currentState!.showBottomSheet((BuildContext context) {
|
||||||
buildCount++;
|
buildCount++;
|
||||||
return const SizedBox(
|
return const SizedBox(
|
||||||
height: 200.0,
|
height: 200.0,
|
||||||
@ -618,7 +618,7 @@ void main() {
|
|||||||
expect(showBottomSheetThenCalled, isFalse);
|
expect(showBottomSheetThenCalled, isFalse);
|
||||||
expect(find.text('BottomSheet'), findsNothing);
|
expect(find.text('BottomSheet'), findsNothing);
|
||||||
|
|
||||||
scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
|
scaffoldKey.currentState!.showBottomSheet((BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.all(40.0),
|
margin: const EdgeInsets.all(40.0),
|
||||||
child: const Text('BottomSheet'),
|
child: const Text('BottomSheet'),
|
||||||
@ -672,7 +672,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
|
scaffoldKey.currentState!.showBottomSheet((BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.all(40.0),
|
margin: const EdgeInsets.all(40.0),
|
||||||
child: const Text('BottomSheet'),
|
child: const Text('BottomSheet'),
|
||||||
@ -1482,7 +1482,7 @@ void main() {
|
|||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
key: tapTarget,
|
key: tapTarget,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
showBottomSheet<void>(
|
showBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
// The default duration and reverseDuration is 1 second
|
// The default duration and reverseDuration is 1 second
|
||||||
transitionAnimationController: controller,
|
transitionAnimationController: controller,
|
||||||
@ -1539,7 +1539,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
scaffoldKey.currentState!.showBottomSheet<void>((_) {
|
scaffoldKey.currentState!.showBottomSheet((_) {
|
||||||
return Builder(
|
return Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return Container(height: 200.0);
|
return Container(height: 200.0);
|
||||||
@ -1553,7 +1553,7 @@ void main() {
|
|||||||
// The first sheet's animation is still running.
|
// The first sheet's animation is still running.
|
||||||
|
|
||||||
// Trigger the second sheet will remove the first sheet from tree.
|
// Trigger the second sheet will remove the first sheet from tree.
|
||||||
scaffoldKey.currentState!.showBottomSheet<void>((_) {
|
scaffoldKey.currentState!.showBottomSheet((_) {
|
||||||
return Builder(
|
return Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return Container(height: 200.0);
|
return Container(height: 200.0);
|
||||||
@ -1575,7 +1575,7 @@ void main() {
|
|||||||
// Regression test for https://github.com/flutter/flutter/issues/99627
|
// Regression test for https://github.com/flutter/flutter/issues/99627
|
||||||
testWidgetsWithLeakTracking('The old route entry should be removed when a new sheet popup', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('The old route entry should be removed when a new sheet popup', (WidgetTester tester) async {
|
||||||
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey();
|
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey();
|
||||||
PersistentBottomSheetController<void>? sheetController;
|
PersistentBottomSheetController? sheetController;
|
||||||
|
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
@ -1587,7 +1587,7 @@ void main() {
|
|||||||
final ModalRoute<dynamic> route = ModalRoute.of(scaffoldKey.currentContext!)!;
|
final ModalRoute<dynamic> route = ModalRoute.of(scaffoldKey.currentContext!)!;
|
||||||
expect(route.canPop, false);
|
expect(route.canPop, false);
|
||||||
|
|
||||||
scaffoldKey.currentState!.showBottomSheet<void>((_) {
|
scaffoldKey.currentState!.showBottomSheet((_) {
|
||||||
return Builder(
|
return Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return Container(height: 200.0);
|
return Container(height: 200.0);
|
||||||
@ -1600,7 +1600,7 @@ void main() {
|
|||||||
expect(route.canPop, true);
|
expect(route.canPop, true);
|
||||||
|
|
||||||
// Trigger the second sheet will remove the first sheet from tree.
|
// Trigger the second sheet will remove the first sheet from tree.
|
||||||
sheetController = scaffoldKey.currentState!.showBottomSheet<void>((_) {
|
sheetController = scaffoldKey.currentState!.showBottomSheet((_) {
|
||||||
return Builder(
|
return Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return Container(height: 200.0);
|
return Container(height: 200.0);
|
||||||
@ -1632,7 +1632,7 @@ void main() {
|
|||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
key: tapTarget,
|
key: tapTarget,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
showBottomSheet<void>(
|
showBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
transitionAnimationController: controller,
|
transitionAnimationController: controller,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
@ -1675,7 +1675,7 @@ void main() {
|
|||||||
|
|
||||||
testWidgetsWithLeakTracking('Calling PersistentBottomSheetController.close does not crash when it is not the current bottom sheet', (WidgetTester tester) async {
|
testWidgetsWithLeakTracking('Calling PersistentBottomSheetController.close does not crash when it is not the current bottom sheet', (WidgetTester tester) async {
|
||||||
// Regression test for https://github.com/flutter/flutter/issues/93717
|
// Regression test for https://github.com/flutter/flutter/issues/93717
|
||||||
PersistentBottomSheetController<void>? sheetController1;
|
PersistentBottomSheetController? sheetController1;
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
body: Builder(builder: (BuildContext context) {
|
body: Builder(builder: (BuildContext context) {
|
||||||
@ -1685,7 +1685,7 @@ void main() {
|
|||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
child: const Text('show 1'),
|
child: const Text('show 1'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
sheetController1 = Scaffold.of(context).showBottomSheet<void>(
|
sheetController1 = Scaffold.of(context).showBottomSheet(
|
||||||
(BuildContext context) => const Text('BottomSheet 1'),
|
(BuildContext context) => const Text('BottomSheet 1'),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -1693,7 +1693,7 @@ void main() {
|
|||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
child: const Text('show 2'),
|
child: const Text('show 2'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Scaffold.of(context).showBottomSheet<void>(
|
Scaffold.of(context).showBottomSheet(
|
||||||
(BuildContext context) => const Text('BottomSheet 2'),
|
(BuildContext context) => const Text('BottomSheet 2'),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -1914,7 +1914,7 @@ void main() {
|
|||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
child: const Text('Press me'),
|
child: const Text('Press me'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Scaffold.of(context).showBottomSheet<void>(
|
Scaffold.of(context).showBottomSheet(
|
||||||
(BuildContext context) => const Text('BottomSheet'),
|
(BuildContext context) => const Text('BottomSheet'),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -2033,7 +2033,7 @@ void main() {
|
|||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
child: const Text('Press me'),
|
child: const Text('Press me'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Scaffold.of(context).showBottomSheet<void>(
|
Scaffold.of(context).showBottomSheet(
|
||||||
(BuildContext context) => const Text('BottomSheet'),
|
(BuildContext context) => const Text('BottomSheet'),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -2102,7 +2102,7 @@ void main() {
|
|||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
child: const Text('Press me'),
|
child: const Text('Press me'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Scaffold.of(context).showBottomSheet<void>(
|
Scaffold.of(context).showBottomSheet(
|
||||||
(BuildContext context) => const Text('BottomSheet'),
|
(BuildContext context) => const Text('BottomSheet'),
|
||||||
constraints: const BoxConstraints(maxWidth: sheetMaxWidth),
|
constraints: const BoxConstraints(maxWidth: sheetMaxWidth),
|
||||||
);
|
);
|
||||||
|
@ -397,7 +397,7 @@ Widget bottomSheetWithElevations(BottomSheetThemeData bottomSheetTheme, {bool us
|
|||||||
RawMaterialButton(
|
RawMaterialButton(
|
||||||
child: const Text('Show Persistent'),
|
child: const Text('Show Persistent'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showBottomSheet<void>(
|
showBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext _) {
|
builder: (BuildContext _) {
|
||||||
return const Text(
|
return const Text(
|
||||||
|
@ -97,7 +97,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
home: Builder(
|
home: Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
showBottomSheet<void>(
|
showBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) => Container(),
|
builder: (BuildContext context) => Container(),
|
||||||
);
|
);
|
||||||
|
@ -107,7 +107,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
final PersistentBottomSheetController<void> bottomSheet = scaffoldKey.currentState!.showBottomSheet<void>((_) {
|
final PersistentBottomSheetController bottomSheet = scaffoldKey.currentState!.showBottomSheet((_) {
|
||||||
return Builder(
|
return Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
buildCount += 1;
|
buildCount += 1;
|
||||||
@ -164,7 +164,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
|
scaffoldKey.currentState!.showBottomSheet((BuildContext context) {
|
||||||
return ListView(
|
return ListView(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
primary: false,
|
primary: false,
|
||||||
@ -196,7 +196,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
|
scaffoldKey.currentState!.showBottomSheet((BuildContext context) {
|
||||||
return DraggableScrollableSheet(
|
return DraggableScrollableSheet(
|
||||||
expand: false,
|
expand: false,
|
||||||
shouldCloseOnMinExtent: false,
|
shouldCloseOnMinExtent: false,
|
||||||
@ -234,7 +234,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
|
scaffoldKey.currentState!.showBottomSheet((BuildContext context) {
|
||||||
return ListView(
|
return ListView(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
primary: false,
|
primary: false,
|
||||||
@ -269,7 +269,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
scaffoldKey.currentState!.showBottomSheet<void>(
|
scaffoldKey.currentState!.showBottomSheet(
|
||||||
(BuildContext context) {
|
(BuildContext context) {
|
||||||
return DraggableScrollableSheet(
|
return DraggableScrollableSheet(
|
||||||
expand: false,
|
expand: false,
|
||||||
@ -423,7 +423,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
scaffoldKey.currentState!.showBottomSheet<void>(
|
scaffoldKey.currentState!.showBottomSheet(
|
||||||
(BuildContext context) {
|
(BuildContext context) {
|
||||||
return DraggableScrollableSheet(
|
return DraggableScrollableSheet(
|
||||||
expand: false,
|
expand: false,
|
||||||
@ -472,7 +472,7 @@ void main() {
|
|||||||
));
|
));
|
||||||
|
|
||||||
int buildCount = 0;
|
int buildCount = 0;
|
||||||
showBottomSheet<void>(
|
showBottomSheet(
|
||||||
context: key.currentContext!,
|
context: key.currentContext!,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return Builder(
|
return Builder(
|
||||||
@ -510,7 +510,7 @@ void main() {
|
|||||||
|
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
showBottomSheet<void>(
|
showBottomSheet(
|
||||||
context: scaffoldContext,
|
context: scaffoldContext,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
bottomSheetContext = context;
|
bottomSheetContext = context;
|
||||||
@ -627,7 +627,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
|
scaffoldKey.currentState!.showBottomSheet((BuildContext context) {
|
||||||
return ListView(
|
return ListView(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
primary: false,
|
primary: false,
|
||||||
@ -657,7 +657,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
final PersistentBottomSheetController<void> bottomSheet = scaffoldKey.currentState!.showBottomSheet<void>((_) {
|
final PersistentBottomSheetController bottomSheet = scaffoldKey.currentState!.showBottomSheet((_) {
|
||||||
return Builder(
|
return Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return Container(height: 200.0);
|
return Container(height: 200.0);
|
||||||
|
@ -596,7 +596,7 @@ void main() {
|
|||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Scaffold.of(context).showBottomSheet<void>((BuildContext context) {
|
Scaffold.of(context).showBottomSheet((BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
key: sheetKey,
|
key: sheetKey,
|
||||||
color: Colors.blue[500],
|
color: Colors.blue[500],
|
||||||
@ -2173,7 +2173,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
late FlutterError error;
|
late FlutterError error;
|
||||||
try {
|
try {
|
||||||
key.currentState!.showBottomSheet<void>((BuildContext context) {
|
key.currentState!.showBottomSheet((BuildContext context) {
|
||||||
final ThemeData themeData = Theme.of(context);
|
final ThemeData themeData = Theme.of(context);
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -2234,7 +2234,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
key.currentState!.showBottomSheet<void>((_) => Container());
|
key.currentState!.showBottomSheet((_) => Container());
|
||||||
await tester.tap(find.byKey(buttonKey));
|
await tester.tap(find.byKey(buttonKey));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(errors, isNotEmpty);
|
expect(errors, isNotEmpty);
|
||||||
@ -2266,7 +2266,7 @@ void main() {
|
|||||||
MaterialApp(
|
MaterialApp(
|
||||||
home: Builder(
|
home: Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
Scaffold.of(context).showBottomSheet<void>((BuildContext context) {
|
Scaffold.of(context).showBottomSheet((BuildContext context) {
|
||||||
return Container();
|
return Container();
|
||||||
});
|
});
|
||||||
return Container();
|
return Container();
|
||||||
@ -2766,7 +2766,7 @@ void main() {
|
|||||||
final DraggableScrollableController draggableController = DraggableScrollableController();
|
final DraggableScrollableController draggableController = DraggableScrollableController();
|
||||||
addTearDown(draggableController.dispose);
|
addTearDown(draggableController.dispose);
|
||||||
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey();
|
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey();
|
||||||
PersistentBottomSheetController<void>? sheetController;
|
PersistentBottomSheetController? sheetController;
|
||||||
|
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
@ -2775,7 +2775,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
sheetController = scaffoldKey.currentState!.showBottomSheet<void>((_) {
|
sheetController = scaffoldKey.currentState!.showBottomSheet((_) {
|
||||||
return DraggableScrollableSheet(
|
return DraggableScrollableSheet(
|
||||||
expand: false,
|
expand: false,
|
||||||
controller: draggableController,
|
controller: draggableController,
|
||||||
@ -2811,7 +2811,7 @@ void main() {
|
|||||||
|
|
||||||
testWidgetsWithLeakTracking("Closing bottom sheet & removing FAB at the same time doesn't throw assertion", (WidgetTester tester) async {
|
testWidgetsWithLeakTracking("Closing bottom sheet & removing FAB at the same time doesn't throw assertion", (WidgetTester tester) async {
|
||||||
final Key bottomSheetKey = UniqueKey();
|
final Key bottomSheetKey = UniqueKey();
|
||||||
PersistentBottomSheetController<void>? controller;
|
PersistentBottomSheetController? controller;
|
||||||
bool show = true;
|
bool show = true;
|
||||||
|
|
||||||
await tester.pumpWidget(StatefulBuilder(
|
await tester.pumpWidget(StatefulBuilder(
|
||||||
|
@ -28,7 +28,7 @@ class PersistentBottomSheetTestState extends State<PersistentBottomSheetTest> {
|
|||||||
bool setStateCalled = false;
|
bool setStateCalled = false;
|
||||||
|
|
||||||
void showBottomSheet() {
|
void showBottomSheet() {
|
||||||
_scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
|
_scaffoldKey.currentState!.showBottomSheet((BuildContext context) {
|
||||||
return const Text('bottomSheet');
|
return const Text('bottomSheet');
|
||||||
})
|
})
|
||||||
.closed.whenComplete(() {
|
.closed.whenComplete(() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user