DrawerManager class

A drawer container that has the ability to swap Scaffold body contents, using a custom provider.

A Drawer Manager is similar to the Android Drawer, in that it swaps out Widgets (like Android Fragments). It does this by notifying the Scaffold body of the changes needed for your selection using the DrawerManagerProvider's body property.

Similar to Flutter's TextEditingController, the Drawer Manager uses Provider's ChangeNotifier as a parent class to manage user selection by displaying the Widget selection. This happens in the DrawerManagerProvider.selectDrawer method, and it basically returns from a list of onTap functions the position that was tapped. Then it uses that positin to set the current drawer selection, and notifies the Drawer Manager's body property and any other Consumers to make the update for this drawer selection.

The selections can be more than the Drawer Tiles, but the tiles can not be more than the selections.


   const drawerSelections = [
     HelloPage(),
     CounterPage(),
     TheMACPage()
   ];

Here is an example of a DrawerManager with drawerElements and drawerSelections added.


    drawer: DrawerManager(
        context: context,
        drawerElements: [
            const DrawerHeader(
                child: Padding(
                    padding: EdgeInsets.only(bottom: 20),
                    child: Icon(Icons.account_circle),
                ),
            ),
            DrawerTile(
                context: context,
                leading: const Icon(Icons.hail_rounded),
                title: Text('Hello'),
                onTap: () async {
                    // RUN A BACKEND Hello, Flutter OPERATION
                },
            ),
            // ...
        ],
        tileSelections: drawerSelections
    )

Inheritance

Constructors

DrawerManager(BuildContext context, {Key? key, Color? backgroundColor, double? elevation, ShapeBorder? shape, Widget? child, String? semanticLabel, List<Widget>? drawerElements, required List<Widget> tileSelections})

Properties

backgroundColor Color?
Sets the color of the Material that holds all of the Drawer's contents.
final
child Widget?
The widget below this widget in the tree.
getter/setter pair
dmProvider DrawerManagerProvider
The provider that manages the widget presentation.
getter/setter pair
drawerElements List<Widget>?
The widget list that is selected from to view in the app body.
final
elevation double?
The z-coordinate at which to place this 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
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
semanticLabel String?
The semantic label of the dialog used by accessibility frameworks to announce screen transitions when the drawer is opened and closed.
final
shape ShapeBorder?
The shape of the drawer.
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
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}) 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