Flutter 抽屉是透明的

Flutter 抽屉是透明的,flutter,Flutter,抽屉的背景是透明的。我曾尝试重新热加载我从头开始编写的整个代码,但没有成功 drawer: ListView( children: <Widget>[ DrawerHeader( padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 100.0), child: Text('Hi!'),

抽屉的背景是透明的。我曾尝试重新热加载我从头开始编写的整个代码,但没有成功

drawer: ListView(
        children: <Widget>[
          DrawerHeader(
            padding:
                EdgeInsets.symmetric(vertical: 20.0, horizontal: 100.0),
            child: Text('Hi!'),
            curve: Curves.easeInCubic,
          ),
          ListTile(
            contentPadding: EdgeInsets.all(100.0),
            leading: Icon(Icons.home),
            trailing: Icon(Icons.donut_small),
            title: Text(
              'Home',
              style: TextStyle(color: Colors.white),
            ),
          )
        ],
      ),
参考图像

您应该使用抽屉小部件作为ListView的父级

此处的更多信息:

您应该使用抽屉小部件作为ListView的父级

此处的详细信息:

您不正确地使用了抽屉阅读器。抽屉阅读器只是要打开的抽屉的顶部部分。您应该使用它来设置抽屉的标题,可能还有不同的背景色。 请尝试以下方法:

         Drawer(
          child: ListView(
            children: <Widget>[
              DrawerHeader(
                padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 100.0),
                child: Text('Hi!'),
                curve: Curves.easeInCubic,
              ),
              ListTile(
                contentPadding: EdgeInsets.all(100.0),
                leading: Icon(Icons.home),
                trailing: Icon(Icons.donut_small),
                title: Text(
                  'Home',
                  style: TextStyle(color: Colors.white),
                ),
              )
            ],
          ),
        ),
您正在错误地使用抽屉阅读器。抽屉阅读器只是要打开的抽屉的顶部部分。您应该使用它来设置抽屉的标题,可能还有不同的背景色。 请尝试以下方法:

         Drawer(
          child: ListView(
            children: <Widget>[
              DrawerHeader(
                padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 100.0),
                child: Text('Hi!'),
                curve: Curves.easeInCubic,
              ),
              ListTile(
                contentPadding: EdgeInsets.all(100.0),
                leading: Icon(Icons.home),
                trailing: Icon(Icons.donut_small),
                title: Text(
                  'Home',
                  style: TextStyle(color: Colors.white),
                ),
              )
            ],
          ),
        ),