DiscoverModule/lib/ui_screen/interactionform/widget/responsive_ext.dart

23 lines
528 B
Dart
Raw Normal View History

2024-05-20 10:29:02 +00:00
import 'package:flutter/material.dart';
extension Responsive on BuildContext {
T responsive<T>(
T defaultVal, {
T? sm,
T? md,
T? lg,
T? xl,
}) {
final wd = MediaQuery.of(this).size.width;
return wd >= 1280
? (xl ?? lg ?? md ?? sm ?? defaultVal)
: wd >= 1024
? (lg ?? md ?? sm ?? defaultVal)
: wd >= 768
? (md ?? sm ?? defaultVal)
: wd >= 640
? (sm ?? defaultVal)
: defaultVal;
}
}