Выровняйте контейнер по кнопке в столбце внизу экрана. - PullRequest
0 голосов
/ 26 апреля 2020

Мой код:

return Scaffold(
  drawer: Drawer(),
  backgroundColor: Color(0xFFF6F4F2),
  body: Column(
    children: <Widget>[
      Container(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Image.asset(
              'images/emblem.png',
              height: 80,
            ),
            SizedBox(
              width: 20,
            ),
            Text(
              'Connect',
              style: TextStyle(color: Colors.white, fontSize: 40),
            ),
          ],
        ),
        height: 120,
        width: 1000,
        decoration: BoxDecoration(
            gradient: LinearGradient(
              colors: _colors,
              stops: _stops,
            ),
            borderRadius: BorderRadius.only(
              bottomLeft: Radius.circular(100),
              bottomRight: Radius.circular(100),
            )),
      ),
      Column(
        mainAxisAlignment: MainAxisAlignment.start,
        children: <Widget>[
          AltButton(
            label: 'Contacts',
            icon: FontAwesomeIcons.phone,
            routeString: ContactsScreen.id,
          ),
          AltButton(
            label: 'CGHS Codes',
            icon: FontAwesomeIcons.calculator,
            routeString: CGHSCodesScreen.id,
          ),
          Column(
            mainAxisSize: MainAxisSize.max,
            mainAxisAlignment: MainAxisAlignment.end,
            children: <Widget>[
              InkWell(
                onTap: () {},
                child: Container(
                  margin: EdgeInsets.only(left: 20, right: 20, top: 10),
                  padding: EdgeInsets.all(20),
                  decoration: BoxDecoration(
                    color: Color(0xFFFFFFFF),
                    borderRadius: BorderRadius.circular(25),
                    boxShadow: [
                      new BoxShadow(
                        spreadRadius: 1,
                        offset: Offset.fromDirection(
                          120,
                          5,
                        ),
                        color: Colors.green[300],
                        blurRadius: 10.0,
                      ),
                    ],
                  ),
                  child: Row(
                    children: <Widget>[
                      Container(
                        decoration: BoxDecoration(
                          color: Colors.grey[300],
                          borderRadius: BorderRadius.circular(10),
                        ),
                        padding: EdgeInsets.all(10),
                        child: InkWell(
                          child: FaIcon(
                            FontAwesomeIcons.signInAlt,
                            color: Color(0xFF237158),
                            size: 20,
                          ),
                          radius: 30,
                          splashColor: Colors.lightGreen,
                          hoverColor: Colors.lightGreen[50],
                        ),
                      ),
                      SizedBox(
                        width: 15,
                      ),
                      Text(
                        'Login',
                        style: TextStyle(
                            fontSize: 25, color: Colors.green[700]),
                      ),
                    ],
                  ),
                ),
              ),
            ],
          ),
          _loggedIn
              ? Container()
              : AltButton(
                  label: 'Login',
                  icon: FontAwesomeIcons.user,
                  routeString: LoginScreen.id,
                ),
        ],
      )
    ],
  ),
);

В настоящее время это выглядит так:

Current design

Я стремлюсь к тому, чтобы:

Expected look

Я думал, что добавление следующего в последнем столбце исправит это:

mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,

Какой правильный способ сделать это

1 Ответ

1 голос
/ 26 апреля 2020

добавьте это вместо кнопок, содержащих колонки, попробуйте использовать LayoutBuilder, чтобы вы могли легко преодолевать подобные проблемы

            LayoutBuilder(
              builder: (_, constraints) {
                return Container(
                  width: constraints.maxWidth,
                  height: constraints.maxHeight,
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Container(                                
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.start,
                          children: <Widget>[
                            //your first 2 button
                          ],
                        ),
                      ),
                      Container(
                        child: //your bottom button,
                      ),
                    ],
                  ),
                );
              },
            ),
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...