MainAxis VS CrossAxis
MainAxisAlignment Properties
- MainAxisAlignment.start: All widgets start from the top
- MainAxisAlignment.end: All widgets start from the end
- MainAxisAlignment. centre:All widgets start from the centre
- MainAxisAlignment.spaceBetween: First & Last widget no space & space between inner widget
- MainAxisAlignment.spaceAround: first and last widget with half of the space of inner widgets
- MainAxisAlignment.spaceEvenly: All widgets wrapped with equal space
Coding Example
import 'package:flutter/material.dart';
void main(List<String> args) {
runApp(MaterialApp(
home: Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
color: Colors.red,
width: 100,
height: 100,
child: const Center(child: Text("First Child")),
),
Container(
color: Colors.green,
width: 100,
height: 100,
child: const Center(child: Text("Second Child")),
),
Container(
color: Colors.blue,
width: 100,
height: 100,
child: const Center(child: Text("Third Child")),
),
],
),
),
),
));
}
No comments:
Post a Comment