mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 14:47:23 +00:00
40 lines
984 B
Dart
40 lines
984 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class ResponsiveLayout extends StatelessWidget {
|
|
final Widget mobileBody;
|
|
final Widget? tablet;
|
|
final Widget desktopBody;
|
|
|
|
const ResponsiveLayout({
|
|
super.key,
|
|
required this.mobileBody,
|
|
this.tablet,
|
|
required this.desktopBody,
|
|
});
|
|
|
|
static bool isMobile(BuildContext context) =>
|
|
MediaQuery.of(context).size.width < 650;
|
|
|
|
static bool isTablet(BuildContext context) =>
|
|
MediaQuery.of(context).size.width < 1100 &&
|
|
MediaQuery.of(context).size.width >= 650;
|
|
|
|
static bool isDesktop(BuildContext context) =>
|
|
MediaQuery.of(context).size.width >= 1100;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
if (constraints.maxWidth >= 1100) {
|
|
return desktopBody;
|
|
} else if (constraints.maxWidth >= 650) {
|
|
return tablet!;
|
|
} else {
|
|
return mobileBody;
|
|
}
|
|
},
|
|
);
|
|
}
|
|
}
|