Add example to SafeArea docs (#157228)
This commit is contained in:
@@ -11,8 +11,10 @@ import 'debug.dart';
|
||||
import 'framework.dart';
|
||||
import 'media_query.dart';
|
||||
|
||||
/// A widget that insets its child by sufficient padding to avoid intrusions by
|
||||
/// the operating system.
|
||||
/// A widget that insets its child with sufficient padding to avoid intrusions
|
||||
/// by the operating system.
|
||||
///
|
||||
/// {@youtube 560 315 https://www.youtube.com/watch?v=lkF0TQJO0bA}
|
||||
///
|
||||
/// For example, this will indent the child by enough to avoid the status bar at
|
||||
/// the top of the screen.
|
||||
@@ -23,21 +25,40 @@ import 'media_query.dart';
|
||||
/// When a [minimum] padding is specified, the greater of the minimum padding
|
||||
/// or the safe area padding will be applied.
|
||||
///
|
||||
/// {@youtube 560 315 https://www.youtube.com/watch?v=lkF0TQJO0bA}
|
||||
/// {@tool snippet}
|
||||
///
|
||||
/// This example creates a blue box containing text that is sufficiently padded
|
||||
/// to avoid instrusions by the operating system.
|
||||
///
|
||||
/// ```dart
|
||||
/// SafeArea(
|
||||
/// child: Container(
|
||||
/// constraints: const BoxConstraints.expand(),
|
||||
/// alignment: Alignment.center,
|
||||
/// color: Colors.blue,
|
||||
/// child: const Text('Hello, World!'),
|
||||
/// ),
|
||||
/// )
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
///
|
||||
/// ### [MediaQuery] impact
|
||||
///
|
||||
/// The padding on the [MediaQuery] for the [child] will be suitably adjusted
|
||||
/// to zero out any sides that were avoided by this widget.
|
||||
///
|
||||
/// {@youtube 560 315 https://www.youtube.com/watch?v=ceCo8U0XHqw}
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [SliverSafeArea], for insetting slivers to avoid operating system
|
||||
/// intrusions.
|
||||
/// * [Padding], for insetting widgets in general.
|
||||
/// * [MediaQuery], from which the window padding is obtained.
|
||||
/// * [MediaQuery], from which the view padding is obtained.
|
||||
/// * [dart:ui.FlutterView.padding], which reports the padding from the operating
|
||||
/// system.
|
||||
class SafeArea extends StatelessWidget {
|
||||
/// Creates a widget that avoids operating system interfaces.
|
||||
///
|
||||
/// The [left], [top], [right], [bottom], and [minimum] arguments must not be
|
||||
/// null.
|
||||
const SafeArea({
|
||||
super.key,
|
||||
this.left = true,
|
||||
|
||||
Reference in New Issue
Block a user