Skip to content
Open
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
17 changes: 17 additions & 0 deletions .github/workflows/flutter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ jobs:
- name: Analyze code
run: flutter analyze ${{ needs.changes.outputs.all_changed_files }}

custom_lint:
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.any_changed == 'true'
steps:
- uses: actions/checkout@v4
- uses: kuhnroyal/flutter-fvm-config-action@v2
id: fvm-config-action
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
- name: Get dependencies
run: flutter pub get
- name: Analyze code
run: flutter pub run custom_lint ${{ needs.changes.outputs.all_changed_files }}

formatter:
runs-on: ubuntu-latest
needs: changes
Expand Down
30 changes: 3 additions & 27 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
analyzer:
plugins:
- custom_lint
19 changes: 11 additions & 8 deletions lib/features/users/widgets/users_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:bloc_example/features/users/bloc/users_bloc.dart';
import 'package:bloc_example/features/users/bloc/users_bloc_event.dart';
import 'package:bloc_example/features/users/bloc/users_bloc_state.dart';
import 'package:bloc_example/features/users/widgets/user_info_row.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

Expand Down Expand Up @@ -35,13 +34,17 @@ class _UsersListState extends State<UsersList> {
@override
Widget build(BuildContext context) {
return BlocBuilder<UsersBloc, UsersBlocState>(
buildWhen: (prev, curr) {
if (prev is UsersBlocStateLoaded && curr is UsersBlocStateLoaded) {
return !const DeepCollectionEquality().equals(prev.users, curr.users);
}

return true;
},
//
// Чтобы убрать ошибку - добавьте `buildWhen` из комментария ниже.
// Вообще, можно вставить свою реализацию. Ошибка отсутствия `buildWhen` пропадет после его добавления.
//
// buildWhen: (prev, curr) {
// if (prev is UsersBlocStateLoaded && curr is UsersBlocStateLoaded) {
// return !const DeepCollectionEquality().equals(prev.users, curr.users);
// }
//
// return true;
// },
builder: (context, state) {
return switch (state) {
UsersBlocStateLoading _ => const UsersListShimmer(),
Expand Down
Loading
Loading