颤振:导航抽屉和扩展瓷砖

马里

我正在尝试构建带有扩展图块的导航抽屉,当我单击标题时它会折叠,反之亦然,但是当我将抽屉标题设置为ExpansionTile的子项时,原始标题填充会丢失

在此处输入图片说明

 Widget _buildDrawer() {
return Drawer(
    child: ExpansionTile(
  title: UserAccountsDrawerHeader(
    decoration: BoxDecoration(color: Colors.deepPurple),
    accountName: Text("Mohamed Ali"),
    accountEmail: Text("[email protected]"),
    currentAccountPicture: CircleAvatar(
      child: Text("M"),
      backgroundColor: Colors.white,
    ),
  ),
  children: <Widget>[
    ListTile(
      title: Text("page one"),
      trailing: Icon(Icons.android),
      onTap: () => _onSelectedItem(0),
    ),
    ListTile(
      title: Text("page two"),
      trailing: Icon(Icons.accessible),
      onTap: () => _onSelectedItem(1),
    ),
    Divider(),
    ListTile(
      title: Text("Log out"),
      trailing: Icon(Icons.exit_to_app),
    ),
  ],
  initiallyExpanded: false,
)

); }

化学am

问题在于标头会取代中的第一个图块ExpansionTile

一种可能的解决方案是使用aStack用a调整内容,Align以便扩展图标位于标题的底部。

更改展开图标的颜色可能对您不起作用。这里有一个报道的问题,我已经在这里提交了一份PR不知道什么时候会落入主人。

_buildDrawer(BuildContext context) {
  ThemeData theme = Theme.of(context);
  return Drawer(
    child: Stack(
      children: <Widget>[
        UserAccountsDrawerHeader(
          decoration: BoxDecoration(color: Colors.indigo),
        ),
        Positioned(
          top: 120.0,
          left: 0.0,
          right: 0.0,
          child: Theme(
            data: theme.copyWith(
              textTheme: theme.textTheme.copyWith(
                subhead: theme.textTheme.subhead.copyWith(
                  color: Colors.grey,
                ),
              ),
              accentColor: Colors.white,
              unselectedWidgetColor: Colors.grey,
              iconTheme: theme.iconTheme.copyWith(color: Colors.white),
              dividerColor: Colors.transparent,
            ),
            child: ExpansionTile(
              title: Align(
                heightFactor: 0.4,
                alignment: Alignment.bottomCenter,
                child: UserAccountsDrawerHeader(
                  decoration: BoxDecoration(color: Colors.transparent),
                  accountName: Text("Mohamed Ali"),
                  accountEmail: Text("[email protected]"),
                  currentAccountPicture: CircleAvatar(
                    child: Text("M"),
                    backgroundColor: Colors.white,
                  ),
                ),
              ),
              children: <Widget>[
                ListTile(
                  title: Text("page one"),
                  trailing: Icon(Icons.android),
                  onTap: () => {},
                ),
                ListTile(
                  title: Text("page two"),
                  trailing: Icon(Icons.accessible),
                  onTap: () => {},
                ),
                Container(
                  height: 1.0,
                  color: Color(0xFFDDDDDD),
                ),
                ListTile(
                  title: Text("Log out"),
                  trailing: Icon(Icons.exit_to_app),
                ),
              ],
              initiallyExpanded: false,
            ),
          ),
        ),
      ],
    ),
  )
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章