| // Copyright 2014 The Flutter Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| // Flutter code sample for Material Design 3 TextFields. |
| /// Flutter code sample for [showModalBottomSheet]. |
| |
| import 'package:flutter/material.dart'; |
| |
| void main() => runApp(const MyApp()); |
| |
| class MyApp extends StatelessWidget { |
| const MyApp({super.key}); |
| |
| @override |
| Widget build(BuildContext context) { |
| return MaterialApp( |
| theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true), |
| home: Scaffold( |
| appBar: AppBar(title: const Text('Bottom Sheet Sample')), |
| body: const MyStatelessWidget(), |
| ), |
| ); |
| } |
| } |
| |
| class MyStatelessWidget extends StatelessWidget { |
| const MyStatelessWidget({super.key}); |
| |
| @override |
| Widget build(BuildContext context) { |
| return Center( |
| child: ElevatedButton( |
| child: const Text('showModalBottomSheet'), |
| onPressed: () { |
| showModalBottomSheet<void>( |
| context: context, |
| builder: (BuildContext context) { |
| return SizedBox( |
| height: 200, |
| child: Center( |
| child: Column( |
| mainAxisAlignment: MainAxisAlignment.center, |
| mainAxisSize: MainAxisSize.min, |
| children: <Widget>[ |
| const Text('Modal BottomSheet'), |
| ElevatedButton( |
| child: const Text('Close BottomSheet'), |
| onPressed: () => Navigator.pop(context), |
| ), |
| ], |
| ), |
| ), |
| ); |
| }, |
| ); |
| }, |
| ), |
| ); |
| } |
| } |