DrawerLayout class
Wraps a screen with a drawer at its directional start edge.
In DrawerLayoutMode.overlay the drawer slides over the screen behind a barrier; in DrawerLayoutMode.push the screen slides aside to reveal it. A horizontal drag anywhere inside child moves the drawer with the finger and settles open or closed on release. Opening clears the current focus, which also closes the keyboard.
Descendants reach the controller with DrawerLayout.of.
DrawerLayout(
mode: DrawerLayoutMode.push,
drawer: menu,
child: Scaffold(
appBar: AppBar(
leading: Builder(
builder: (context) => AppBarButton(
onTap: DrawerLayout.of(context).open,
child: menuIcon,
),
),
),
body: messageList,
),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- DrawerLayout
Constructors
-
DrawerLayout({Key? key, required Widget drawer, required Widget child, DrawerLayoutController? controller, ValueChanged<
bool> ? onChanged, DrawerLayoutMode mode = DrawerLayoutMode.overlay, double width = 300.0, bool enableDrag = true, double dragThreshold = 32.0, Duration duration = const Duration(milliseconds: 250), Curve curve = Curves.easeOutCubic, Color? barrierColor, RadiusToken pageRadius = RadiusToken.r4xl, List<BoxShadow> ? pageShadows, Color? backgroundColor}) -
Creates a drawer layout.
const
Properties
- backgroundColor → Color?
-
Color painted behind the whole layout in DrawerLayoutMode.push, so the
pushed screen's rounded corners reveal it rather than nothing. Defaults to
the theme's surface color.
final
- barrierColor → Color?
-
Color drawn over the screen while the drawer is open. Defaults to the
theme's backdrop color.
final
- child → Widget
-
The screen the drawer belongs to.
final
- controller → DrawerLayoutController?
-
Controls whether the drawer is open. When null the layout keeps its own.
final
- curve → Curve
-
Curve of the open and close animation. Defaults to Curves.easeOutCubic.
final
- dragThreshold → double
-
How far, from where the finger went down, a horizontal drag must travel
before the drawer starts to follow it, so small or diagonal movements
while scrolling don't nudge it. Defaults to 32.
final
- drawer → Widget
-
The panel revealed at the directional start edge.
final
- duration → Duration
-
Duration of the open and close animation. Defaults to 250 milliseconds.
final
- enableDrag → bool
-
Whether a horizontal drag inside child opens and closes the drawer.
Defaults to
true.final - hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- mode → DrawerLayoutMode
-
How the drawer is presented. Defaults to DrawerLayoutMode.overlay.
final
-
onChanged
→ ValueChanged<
bool> ? -
Called with the new state each time the drawer opens or closes.
final
- pageRadius → RadiusToken
-
Corner radius of the screen's leading edge while pushed aside. Defaults
to RadiusToken.r4xl.
final
-
pageShadows
→ List<
BoxShadow> ? -
Shadows the pushed screen casts onto the drawer. Defaults to a soft
shadow toward the drawer's edge.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- width → double
-
Width of the drawer, and how far the screen slides in
DrawerLayoutMode.push. Defaults to 300.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< DrawerLayout> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
maybeOf(
BuildContext context) → DrawerLayoutController? - The controller of the closest enclosing DrawerLayout, or null.
-
of(
BuildContext context) → DrawerLayoutController - The controller of the closest enclosing DrawerLayout.