Правильный способ поместить ящик в нижней части панели приложений

#flutter #dart

#flutter #dart

Вопрос:

Итак, вот как я это делаю

 Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Image.asset(
          'assets/images/logo.png',
          height: 20.0,
        ),
        leading: InkWell(
          onTap: () {
            //do something here
          },
          child: Icon(
            Icons.menu,
          ),
        ),
        backgroundColor: Colors.red,
      ),
      body: SafeArea(
        child: RefreshIndicator(
            child: Column(
                       ...
        ),
      drawer: Padding(
        padding: const EdgeInsets.only(top:89), // I've added this so that I can test it
        child: Drawer(
          child: ListView(
            padding: EdgeInsets.zero,
            children: <Widget>[
              ListTile(
                title: Text('Item 1'),
                onTap: () {
                },
              ),
              ListTile(
                title: Text('Item 2'),
                onTap: () {
                },
              ),
       ...
 

Я добавил отступ padding: const EdgeInsets.only(top:89) , но панель приложений по-прежнему выглядит прозрачной, когда ящик открыт.

Каков наилучший способ обойти это? Нужно ли мне поместить ящик в другое место, или это простое решение?

Комментарии:

1. не могли бы вы добавить скриншот того, что вы получаете сейчас?

2. i.imgur.com/LmAGDYZ.png

Ответ №1:

Для того, чтобы увидеть AppBar без прозрачного вида, вам нужно установить значение drawerScrimColor в Colors.transparent пределах Scaffold . Что-то вроде этого:

 Widget build(BuildContext context) {
    return Scaffold(
      
      ... // other lines

      drawerScrimColor: Colors.transparent, // Set the color to transparent here
      drawer: Padding(
     
      ... // other lines
 

Ответ №2:

 @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(),
        drawer: SafeArea(
            child: Drawer(
                child: Column(children: <Widget>[
                  UserAccountsDrawerHeader(
                    margin: EdgeInsets.only(bottom: 3.0),
                    onDetailsPressed: () {},
                    currentAccountPicture: CircleAvatar(
                      radius: 30,
                      child: Icon(Icons.person, size: 60,),
                    ),
                    accountName: Text("Name",),
                    accountEmail: Text("Email Id",),
                  ),
                  ListTile(
                    leading: Icon(Icons.home,size: 20,),
                    title: Text('Home'),
                    trailing: Icon(Icons.arrow_forward_ios),
                    onTap: () {},
                  ),
                ])
            )
        ),
      body: Container(),
    );
}