mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
parent
322dd06d6e
commit
333397a0ed
@ -6,27 +6,24 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
void main() => runApp(const MyApp());
|
void main() => runApp(const BottomSheetApp());
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class BottomSheetApp extends StatelessWidget {
|
||||||
const MyApp({super.key});
|
const BottomSheetApp({super.key});
|
||||||
|
|
||||||
static const String _title = 'Flutter Code Sample';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: _title,
|
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
appBar: AppBar(title: const Text(_title)),
|
appBar: AppBar(title: const Text('Bottom Sheet Sample')),
|
||||||
body: const MyStatelessWidget(),
|
body: const BottomSheetExample(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyStatelessWidget extends StatelessWidget {
|
class BottomSheetExample extends StatelessWidget {
|
||||||
const MyStatelessWidget({super.key});
|
const BottomSheetExample({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -2,30 +2,32 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// Flutter code sample for Material Design 3 TextFields.
|
|
||||||
/// Flutter code sample for [showModalBottomSheet].
|
/// Flutter code sample for [showModalBottomSheet].
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
void main() => runApp(const MyApp());
|
void main() => runApp(const BottomSheetApp());
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class BottomSheetApp extends StatelessWidget {
|
||||||
const MyApp({super.key});
|
const BottomSheetApp({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true),
|
theme: ThemeData(
|
||||||
|
colorSchemeSeed: const Color(0xff6750a4),
|
||||||
|
useMaterial3: true,
|
||||||
|
),
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
appBar: AppBar(title: const Text('Bottom Sheet Sample')),
|
appBar: AppBar(title: const Text('Bottom Sheet Sample')),
|
||||||
body: const MyStatelessWidget(),
|
body: const BottomSheetExample(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyStatelessWidget extends StatelessWidget {
|
class BottomSheetExample extends StatelessWidget {
|
||||||
const MyStatelessWidget({super.key});
|
const BottomSheetExample({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_api_samples/material/bottom_sheet/show_modal_bottom_sheet.0.dart' as example;
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('BottomSheet can be opened and closed', (WidgetTester tester) async {
|
||||||
|
const String titleText = 'Modal BottomSheet';
|
||||||
|
const String closeText = 'Close BottomSheet';
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
const example.BottomSheetApp(),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(find.text(titleText), findsNothing);
|
||||||
|
expect(find.text(closeText), findsNothing);
|
||||||
|
|
||||||
|
// Open the bottom sheet.
|
||||||
|
await tester.tap(find.widgetWithText(ElevatedButton, 'showModalBottomSheet'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
// Verify that the bottom sheet is open.
|
||||||
|
expect(find.text(titleText), findsOneWidget);
|
||||||
|
expect(find.text(closeText), findsOneWidget);
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_api_samples/material/bottom_sheet/show_modal_bottom_sheet.1.dart' as example;
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('BottomSheet can be opened and closed', (WidgetTester tester) async {
|
||||||
|
const String titleText = 'Modal BottomSheet';
|
||||||
|
const String closeText = 'Close BottomSheet';
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
const example.BottomSheetApp(),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(find.text(titleText), findsNothing);
|
||||||
|
expect(find.text(closeText), findsNothing);
|
||||||
|
|
||||||
|
// Open the bottom sheet.
|
||||||
|
await tester.tap(find.widgetWithText(ElevatedButton, 'showModalBottomSheet'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
// Verify that the bottom sheet is open.
|
||||||
|
expect(find.text(titleText), findsOneWidget);
|
||||||
|
expect(find.text(closeText), findsOneWidget);
|
||||||
|
});
|
||||||
|
}
|
@ -799,6 +799,13 @@ class _BottomSheetSuspendedCurve extends ParametricCurve<double> {
|
|||||||
/// ** See code in examples/api/lib/material/bottom_sheet/show_modal_bottom_sheet.0.dart **
|
/// ** See code in examples/api/lib/material/bottom_sheet/show_modal_bottom_sheet.0.dart **
|
||||||
/// {@end-tool}
|
/// {@end-tool}
|
||||||
///
|
///
|
||||||
|
/// {@tool dartpad}
|
||||||
|
/// This sample shows the creation of [showModalBottomSheet], as described in:
|
||||||
|
/// https://m3.material.io/components/bottom-sheets/overview
|
||||||
|
///
|
||||||
|
/// ** See code in examples/api/lib/material/bottom_sheet/show_modal_bottom_sheet.1.dart **
|
||||||
|
/// {@end-tool}
|
||||||
|
///
|
||||||
/// See also:
|
/// See also:
|
||||||
///
|
///
|
||||||
/// * [BottomSheet], which becomes the parent of the widget returned by the
|
/// * [BottomSheet], which becomes the parent of the widget returned by the
|
||||||
|
Loading…
Reference in New Issue
Block a user