Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .fvmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"flutter": "3.29.1"
"flutter": "3.38.10"
}
44 changes: 22 additions & 22 deletions example/lib/use_widget_ref_synchronously_lint_rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ class UseWidgetRefSynchronouslyLintRule extends HookConsumerWidget {
) async {
// expect_lint: use_widget_ref_synchronously
await ref
.read(asyncStateCounterNotifierProvider.notifier)
.read(asyncStateCounterProvider.notifier)
.asyncIncrementCounter();

if (context.mounted) {
ref
.read(asyncStateCounterNotifierProvider.notifier)
.read(asyncStateCounterProvider.notifier)
.syncIncrementCounter();
}

if (!context.mounted) {
// expect_lint: use_widget_ref_synchronously
ref
.read(asyncStateCounterNotifierProvider.notifier)
.read(asyncStateCounterProvider.notifier)
.syncIncrementCounter();
return;
}
Expand All @@ -35,21 +35,21 @@ class UseWidgetRefSynchronouslyLintRule extends HookConsumerWidget {
return;
}

ref.read(asyncStateCounterNotifierProvider.notifier).syncIncrementCounter();
ref.read(asyncStateCounterProvider.notifier).syncIncrementCounter();
}

@override
Widget build(BuildContext context, WidgetRef ref) {
final counter = ref.watch(asyncStateCounterNotifierProvider);
final counter = ref.watch(asyncStateCounterProvider);

useEffect(() {
WidgetsBinding.instance.addPostFrameCallback((_) async {
// expect_lint: use_widget_ref_synchronously
final state = ref.watch(asyncStateCounterNotifierProvider);
final state = ref.watch(asyncStateCounterProvider);
state.isOdd;

if (context.mounted) {
final state = ref.watch(asyncStateCounterNotifierProvider);
final state = ref.watch(asyncStateCounterProvider);
state.isEven;
}
});
Expand All @@ -65,19 +65,19 @@ class UseWidgetRefSynchronouslyLintRule extends HookConsumerWidget {
onTap: () async {
// expect_lint: use_widget_ref_synchronously
await ref
.read(asyncStateCounterNotifierProvider.notifier)
.read(asyncStateCounterProvider.notifier)
.asyncIncrementCounter();

if (context.mounted) {
ref
.read(asyncStateCounterNotifierProvider.notifier)
.read(asyncStateCounterProvider.notifier)
.syncIncrementCounter();
}

if (!context.mounted) {
// expect_lint: use_widget_ref_synchronously
ref
.read(asyncStateCounterNotifierProvider.notifier)
.read(asyncStateCounterProvider.notifier)
.syncIncrementCounter();
return;
}
Expand All @@ -87,7 +87,7 @@ class UseWidgetRefSynchronouslyLintRule extends HookConsumerWidget {
}

ref
.read(asyncStateCounterNotifierProvider.notifier)
.read(asyncStateCounterProvider.notifier)
.syncIncrementCounter();
},
),
Expand All @@ -114,19 +114,19 @@ class _StatefulUseWidgetRefSynchronouslyLintRuleState
) async {
// expect_lint: use_widget_ref_synchronously
await ref
.read(asyncStateCounterNotifierProvider.notifier)
.read(asyncStateCounterProvider.notifier)
.asyncIncrementCounter();

if (mounted) {
ref
.read(asyncStateCounterNotifierProvider.notifier)
.read(asyncStateCounterProvider.notifier)
.syncIncrementCounter();
}

if (!mounted) {
// expect_lint: use_widget_ref_synchronously
ref
.read(asyncStateCounterNotifierProvider.notifier)
.read(asyncStateCounterProvider.notifier)
.syncIncrementCounter();
return;
}
Expand All @@ -135,21 +135,21 @@ class _StatefulUseWidgetRefSynchronouslyLintRuleState
return;
}

ref.read(asyncStateCounterNotifierProvider.notifier).syncIncrementCounter();
ref.read(asyncStateCounterProvider.notifier).syncIncrementCounter();
}

@override
Widget build(BuildContext context) {
final counter = ref.watch(asyncStateCounterNotifierProvider);
final counter = ref.watch(asyncStateCounterProvider);

useEffect(() {
WidgetsBinding.instance.addPostFrameCallback((_) async {
// expect_lint: use_widget_ref_synchronously
final state = ref.watch(asyncStateCounterNotifierProvider);
final state = ref.watch(asyncStateCounterProvider);
state.isOdd;

if (mounted) {
final state = ref.watch(asyncStateCounterNotifierProvider);
final state = ref.watch(asyncStateCounterProvider);
state.isEven;
}
});
Expand All @@ -165,19 +165,19 @@ class _StatefulUseWidgetRefSynchronouslyLintRuleState
onTap: () async {
// expect_lint: use_widget_ref_synchronously
await ref
.read(asyncStateCounterNotifierProvider.notifier)
.read(asyncStateCounterProvider.notifier)
.asyncIncrementCounter();

if (mounted) {
ref
.read(asyncStateCounterNotifierProvider.notifier)
.read(asyncStateCounterProvider.notifier)
.syncIncrementCounter();
}

if (!mounted) {
// expect_lint: use_widget_ref_synchronously
ref
.read(asyncStateCounterNotifierProvider.notifier)
.read(asyncStateCounterProvider.notifier)
.syncIncrementCounter();
return;
}
Expand All @@ -187,7 +187,7 @@ class _StatefulUseWidgetRefSynchronouslyLintRuleState
}

ref
.read(asyncStateCounterNotifierProvider.notifier)
.read(asyncStateCounterProvider.notifier)
.syncIncrementCounter();
},
),
Expand Down
67 changes: 51 additions & 16 deletions example/lib/use_widget_ref_synchronously_lint_rule.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading