Skip to content

Commit ebf7fbd

Browse files
author
Bas de Vaan
committed
Fix errors on readme on retrieving FluidConfig
1 parent 2d0364c commit ebf7fbd

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,21 @@ If you need to access the config in your code, you can use the FluidConfig class
7373
We saved this config file in the theme, so you can access it from the theme. Using the following code will retrieve the config from the theme we created earlier;
7474

7575
```dart
76-
FluidConfig config = FluidConfig.fromContext(context);
76+
FluidConfig config = FluidConfig.of(context);
7777
```
7878

79+
or using the extension on BuildContext
80+
81+
```dart
82+
FluidConfig config = context.fluid;
83+
```
7984

8085
### FluidSize
8186

8287
Fluid Size is the basic class to determine a size. It can be used to get a linear value based on the current screen size compared to the min and max set to the FluidWrapper.
8388

8489
```dart
85-
FluidSize(fluidConfig: FluidConfig.fromContext(context), min: 100, max: 200);
90+
FluidSize(fluidConfig: context.fluid, min: 100, max: 200);
8691
```
8792

8893
When on the smallest screensize/breakpoint it will return 100. When on the maximal screensize/breakpoint it will return 200. When on a screensize/breakpoint in between it will return a value in between.
@@ -93,7 +98,7 @@ FluidSpace is a layer over Fluid Size based on modifier scale set in the setting
9398
To get a specific fluid space, you can get it by using the following code;
9499

95100
```dart
96-
SizedBox(height: FluidSpaces(FluidConfig.fromContext(context)).m.value);
101+
SizedBox(height: FluidSpaces(context.fluid).m.value);
97102
```
98103

99104
A short way to write this is with a extension on BuildContext. This extension is available in the package.
@@ -107,9 +112,9 @@ Sometimes you want to have a FluidSpace grow more or less based on screensize. O
107112

108113
```dart
109114
FluidSpacePair(
110-
fluidConfig: FluidConfig.fromContext(context),
111-
small: FluidSpaces(FluidConfig.fromContext(context)).m,
112-
large: FluidSpaces(FluidConfig.fromContext(context)).xl,
115+
fluidConfig: context.fluid,
116+
small: FluidSpaces(context.fluid).m,
117+
large: FluidSpaces(context.fluid).xl,
113118
);
114119
```
115120

@@ -118,7 +123,7 @@ FluidSpacePair(
118123
FluidType is used to create a logical typescale. For typography, you want to have more difference in your fontsizes based on screensize. Using FluidType also scales the scale modifier based on screen size within the viewports. This means that the difference in font size will be bigger on a large screen than on a small screen. This is based on the Utopia principle. In general, we use a scale that from -10 to 10, where 0 is the base font size. This scale can be changed in the settings. To get the value of a specific scale, you can use the following code;
119124

120125
```dart
121-
FluidType(fluidConfig: FluidConfig.fromContext(context), scaleStep: 2).value;
126+
FluidType(fluidConfig: context.fluid, scaleStep: 2).value;
122127
```
123128

124129
A short way to write this is with a extension on BuildContext. This extension is available in the package.

0 commit comments

Comments
 (0)