drawer static method

Drawer drawer(
  1. BuildContext context, {
  2. DrawerDelegate delegate = const DrawerChildListDelegate(children: []),
  3. Color? backgroundColor,
  4. double? width,
  5. double? elevation,
  6. ShapeBorder? shape,
})

标准Drawer创建

  • 包含头部信息。
  • 包含菜单项(关于,帮助)。
  • 包含版本标注(Footer)。
  • 包含背景(Coming soon)

Implementation

static Drawer drawer(
  BuildContext context, {
  DrawerDelegate delegate = const DrawerChildListDelegate(children: []),
  Color? backgroundColor,
  double? width,
  double? elevation,
  ShapeBorder? shape,
}) {
  Widget _builderHeader() {
    return delegate.buildHeader() ?? Container();
  }

  List<Widget> _buildList(BuildContext context) {
    return delegate.buildList(context);
  }

  Widget _buildFooter() {
    return delegate.buildFooter() ?? Container();
  }

  return Drawer(
    backgroundColor: backgroundColor,
    elevation: elevation,
    width: width,
    shape: shape,
    child: Column(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        // header
        _builderHeader(),
        // list buttons
        Expanded(
          child: ListView(
            children: _buildList(context),
          ),
        ),
        // footer
        _buildFooter(),
      ],
    ),
  );
}