NxCustomDrawer class
A customizable drawer widget with support for navigation options and sign-out functionality.
This widget extends Flutter's Drawer with additional features:
- Configurable navigation options with icons
- Optional sign-out button at the bottom
- Customizable header (defaults to "Menu")
- Theme-aware styling with customization options
- Optional Sequrify branding button
The drawer automatically handles navigation state and closing when an option is selected.
Example usage:
NxCustomDrawer(
drawerOptions: {
['Profile', Icon(Icons.person_outline)]: () {
// Handle profile navigation
},
['Settings', Icon(Icons.settings_outline)]: () {
// Handle settings navigation
},
},
withSignOutOption: true,
signOutFunction: () {
// Handle sign out
},
backgroundColor: Colors.white,
optionTextStyle: TextStyle(fontSize: 16),
)
The drawer options are specified using a map where:
- The key is a list containing the option text and an optional icon
- The value is a callback function executed when the option is tapped
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- NxCustomDrawer
Constructors
-
NxCustomDrawer.new({required Map<
List, dynamic Function()> drawerOptions, Key? key, EdgeInsets? padding, DrawerHeader? drawerHeader, TextStyle? optionTextStyle, bool withSignOutOption = true, dynamic signOutFunction()?, TextStyle? signOutTextStyle, Widget? signOutIcon, Widget? sequrifyButton, Color? backgroundColor, double? drawerWidth, double? elevation}) -
Creates a custom drawer with navigation options.
const
Properties
- backgroundColor → Color?
-
Background color of the drawer.
final
- drawerHeader → DrawerHeader?
-
Custom header widget shown at the top of the drawer.
final
-
drawerOptions
→ Map<
List, dynamic Function()> -
Map of navigation options and their callbacks.
final
- drawerWidth → double?
-
Width of the drawer.
final
- elevation → double?
-
Z-coordinate at which to place the drawer relative to its parent.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- optionTextStyle → TextStyle?
-
Text style for the navigation options.
final
- padding → EdgeInsets?
-
Padding around the drawer content.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sequrifyButton → Widget?
-
Optional widget shown at the bottom of the drawer.
final
- signOutFunction → dynamic Function()?
-
Callback function executed when sign out is tapped.
final
- signOutIcon → Widget?
-
Custom icon widget for the sign out option.
final
- signOutTextStyle → TextStyle?
-
Text style for the sign out option.
final
- withSignOutOption → bool
-
Whether to show the sign out option at the bottom.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
buildDrawerOption(
{required BuildContext context, required String text, TextStyle? textStyle, Widget? icon}) → Widget - Builds a single drawer option with text and optional icon.
-
buildSignOutOption(
{required BuildContext context, required dynamic signOutFunction(), Widget? icon, TextStyle? signOutTextStyle}) → Widget - Builds the sign out option with a divider and custom styling.
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
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