Skip to content

Commit

Permalink
docs: update api docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ronnnnn committed Jun 27, 2023
1 parent a3c36b4 commit 860e0de
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
15 changes: 10 additions & 5 deletions packages/nilts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,18 @@ Some of lint rules support quick fixes on IDE.

### Overview

| Rule name | Description | Target SDK | Quick fix support |
| :-- | :-- | :--: | :--: |
| [use\_media\_query\_xxx\_of](#use_media_query_xxx_of) | Checks `MediaQuery.xxxOf(context)` or `MediaQuery.maybeXxxOf(context)` usages. | Flutter | ️ |
| Rule name | Overview | Target SDK | Rule type | Maturity level | Quick fix |
| :-- | :-- | :--: | :--: | :--: | :--: |
| [use\_media\_query\_xxx\_of](#use_media_query_xxx_of) | Checks `MediaQuery.xxxOf(context)` or `MediaQuery.maybeXxxOf(context)` usages. | Practice | Experimental | Flutter | ️ |

### Details

#### use_media_query_xxx_of

- Target SDK: Flutter
- Quick fix support: ⭕️
- Rule type: Practice
- Maturity level: Experimental
- Quick fix:

**Prefer** using `MediaQuery.xxxOf(context)` or `MediaQuery.maybeXxxOf(context)` instead of `MediaQuery.of(context)` or `MediaQuery.maybeOf(context)` to avoid unnecessary rebuilds.

Expand All @@ -105,7 +107,10 @@ final size = MediaQuery.sizeOf(context);

Note that using `MediaQuery.of(context)` or `MediaQuery.maybeOf(context)` makes sense in case of observing `MediaQueryData` object changes or referring to many properties of `MediaQueryData`.

See also: [flutter/flutter#114459](https://github.com/flutter/flutter/pull/114459)
See also:

- [MediaQuery as InheritedModel by moffatman · Pull Request #114459 · flutter/flutter](https://github.com/flutter/flutter/pull/114459)
- [MediaQuery class - widgets library - Dart API](https://api.flutter.dev/flutter/widgets/MediaQuery-class.html)

## Assists

Expand Down
11 changes: 10 additions & 1 deletion packages/nilts/lib/src/lints/use_media_query_xxx_of.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import 'package:nilts/src/change_priority.dart';
/// `MediaQuery.of(context)` or `MediaQuery.maybeOf(context)` is used
/// instead of `MediaQuery.xxxOf(context)` or `MediaQuery.maybeXxxOf(context)`.
///
/// - Target SDK: Flutter
/// - Rule type: Practice
/// - Maturity level: Experimental
/// - Quick fix: ✅
///
/// Prefer using
/// `MediaQuery.xxxOf(context)` or `MediaQuery.maybeXxxOf(context)`
/// instead of `MediaQuery.of(context)` or `MediaQuery.maybeOf(context)`
Expand All @@ -31,7 +36,10 @@ import 'package:nilts/src/change_priority.dart';
/// makes sense in case of observing `MediaQueryData` object changes or
/// referring to many properties of `MediaQueryData`.
///
/// See also: https://github.com/flutter/flutter/pull/114459
/// See also:
///
/// - [MediaQuery as InheritedModel by moffatman · Pull Request #114459 · flutter/flutter](https://github.com/flutter/flutter/pull/114459)
/// - [MediaQuery class - widgets library - Dart API](https://api.flutter.dev/flutter/widgets/MediaQuery-class.html)
class UseMediaQueryXxxOf extends DartLintRule {
/// Create a new instance of UseMediaQueryXxxOf.
const UseMediaQueryXxxOf() : super(code: _code);
Expand All @@ -42,6 +50,7 @@ class UseMediaQueryXxxOf extends DartLintRule {
'MediaQuery.xxxOf(context) or MediaQuery.maybeXxxOf(context) '
'instead of MediaQuery.of(context) or MediaQuery.maybeOf(context) '
'to avoid unnecessary rebuilds.',
url: 'https://api.flutter.dev/flutter/widgets/MediaQuery-class.html',
);

@override
Expand Down

0 comments on commit 860e0de

Please sign in to comment.