mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
84 lines
2.4 KiB
Dart
84 lines
2.4 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/material.dart';
|
|
|
|
/// Flutter code sample for [PopupRoute].
|
|
|
|
void main() => runApp(const PopupRouteApp());
|
|
|
|
class PopupRouteApp extends StatelessWidget {
|
|
const PopupRouteApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return const MaterialApp(home: PopupRouteExample());
|
|
}
|
|
}
|
|
|
|
class PopupRouteExample extends StatelessWidget {
|
|
const PopupRouteExample({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Center(
|
|
child: OutlinedButton(
|
|
onPressed: () {
|
|
// This shows a dismissible dialog.
|
|
Navigator.of(context).push(DismissibleDialog<void>());
|
|
},
|
|
child: const Text('Open DismissibleDialog'),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class DismissibleDialog<T> extends PopupRoute<T> {
|
|
@override
|
|
Color? get barrierColor => Colors.black.withAlpha(0x50);
|
|
|
|
// This allows the popup to be dismissed by tapping the scrim or by pressing
|
|
// the escape key on the keyboard.
|
|
@override
|
|
bool get barrierDismissible => true;
|
|
|
|
@override
|
|
String? get barrierLabel => 'Dismissible Dialog';
|
|
|
|
@override
|
|
Duration get transitionDuration => const Duration(milliseconds: 300);
|
|
|
|
@override
|
|
Widget buildPage(
|
|
BuildContext context,
|
|
Animation<double> animation,
|
|
Animation<double> secondaryAnimation,
|
|
) {
|
|
return Center(
|
|
// Provide DefaultTextStyle to ensure that the dialog's text style
|
|
// matches the rest of the text in the app.
|
|
child: DefaultTextStyle(
|
|
style: Theme.of(context).textTheme.bodyMedium!,
|
|
// UnconstrainedBox is used to make the dialog size itself
|
|
// to fit to the size of the content.
|
|
child: UnconstrainedBox(
|
|
child: Container(
|
|
padding: const EdgeInsets.all(20.0),
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: Colors.white),
|
|
child: Column(
|
|
children: <Widget>[
|
|
Text('Dismissible Dialog', style: Theme.of(context).textTheme.headlineSmall),
|
|
const SizedBox(height: 20),
|
|
const Text('Tap in the scrim or press escape key to dismiss.'),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|