You can align a container by wrapping it inside an Align widget.
For example, the below code will set the container to topCenter.
Align(
alignment: FractionalOffset.topCenter,
child: Container(
height: 100,
width: 100,
decoration: const BoxDecoration(
color: Colors.amber,
),
),
)
You can set Alignment to topCenter, topRight, centerLeft, center, centerRight, bottomLeft, bottomCenter, or bottomRight.Here is a simple example, that helps you to understand more about aligning the container.
import 'package:flutter/material.dart';
void main(List<String> args) {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@
override
Widget build(BuildContext context) {
return Align(
alignment: FractionalOffset.,
child: Container(
height: 100,
width: 100,
decoration: const BoxDecoration(
color: Colors.amber,
),
),
);
}
}
Thanks,
Srikanth