Удалить ненужное заполнение в начале строки

#flutter

#flutter

Вопрос:

Row в моем контейнере содержится заполнение слева (я думаю). Я хочу выровнять с другими дочерними элементами в Column . Я играл с заполнением в течение последних двух часов и выяснил, как устранить заполнение…

Вход должен располагаться по вертикали слева с кнопками над ним

 @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Container(
        height: MediaQuery.of(context).size.height,
        child: Stack(
          alignment: Alignment.topCenter,
          children: <Widget>[
            Container(
              decoration: BoxDecoration(
                image: DecorationImage(
                  image: AssetImage('assets/img/signin.png'),
                  fit: BoxFit.cover,
                ),
              ),
            ),
            Container(
              padding: EdgeInsets.only(top: 100),
              child: Opacity(
                opacity: _showProgressIndicator ? 1 : 0,
                child: CircularProgressIndicator(),
              ),
            ),
            Container(
//                height: MediaQuery.of(context).size.height - 180,
                padding:
                EdgeInsets.only(top: 20, left: 10, right: 10, bottom: 60),
                child: Form(
                  key: formKey,
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.stretch,
                    verticalDirection: VerticalDirection.up,
                    children: [
                      Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            new FlatButton(
                              padding: EdgeInsets.zero,

                              child: new Text('SIGN IN',
                                  style: Theme.of(context).textTheme.body1),
                              onPressed: () {
                                Navigator.push(
                                    context, SignInPage(widget.onSignedIn));
                              },

                            ),
                            Opacity(
                                opacity: _showMessage ? 1 : 0,
                                child: Text('CONSIDER GOOGLE', style:Theme.of(context).textTheme.body1)),
                            new FlatButton(
                              padding: new EdgeInsets.all(0.0),
                              child: new Text(
                                'SIGN UP WITH EMAIL',
                                style: Theme.of(context).textTheme.body1,
                              ),
                              onPressed: () {
                                Navigator.push(
                                    context, SignUpPage(widget.onSignedIn));
                              },
                            ),
                          ]),
                      new Container(
                        // padding: EdgeInsets.all(10),
                        child: new Column(
                          crossAxisAlignment: CrossAxisAlignment.stretch,
                          children: <Widget>[
                            new RaisedButton(
                              color: Colors.blue[800],
                             padding: EdgeInsets.all(20),
                              shape: RoundedRectangleBorder(
                                  borderRadius:
                                  BorderRadius.all(Radius.circular(4))),
                              child: new Text('CONNECT WITH FACEBOOK',
                                  style: new TextStyle(
                                      fontSize: 16,
                                      letterSpacing: 0.5,
                                      color: Colors.white)),
                              onPressed: loginWithFb,
                            ),
                            new SizedBox(height: 20),
                            new RaisedButton(
                              color: Colors.red,
                              padding: EdgeInsets.all(20),
                              shape: RoundedRectangleBorder(
                                  borderRadius:
                                  BorderRadius.all(Radius.circular(4))),
                              child: new Text('CONNECT WITH GOOGLE',
                                  style: new TextStyle(
                                      fontSize: 16,
                                      letterSpacing: 0.5,
                                      color: Colors.white)),
                              onPressed: loginWithGoogle,
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                ))
          ],
        ),
      ),
    );
  }
  

введите описание изображения здесь

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

1. Я думаю, вы имеете в виду размер FlatButton() по умолчанию, ButtonTheme предоставляет кнопку с минимальной шириной: 88,0, высотой: 36,0, как указано в классе ButtonTheme , это означает, что кнопка входа имеет минимальную ширину 88,0. похоже, что у нее есть заполнение

Ответ №1:

Я мог бы исправить это, изменив значение по умолчанию ButtonTheme , если я правильно понимаю, что вы имеете в виду, потому что вы сказали:

Вход должен располагаться по вертикали слева с кнопками над ним

Разве вы не имеете в виду горизонтально слева, если это так, попробуйте это:

Оберните Flatbutton в тему с помощью ThemeData и new ButtonTheme , затем измените заполнение и минимальную ширину на свои собственные (когда я менял только заполнение или ширину, это не работало). Это удаляет значение по умолчанию из примера ButtonTheme ButtonTheme:

 Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
      Theme(
        data: ThemeData(buttonTheme: ButtonThemeData(minWidth: 20.0,padding: EdgeInsets.all(0.0))),
        child: new FlatButton(
          child: new Text('SIGN IN',
              style: Theme.of(context).textTheme.body1),
          onPressed: () {
          },

        ),
      ),
      Opacity(
          opacity: true ? 1 : 0,
          child: Text('CONSIDER GOOGLE', style:Theme.of(context).textTheme.body1)),
      new FlatButton(
        padding: new EdgeInsets.all(0.0),
        child: new Text(
          "SIGN UP WITH EMAIL ",
          style: Theme.of(context).textTheme.body1,
        ),
        onPressed: () {

        },
      ),
    ]),
  

Результат:

Кнопки