You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
900 B
36 lines
900 B
import 'package:flutter/material.dart';
|
|
|
|
class Responsive extends StatelessWidget {
|
|
final Widget mobile;
|
|
final Widget? tablet;
|
|
final Widget desktop;
|
|
|
|
const Responsive({
|
|
Key? key,
|
|
required this.mobile,
|
|
this.tablet,
|
|
required this.desktop,
|
|
}) : super(key: key);
|
|
|
|
static bool isMobile(BuildContext context) =>
|
|
MediaQuery.of(context).size.width < 576;
|
|
|
|
static bool isTablet(BuildContext context) =>
|
|
MediaQuery.of(context).size.width >= 576 &&
|
|
MediaQuery.of(context).size.width <= 992;
|
|
|
|
static bool isDesktop(BuildContext context) =>
|
|
MediaQuery.of(context).size.width > 992;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final Size size = MediaQuery.of(context).size;
|
|
if (size.width > 992) {
|
|
return desktop;
|
|
} else if (size.width >= 576 && tablet != null) {
|
|
return tablet!;
|
|
} else {
|
|
return mobile;
|
|
}
|
|
}
|
|
}
|