Флаттер ящик фоновое изображение - PullRequest
0 голосов
/ 16 июня 2019

Интересно, смогу ли я использовать фоновое изображение вместо цвета в заголовке ящика приложения?цвет с пользовательским изображением.

1 Ответ

0 голосов
/ 16 июня 2019

Вы можете использовать оформление в DrawerHeader для установки изображения в качестве заголовка ящика

  return Scaffold(
      appBar: AppBar(title: Text(title)),
      body: Center(child: Text('some text')),
      drawer: Drawer(
        // Add a ListView to the drawer. This ensures the user can scroll
        // through the options in the drawer if there isn't enough vertical
        // space to fit everything.
        child: ListView(
          // Important: Remove any padding from the ListView.
          padding: EdgeInsets.zero,
          children: <Widget>[
            DrawerHeader(
              child: Text('Drawer Header'),
              decoration: BoxDecoration(
                color: Colors.blue,
                image: DecorationImage(
                  image: AssetImage("assets/gold.jpg"),
                     fit: BoxFit.cover)
              ),
            ),
            ListTile(
              title: Text('Item 1'),
              onTap: () {
                // Update the state of the app
                // ...
                // Then close the drawer
                Navigator.pop(context);
              },
            ),
            ListTile(
              title: Text('Item 2'),
              onTap: () {
                // Update the state of the app
                // ...
                // Then close the drawer
                Navigator.pop(context);
              },
            ),
          ],
        ),
      ),
    );

также смотрите эту ссылку

enter image description here

...