width property
double
get
width
Safely gets the screen width, handling cases where context might not be available
Implementation
static double get width {
try {
BuildContext? context = getSafeModalContext();
if (context != null) {
try {
return MediaQuery.of(context).size.width;
} catch (e) {
// MediaQuery failed, try Get.width
try {
return Get.width;
} catch (e) {
// Fallback to default
return 400.0;
}
}
} else {
// No context, try Get.width
try {
return Get.width;
} catch (e) {
// Fallback to default
return 400.0;
}
}
} catch (e) {
// Complete fallback
return 400.0;
}
}