flutterdartflutter-layout

Set the space between Elements in Row Flutter


Code:

new Container(
          alignment: FractionalOffset.center,
          child: new Row(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: <Widget>[
              new FlatButton(
                child: new Text('Don\'t have an account?', style: new TextStyle(color: Color(0xFF2E3233))),
              ),
              new FlatButton(
                child: new Text('Register.', style: new TextStyle(color: Color(0xFF84A2AF), fontWeight: FontWeight.bold),),
                onPressed: moveToRegister,
              )
            ],
          ),
        ),  

And here is the result: https://dartpad.dev/?id=6bbfc6139bdf32aa7b47eebcdf9623ba

How to fix that the two FlatButton elements are side by side without space between the center of the screen width?


Solution

  • Removing Space-:

    new Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  GestureDetector(
                    child: new Text('Don\'t have an account?',
                        style: new TextStyle(color: Color(0xFF2E3233))),
                    onTap: () {},
                  ),
                  GestureDetector(
                    onTap: (){},
                      child: new Text(
                    'Register.',
                    style: new TextStyle(
                        color: Color(0xFF84A2AF), fontWeight: FontWeight.bold),
                  ))
                ],
              ),
    

    OR

    GestureDetector(
                onTap: (){},
                child: new Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    new Text('Don\'t have an account?',
                        style: new TextStyle(color: Color(0xFF2E3233))),
                    new Text(
                      'Register.',
                      style: new TextStyle(
                      color: Color(0xFF84A2AF), fontWeight: FontWeight.bold),
                    )
                  ],
                ),
              ),