@@ -16,9 +16,37 @@ class FormFactorBreakpoints {
16
16
/// Enum which defines the possible form factors.
17
17
enum FormFactor { desktop, tablet, handset, watch }
18
18
19
+ extension FormFactorExtensions on FormFactor {
20
+ /// Whether `context.formFactor` is equal to `FormFactor.desktop` .
21
+ bool get isDesktop => this == FormFactor .desktop;
22
+
23
+ /// Whether `context.formFactor` is equal to `FormFactor.tablet` .
24
+ bool get isTablet => this == FormFactor .tablet;
25
+
26
+ /// Whether `context.formFactor` is equal to `FormFactor.handset` .
27
+ bool get isHandset => this == FormFactor .handset;
28
+
29
+ /// Whether `context.formFactor` is equal to `FormFactor.watch` .
30
+ bool get isWatch => this == FormFactor .watch;
31
+ }
32
+
19
33
/// Alternative to [FormFactor] , which is more abstract and defines it in terms of small to large.
20
34
enum ScreenSize { small, normal, large, extraLarge }
21
35
36
+ extension ScreenSizeExtensions on ScreenSize {
37
+ /// Whether `context.screenSize` is equal to `ScreenSize.small` .
38
+ bool get isSmall => this == ScreenSize .small;
39
+
40
+ /// Whether `context.screenSize` is equal to `ScreenSize.normal` .
41
+ bool get isNormal => this == ScreenSize .normal;
42
+
43
+ /// Whether `context.screenSize` is equal to `ScreenSize.large` .
44
+ bool get isLarge => this == ScreenSize .large;
45
+
46
+ /// Whether `context.screenSize` is equal to `ScreenSize.extraLarge` .
47
+ bool get isExtraLarge => this == ScreenSize .extraLarge;
48
+ }
49
+
22
50
extension AdpativeContextExtensions on BuildContext {
23
51
/// The [MediaQueryData] from the closest instance of this class that encloses the given context.
24
52
///
0 commit comments