aves_mio1/.flutter/examples/api/lib/cupertino/sheet/cupertino_sheet.1.dart
FabioMich66 19a982ede6
Some checks are pending
Quality check / Flutter analysis (push) Waiting to run
Quality check / CodeQL analysis (java-kotlin) (push) Waiting to run
first commit
2026-03-05 15:51:30 +01:00

124 lines
3.2 KiB
Dart

// 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/cupertino.dart';
/// Flutter code sample for [showCupertinoSheet].
void main() {
runApp(const CupertinoSheetApp());
}
class CupertinoSheetApp extends StatelessWidget {
const CupertinoSheetApp({super.key});
@override
Widget build(BuildContext context) {
return const CupertinoApp(title: 'Cupertino Sheet', home: HomePage());
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: Text('Sheet Example'),
automaticBackgroundVisibility: false,
),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
CupertinoButton.filled(
onPressed: () {
showCupertinoSheet<void>(
context: context,
useNestedNavigation: true,
builder: (BuildContext context) => const _SheetScaffold(),
);
},
child: const Text('Open Bottom Sheet'),
),
],
),
),
);
}
}
class _SheetScaffold extends StatelessWidget {
const _SheetScaffold();
@override
Widget build(BuildContext context) {
return const CupertinoPageScaffold(
child: _SheetBody(title: 'CupertinoSheetRoute'),
);
}
}
class _SheetBody extends StatelessWidget {
const _SheetBody({required this.title});
final String title;
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(title),
CupertinoButton.filled(
onPressed: () {
Navigator.of(context).maybePop();
},
child: const Text('Go Back'),
),
CupertinoButton.filled(
onPressed: () {
CupertinoSheetRoute.popSheet(context);
},
child: const Text('Pop Whole Sheet'),
),
CupertinoButton.filled(
onPressed: () {
Navigator.of(context).push(
CupertinoPageRoute<void>(
builder: (BuildContext context) => const _SheetNextPage(),
),
);
},
child: const Text('Push Nested Page'),
),
CupertinoButton.filled(
onPressed: () {
showCupertinoSheet<void>(
context: context,
useNestedNavigation: true,
builder: (BuildContext context) => const _SheetScaffold(),
);
},
child: const Text('Push Another Sheet'),
),
],
),
);
}
}
class _SheetNextPage extends StatelessWidget {
const _SheetNextPage();
@override
Widget build(BuildContext context) {
return const CupertinoPageScaffold(
backgroundColor: CupertinoColors.activeOrange,
child: _SheetBody(title: 'Next Page'),
);
}
}