抽屉颤抖

时间:2020-08-03 01:09:34

标签: flutter flutter-layout

如何使菜单图标可单击,以便在单击汉堡菜单图标时可以打开抽屉?我在一个单独的dart文件中制作了抽屉,以便可以将其用作其他多个页面中的可重用组件。这是带有菜单图标的应用栏的设计,我希望从中调用抽屉:Image of the appbar with menu and search icon。感谢您阅读这篇冗长的文章:)

这是我的appbar代码:

    class Bar extends StatelessWidget {
  Widget appBar(String text) {
    return PreferredSize(
        child: Container(
          color: Colors.white,
          padding: EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              SvgPicture.asset('assets/menu.svg'),
              Text(
                text,
                style: TextStyle(fontWeight: FontWeight.bold),
              ),
              SvgPicture.asset('assets/search.svg')
            ],
          ),
        ),
        preferredSize: Size.fromHeight(40));
  }

  @override
  Widget build(BuildContext context) {
    return Bar();
  }
}

这是我的抽屉代码的一部分,我在主抽屉内构造了一个自定义小部件:

    class MainDrawer extends StatelessWidget {
  Widget drawerTiles(String tileIcon, String tileText, IconData tileRightIcon) {
    return Padding(
      padding:
          const EdgeInsets.only(top: 8.0, left: 16, right: 32.0, bottom: 8.0),
      child: Row(
        children: <Widget>[
          CircleAvatar(
            radius: 14,
            backgroundColor: Hexcolor('#0565ac'),
            child: Padding(
              padding: EdgeInsets.all(0),
              child: SvgPicture.asset(tileIcon),
            ),
          ),
          SizedBox(
            width: 16,
          ),
          Text(
            tileText,
            style: TextStyle(
                fontSize: 12, fontWeight: FontWeight.w600, color: Colors.black),
          ),
          Spacer(),
          Icon(tileRightIcon)
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Drawer(

0 个答案:

没有答案