How To Use Row Widget Alignment Using Flutter Android App

admin_img Posted By Bajarangi soft , Posted On 27-11-2020

The Row widget does not scroll (and in general it is considered an error to have more children in a Row than will fit in the available room). If you have a line of widgets and want them to be able to scroll if there is insufficient room, consider using a ListView.For a vertical variant, see Column.If you only have one child, then consider using Align or Center to position the child.

How To Use Row Widget Alignment Using Flutter Android App

 Row Widget alignment
Complete Code For  Row Widget alignment In Flutter
main.dart

import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: MyHomePage(),
    );
  }
}
class MyHomePage extends StatefulWidget {
  final String title;
  MyHomePage({this.title});
  @override
  _MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage>{
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.black,
      appBar: AppBar(
        backgroundColor: Colors.blue[800],
          title: Text("Row Widget")),
      body: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Row(
          mainAxisSize: MainAxisSize.max,
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Container(
              height: 70.0,
              width: 70.0,
              color: Colors.pink,
            ),
            Container(
              height: 70.0,
              width: 70.0,
              color: Colors.deepOrangeAccent,
            ),
            Container(
              height: 70.0,
              width: 70.0,
              color: Colors.lightGreen,
            )
          ],
        ),
      ),
    );
  }
}

Related Post