Flutter-Apps laufen auf vielen Bildschirmgrößen (Phones, Tablets, Web, Desktop), daher ist das Erstellen von responsiven UIs (Anpassung an Größe) und adaptiven UIs (Anpassung an Plattform) wichtig. Flutter bietet Tools wie MediaQuery, LayoutBuilder und flexible Widgets dafür.
Responsive: Anpassung an die Bildschirmgröße
// 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();
})
