Flutter SizedBox, Container & SafeArea - All Common Properties
🔹 SizedBox - All Common Properties
```dart
SizedBox(
// Width নির্ধারণ
width: 200,
// Height নির্ধারণ
height: 100,
// ভিতরের Widget
child: Text("SizedBox"),
)
```Expanded SizedBox
SizedBox.expand(
// Parent এর সম্পূর্ণ Space নিবে
child: FlutterLogo(),
)
Shrink SizedBox
SizedBox.shrink()
// Width = 0
// Height = 0
// কোনো Space নিবে না
🔹 Container - All Common Properties
Container(
// Width
width: 250,
// Height
height: 150,
// Background Color
color: Colors.blue,
// Inner Space
padding: EdgeInsets.all(15),
// Outer Space
margin: EdgeInsets.all(20),
// Child Alignment
alignment: Alignment.center,
// Constraint
constraints: BoxConstraints(
// Minimum Width
minWidth: 100,
// Maximum Width
maxWidth: 300,
// Minimum Height
minHeight: 50,
// Maximum Height
maxHeight: 200,
),
// Decoration
decoration: BoxDecoration(
// Background Color
color: Colors.blue,
// Border
border: Border.all(
color: Colors.white,
width: 2,
),
// Border Radius
borderRadius: BorderRadius.circular(20),
// Box Shadow
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 10,
offset: Offset(2, 5),
),
],
// Gradient
gradient: LinearGradient(
colors: [
Colors.blue,
Colors.purple,
],
),
// Background Image
image: DecorationImage(
image: AssetImage("assets/image.png"),
fit: BoxFit.cover,
),
),
// Foreground Decoration
foregroundDecoration: BoxDecoration(),
// Transform
transform: Matrix4.rotationZ(0.1),
// Transform Alignment
transformAlignment: Alignment.center,
// Clip Behavior
clipBehavior: Clip.none,
// Child Widget
child: Text("Container"),
)
🔹 SafeArea - All Common Properties
SafeArea(
// Top Safe Area ব্যবহার করবে কিনা
top: true,
// Bottom Safe Area ব্যবহার করবে কিনা
bottom: true,
// Left Safe Area ব্যবহার করবে কিনা
left: true,
// Right Safe Area ব্যবহার করবে কিনা
right: true,
// Minimum Padding
minimum: EdgeInsets.all(10),
// Keyboard Open হলে Bottom Padding রাখবে
maintainBottomViewPadding: false,
// Child Widget
child: Scaffold(
body: Center(
child: Text("Safe Area"),
),
),
)
📌 সংক্ষেপে
| Widget | ব্যবহার |
|---|---|
| SizedBox | নির্দিষ্ট Width/Height দেওয়ার জন্য |
| SizedBox.expand | Parent-এর সম্পূর্ণ Space নেওয়ার জন্য |
| SizedBox.shrink | 0 Size Widget তৈরির জন্য |
| Container | Layout, Decoration, Padding, Margin ইত্যাদির জন্য |
| SafeArea | Notch, Status Bar, Navigation Bar থেকে UI নিরাপদ |
Comments
Post a Comment