No Description
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.

responsive.dart 900B

123456789101112131415161718192021222324252627282930313233343536
  1. import 'package:flutter/material.dart';
  2. class Responsive extends StatelessWidget {
  3. final Widget mobile;
  4. final Widget? tablet;
  5. final Widget desktop;
  6. const Responsive({
  7. Key? key,
  8. required this.mobile,
  9. this.tablet,
  10. required this.desktop,
  11. }) : super(key: key);
  12. static bool isMobile(BuildContext context) =>
  13. MediaQuery.of(context).size.width < 576;
  14. static bool isTablet(BuildContext context) =>
  15. MediaQuery.of(context).size.width >= 576 &&
  16. MediaQuery.of(context).size.width <= 992;
  17. static bool isDesktop(BuildContext context) =>
  18. MediaQuery.of(context).size.width > 992;
  19. @override
  20. Widget build(BuildContext context) {
  21. final Size size = MediaQuery.of(context).size;
  22. if (size.width > 992) {
  23. return desktop;
  24. } else if (size.width >= 576 && tablet != null) {
  25. return tablet!;
  26. } else {
  27. return mobile;
  28. }
  29. }
  30. }