Display a Cupertino sheet
How to implement a Cupertino sheet to display messages and content.
A Cupertino sheet is an iOS-style modal bottom sheet used to present content or options. It slides up from the bottom of the screen and can be pulled down to dismiss.
In Flutter, this is the job of showCupertinoSheet.
This recipe implements a Cupertino sheet using the following steps:
- Create a
CupertinoApporMaterialApp. - Display the sheet content.
1. Create a CupertinoApp
#
When creating apps that follow the iOS design guidelines,
you can use CupertinoApp.
The following example provides a button in the center of the screen
that triggers the modal.
class CupertinoSheetDemo extends StatelessWidget {
const CupertinoSheetDemo({super.key});
@override
Widget build(BuildContext context) {
return const CupertinoApp(
title: 'CupertinoSheet Demo',
home: CupertinoSheetPage(),
);
}
}
2. Display the sheet content
#
With the basic app structure in place, display the sheet.
To show it, call showCupertinoSheet and provide a scrollableBuilder
that returns the content for the sheet, such as a SingleChildScrollView.
showCupertinoSheet(
context: context,
scrollableBuilder: (context, scrollController) {
return SingleChildScrollView(
controller: scrollController,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const SizedBox(height: 100),
const Text('This is a Cupertino sheet'),
const SizedBox(height: 20),
CupertinoButton(
child: const Text('Close'),
onPressed: () {
Navigator.pop(context);
},
),
],
),
),
);
},
);
Interactive example
#import 'package:flutter/cupertino.dart';
void main() => runApp(const CupertinoSheetDemo());
class CupertinoSheetDemo extends StatelessWidget {
const CupertinoSheetDemo({super.key});
@override
Widget build(BuildContext context) {
return const CupertinoApp(
title: 'CupertinoSheet Demo',
home: CupertinoSheetPage(),
);
}
}
class CupertinoSheetPage extends StatelessWidget {
const CupertinoSheetPage({super.key});
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: Text('CupertinoSheet Demo'),
),
child: Center(
child: CupertinoButton.filled(
onPressed: () {
showCupertinoSheet(
context: context,
scrollableBuilder: (context, scrollController) {
return SingleChildScrollView(
controller: scrollController,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const SizedBox(height: 100),
const Text('This is a Cupertino sheet'),
const SizedBox(height: 20),
CupertinoButton(
child: const Text('Close'),
onPressed: () {
Navigator.pop(context);
},
),
],
),
),
);
},
);
},
child: const Text('Show Sheet'),
),
),
);
}
}
除非另有说明,本文档之所提及适用于 Flutter 3.41.5 版本。本页面最后更新时间:2026-03-26。查看文档源码 或者 为本页面内容提出建议。