Commit d3cdb270 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

More documentation for drawers. (#6697)

Closes https://github.com/flutter/flutter/issues/5781
parent a7debdc7
...@@ -34,11 +34,19 @@ const Duration _kBaseSettleDuration = const Duration(milliseconds: 246); ...@@ -34,11 +34,19 @@ const Duration _kBaseSettleDuration = const Duration(milliseconds: 246);
/// Typically, the child of the drawer is a [Block] whose first child is a /// Typically, the child of the drawer is a [Block] whose first child is a
/// [DrawerHeader] that displays status information about the current user. /// [DrawerHeader] that displays status information about the current user.
/// ///
/// The [Scaffold] automatically shows an appropriate [IconButton], and handles
/// the edge-swipe gesture, to show the drawer.
///
/// See also: /// See also:
/// ///
/// * [Scaffold.drawer] /// * [Scaffold.drawer], where one specifies a [Drawer] so that it can be
/// * [DrawerItem] /// shown.
/// * [DrawerHeader] /// * [Scaffold.of], to obtain the current [ScaffoldState], which manages the
/// display and animation of the drawer.
/// * [ScaffoldState.openDrawer], which displays its [Drawer], if any.
/// * [Navigator.pop], which closes the drawer if it is open.
/// * [DrawerItem], a widget for items in drawers.
/// * [DrawerHeader], a widget for the top part of a drawer.
/// * <https://material.google.com/patterns/navigation-drawer.html> /// * <https://material.google.com/patterns/navigation-drawer.html>
class Drawer extends StatelessWidget { class Drawer extends StatelessWidget {
/// Creates a material design drawer. /// Creates a material design drawer.
......
...@@ -52,6 +52,8 @@ class DrawerItem extends StatelessWidget { ...@@ -52,6 +52,8 @@ class DrawerItem extends StatelessWidget {
/// Called when the user taps this drawer item. /// Called when the user taps this drawer item.
/// ///
/// If null, the drawer item is displayed as disabled. /// If null, the drawer item is displayed as disabled.
///
/// To close the [Drawer] when an item is pressed, call [Navigator.pop].
final VoidCallback onPressed; final VoidCallback onPressed;
/// Whether this drawer item is currently selected. /// Whether this drawer item is currently selected.
......
...@@ -504,6 +504,12 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin { ...@@ -504,6 +504,12 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
/// ///
/// If the scaffold has a non-null [Scaffold.drawer], this function will cause /// If the scaffold has a non-null [Scaffold.drawer], this function will cause
/// the drawer to begin its entrance animation. /// the drawer to begin its entrance animation.
///
/// Normally this is not needed since the [Scaffold] automatically shows an
/// appropriate [IconButton], and handles the edge-swipe gesture, to show the
/// drawer.
///
/// To close the drawer once it is open, use [Navigator.pop].
void openDrawer() { void openDrawer() {
_drawerKey.currentState?.open(); _drawerKey.currentState?.open();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment