Skip to content

Instantly share code, notes, and snippets.

@nazrievfarrukhjon
Last active April 22, 2020 17:45
Show Gist options
  • Save nazrievfarrukhjon/985a5e79a89e4bf39a26498e7a2e3a9d to your computer and use it in GitHub Desktop.
Save nazrievfarrukhjon/985a5e79a89e4bf39a26498e7a2e3a9d to your computer and use it in GitHub Desktop.
Flutter Responsive Button With Icon and Text
/*
I tried so many Widgets to make Buttons with icons and text, but none worked for me,
as it should be responsive.
They used to crash with different pixel size devices.
Maybe someone will need this code or if someone knows better option,
write in comments please. because i need it.
Thank you.:)
*/
Flexible(
flex: 1,
fit: FlexFit.tight,
child: FlatButton(
shape: new RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(5.0),
),
color: Color.fromRGBO(58, 90, 128, 1),
child: Flex(
direction: Axis.horizontal,
textDirection: TextDirection.ltr,
children: <Widget>[
Flexible(flex: 10, child: Container()),
Flexible(flex: 10, child: Icon(Icons.email,color: Colors.white,)),
Flexible(flex: 1, child: Container()),
Flexible(flex: 20, fit: FlexFit.tight ,child: Text('Login by email',
style: TextStyle(color: Colors.white,
),
),
),
],
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => GoToSomePage(),
));
},
),
),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment