import 'package:flutter/material.dart';
class SizedBoxPaddingDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('SizedBox and Padding'),
),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text('Hello Flutter!'),
SizedBox(height: 50),
Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.blue),
borderRadius: BorderRadius.circular(8),
),
child: Padding(
padding: EdgeInsets.all(16),
child: Text('Click Me'),
),
),
],
),
),
);
}
}We used SizedBox with a height of 50 pixels to add vertical space between the title text and the button container. This is like putting a spacer between two items.
The button text is wrapped inside a Padding widget with 16 pixels on all sides. This adds space inside the container around the text, so the text does not touch the border.
The Container has a blue border and rounded corners to visually separate the button area.
All widgets are centered vertically and horizontally using Center and Column with mainAxisSize: MainAxisSize.min to keep the content compact.