Skip to content

2.Row and Column

Siddhant edited this page Jun 3, 2019 · 1 revision

Row and Column -

  • Column works as a linear layout - vertical
  • rows work as a linear layout - horizontal
class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
            padding: EdgeInsets.only(top: 5,bottom: 5),
            margin: EdgeInsets.only(top: 0),
            alignment: Alignment.center,
            color: Colors.deepPurple,
            child: Column(children: <Widget>[
              Row(
                children: <Widget>[
                  Expanded(
                      child: Container(
                          margin: EdgeInsets.only(left: 10),
                          child: Text("Name :",
                              style: TextStyle(
                                  decoration: TextDecoration.none,
                                  fontSize: 18.0,

                                  fontFamily: 'Raleway',
                                  fontStyle: FontStyle.normal),
                              textDirection: TextDirection.ltr),
                        )),
                  Expanded(
                      child: Text("Sameer Raorane",
                          style: TextStyle(
                              decoration: TextDecoration.none,
                              fontSize: 18.0,
                              fontFamily: 'Raleway',
                              fontStyle: FontStyle.normal),
                          textDirection: TextDirection.ltr)),
                ],
              ),  Row(
                children: <Widget>[
                  Expanded(
                      child: Text("Color :",
                          style: TextStyle(
                              decoration: TextDecoration.none,
                              fontSize: 18.0,
                              fontFamily: 'Raleway',
                              fontStyle: FontStyle.normal),
                          textDirection: TextDirection.ltr)),
                  Expanded(
                      child: Text("Blue",
                          style: TextStyle(
                              decoration: TextDecoration.none,
                              fontSize: 18.0,
                              fontFamily: 'Raleway',
                              fontStyle: FontStyle.normal),
                          textDirection: TextDirection.ltr)),
                ],
              ),
              FlightImageAsset(),
              FlightBookButton()
            ],));
  }
}

Main Method -

Calling widget Home

import 'package:container_demo/app_screens/Home.dart';
import 'package:flutter/material.dart';

void main()
{
    runApp(MaterialApp(
      title: "Exploring UI Widgets",
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(title: Text("My First App")),
        body: Home(),
        floatingActionButton: FloatingActionButton(onPressed: (){
          debugPrint("");
        },
        tooltip: 'Add One More Field'),
      ),


    ));
}

Clone this wiki locally