Home > Mobile >  Row alignment in flutter
Row alignment in flutter

Time:08-18

I want to align my some widgets in a row in a particular way. I want the Icon to be at the beginning of the row and the text to be at the center, I tried wrapping the text widget in a center widget but that didn't work. Please how can I carry out something like that with a row that only has two children?

Something like this is what I want

CodePudding user response:

Wrap the Center in an Expanded. So something like this:

Widget build(BuildContext context) {
  return Row(children: const [
    Icon(Icons.abc),
    Expanded(child: Center(child: Text('abc')))
  ]);
}

CodePudding user response:

Row(
  children: const [
    Icon(Icons.clear, color: Colors.white),
    Expanded(child: Center(child: Text('Login', style: TextStyle(color: Colors.white))))
  ]
)
  • Related