How to align text in a button in flutter? How to align text in a button in flutter? flutter flutter

How to align text in a button in flutter?


You should put your 'Text' in 'Align' to align your text left, right, top, bottom etc. As-

    FlatButton(                color: Colors.blue,                textColor: Colors.white,                padding: EdgeInsets.all(8.0),                splashColor: Colors.blueAccent,                onPressed: () {                  /*...*/                },                child: Align(                  alignment: Alignment.center,                  child: Text(                    "Flat",                    style: TextStyle(fontSize: 20.0),                    textAlign: TextAlign.center                  ),                ))


Put it in an inkwell

InkWell(    onTap: doSomething,    child: SizedBox(    height: 100,    width: 100,    child: Container(        decoration: BoxDecoration(            border: Border.all(color: Colors.black)),            child: Text(                'hello',                textAlign: TextAlign.right,            ),        ),    ),),


It works for me

  ButtonTheme(    child: FlatButton(      padding: EdgeInsets.all(0),      child: Align(        alignment: Alignment.centerLeft,        child: Text(          "Button text",          style: TextStyle(            color: ThemeColors.primaryDark,            fontWeight: FontWeight.normal,            fontSize: ThemeSizes.normalFont,          ),          textAlign: TextAlign.left,        ),      ),      onPressed: () => _doSomething(),    ),  )