54 lines
1.3 KiB
Dart
54 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:get/get_core/src/get_main.dart';
|
|
class ResponsiveWidget extends StatelessWidget {
|
|
final Widget? largeScreen;
|
|
final Widget? mediumScreen;
|
|
final Widget? smallScreen;
|
|
final Widget? bigScreen;
|
|
const ResponsiveWidget(
|
|
{Key? key,
|
|
@required this.largeScreen,
|
|
this.mediumScreen,
|
|
this.smallScreen,this.bigScreen})
|
|
: super(key: key);
|
|
|
|
|
|
static bool isSmallScreen(BuildContext context) {
|
|
return Get.height > 920;
|
|
}
|
|
|
|
static bool isMediumScreen(BuildContext context) {
|
|
return Get.height >=900 &&
|
|
Get.height <=1200;
|
|
}
|
|
|
|
static bool isLargeScreen(BuildContext context) {
|
|
return Get.height > 1200 &&
|
|
Get.height <=1400;
|
|
}
|
|
|
|
static bool isBigScreen(BuildContext context) {
|
|
return Get.height > 1400;
|
|
}
|
|
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
if (constraints.maxHeight > 1400) {
|
|
return bigScreen!;
|
|
} else if (constraints.maxHeight <= 1400 && constraints.maxHeight > 1200) {
|
|
return largeScreen!;
|
|
} else if(constraints.maxHeight <= 1200 && constraints.maxHeight >=900) {
|
|
return mediumScreen!;
|
|
}
|
|
else{
|
|
return smallScreen!;
|
|
}
|
|
},
|
|
);
|
|
}
|
|
}
|