Flutter apps بہت سی screen sizes (phones، tablets، web، desktop) پر چلتی ہیں، اس لیے responsive (سائز کے مطابق ڈھالنا) اور adaptive (platform کے مطابق ڈھالنا) UIs بنانا اہم ہے۔ Flutter MediaQuery، LayoutBuilder، اور flexible widgets جیسے tools فراہم کرتا ہے۔
Responsive: screen size کے مطابق ڈھالنا
// MediaQuery — get screen dimensions and adapt
final width = MediaQuery.of(context).size.width;
if (width > 600) {
// tablet/desktop layout (e.g. side-by-side)
} else {
// phone layout (e.g. stacked)
}
// LayoutBuilder — adapt based on the available space (parent constraints)
LayoutBuilder(builder: (context, constraints) {
if (constraints.maxWidth > 600) return WideLayout();
return NarrowLayout();
})
