dartlangeditorflutterflutter-appsflutter-examplesflutter-packageflutter-widgetquillquill-deltaquilljsreactquillrich-textrich-text-editorwysiwygwysiwyg-editor
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.
43 lines
1.1 KiB
43 lines
1.1 KiB
import 'package:flutter/material.dart'; |
|
|
|
class ResponsiveWidget extends StatelessWidget { |
|
const ResponsiveWidget({ |
|
required this.largeScreen, |
|
this.mediumScreen, |
|
this.smallScreen, |
|
Key? key, |
|
}) : super(key: key); |
|
|
|
final Widget largeScreen; |
|
final Widget? mediumScreen; |
|
final Widget? smallScreen; |
|
|
|
static bool isSmallScreen(BuildContext context) { |
|
return MediaQuery.sizeOf(context).width < 800; |
|
} |
|
|
|
static bool isLargeScreen(BuildContext context) { |
|
return MediaQuery.sizeOf(context).width > 1200; |
|
} |
|
|
|
static bool isMediumScreen(BuildContext context) { |
|
return MediaQuery.sizeOf(context).width >= 800 && |
|
MediaQuery.sizeOf(context).width <= 1200; |
|
} |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
return LayoutBuilder( |
|
builder: (context, constraints) { |
|
if (constraints.maxWidth > 1200) { |
|
return largeScreen; |
|
} else if (constraints.maxWidth <= 1200 && |
|
constraints.maxWidth >= 800) { |
|
return mediumScreen ?? largeScreen; |
|
} else { |
|
return smallScreen ?? largeScreen; |
|
} |
|
}, |
|
); |
|
} |
|
}
|
|
|