Skip to content

Commit d3cdb27

Browse files
authored
More documentation for drawers. (flutter#6697)
Closes flutter#5781
1 parent a7debdc commit d3cdb27

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

packages/flutter/lib/src/material/drawer.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,19 @@ const Duration _kBaseSettleDuration = const Duration(milliseconds: 246);
3434
/// Typically, the child of the drawer is a [Block] whose first child is a
3535
/// [DrawerHeader] that displays status information about the current user.
3636
///
37+
/// The [Scaffold] automatically shows an appropriate [IconButton], and handles
38+
/// the edge-swipe gesture, to show the drawer.
39+
///
3740
/// See also:
3841
///
39-
/// * [Scaffold.drawer]
40-
/// * [DrawerItem]
41-
/// * [DrawerHeader]
42+
/// * [Scaffold.drawer], where one specifies a [Drawer] so that it can be
43+
/// shown.
44+
/// * [Scaffold.of], to obtain the current [ScaffoldState], which manages the
45+
/// display and animation of the drawer.
46+
/// * [ScaffoldState.openDrawer], which displays its [Drawer], if any.
47+
/// * [Navigator.pop], which closes the drawer if it is open.
48+
/// * [DrawerItem], a widget for items in drawers.
49+
/// * [DrawerHeader], a widget for the top part of a drawer.
4250
/// * <https://material.google.com/patterns/navigation-drawer.html>
4351
class Drawer extends StatelessWidget {
4452
/// Creates a material design drawer.

packages/flutter/lib/src/material/drawer_item.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class DrawerItem extends StatelessWidget {
5252
/// Called when the user taps this drawer item.
5353
///
5454
/// If null, the drawer item is displayed as disabled.
55+
///
56+
/// To close the [Drawer] when an item is pressed, call [Navigator.pop].
5557
final VoidCallback onPressed;
5658

5759
/// Whether this drawer item is currently selected.

packages/flutter/lib/src/material/scaffold.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,12 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
504504
///
505505
/// If the scaffold has a non-null [Scaffold.drawer], this function will cause
506506
/// the drawer to begin its entrance animation.
507+
///
508+
/// Normally this is not needed since the [Scaffold] automatically shows an
509+
/// appropriate [IconButton], and handles the edge-swipe gesture, to show the
510+
/// drawer.
511+
///
512+
/// To close the drawer once it is open, use [Navigator.pop].
507513
void openDrawer() {
508514
_drawerKey.currentState?.open();
509515
}

0 commit comments

Comments
 (0)