Skip to content

Commit

Permalink
fixes && docs and CHANGELOG.md improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromassango committed Mar 10, 2021
1 parent b6d0421 commit 04518d6
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 20 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
## [3.0.0] - 07/03/2021.

* Migrated to null safety
* Migration to ScaffoldMessenger

Added support for:

* `context.platform`
* `context.headline1`
* `context.headline2`
* `context.headline3`
* `context.headline4`
* `context.headline5`
* `context.headline6`
* `context.subtitle1`
* `context.bodyText1`
* `context.bodyText2`
* `context.caption`
* `context.button`
* `context.subtitle2`
* `context.overline`

* `context.modalRoute`
* `context.routeSettings`

## [2.0.4] - 18/07/2020.

Expand Down
7 changes: 6 additions & 1 deletion README-pt-BR.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,18 @@ Observação: Esses devem ser chamados no contexto de um widget `Scaffold`, caso
- `context.focusScope.consumeKeyboardToken()`
- `context.closeKeyboard()`

#### Da classe `ModalRoute.of(context)`.

* `context.modalRoute`
* `context.routeSettings`

# Instalar

Adicione em seu `pubspec.yaml`:

```yaml
dependencies:
build_context: ^2.0.4
build_context: ^3.0.0
```
Importe onde você quer usar, por exemplo, no arquivo do widget.
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ bellow you can see the currently available extensions in the latest version.
* `context.isMacOS`
* `context.isLinux`
* `context.isFuchsia`

* `context.headline1`
* `context.headline2`
* `context.headline3`
Expand Down Expand Up @@ -107,7 +106,6 @@ Note: those must be called in the context of a `Scaffold` widget otherwise you m
* `context.focusScope.consumeKeyboardToken()`
* `context.closeKeyboard()`


#### From `ModalRoute.of(context)` class.

* `context.modalRoute`
Expand All @@ -119,7 +117,7 @@ Add it in your `pubspec.yaml`:

````yaml
dependencies:
build_context: ^2.0.4
build_context: ^3.0.0
````

Import it where you want to use it e.g, in your widget's file.
Expand Down
33 changes: 17 additions & 16 deletions lib/src/build_context_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ extension NavigatorExt on BuildContext {
}

extension ThemeExt on BuildContext {

ThemeData get theme => Theme.of(this);

TextTheme get textTheme => Theme.of(this).textTheme;
Expand Down Expand Up @@ -89,31 +90,31 @@ extension ThemeExt on BuildContext {

bool get isLinux => this.platform == TargetPlatform.linux;

TextStyle get headline1 => textTheme.headline1;
TextStyle? get headline1 => textTheme.headline1;

TextStyle get headline2 => textTheme.headline2;
TextStyle? get headline2 => textTheme.headline2;

TextStyle get headline3 => textTheme.headline3;
TextStyle? get headline3 => textTheme.headline3;

TextStyle get headline4 => textTheme.headline4;
TextStyle? get headline4 => textTheme.headline4;

TextStyle get headline5 => textTheme.headline5;
TextStyle? get headline5 => textTheme.headline5;

TextStyle get headline6 => textTheme.headline6;
TextStyle? get headline6 => textTheme.headline6;

TextStyle get subtitle1 => textTheme.subtitle1;
TextStyle? get subtitle1 => textTheme.subtitle1;

TextStyle get bodyText1 => textTheme.bodyText1;
TextStyle? get bodyText1 => textTheme.bodyText1;

TextStyle get bodyText2 => textTheme.bodyText2;
TextStyle? get bodyText2 => textTheme.bodyText2;

TextStyle get caption => textTheme.caption;
TextStyle? get caption => textTheme.caption;

TextStyle get button => textTheme.button;
TextStyle? get button => textTheme.button;

TextStyle get subtitle2 => textTheme.subtitle2;
TextStyle? get subtitle2 => textTheme.subtitle2;

TextStyle get overline => textTheme.overline;
TextStyle? get overline => textTheme.overline;
}

extension ScaffoldExt on BuildContext {
Expand Down Expand Up @@ -196,10 +197,10 @@ extension FocusScopeExt on BuildContext {
void closeKeyboard() => this.focusScope.requestFocus(FocusNode());
}

extension ModalRouteExt on BuildContext {
extension ModalRouteExt<T> on BuildContext {

ModalRoute get modalRoute => ModalRoute.of(this);
ModalRoute<T>? get modalRoute => ModalRoute.of<T>(this);

RouteSettings get routeSettings => ModalRoute.of(this).settings;
RouteSettings? get routeSettings => modalRoute?.settings;

}

0 comments on commit 04518d6

Please sign in to comment.