Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[riverpod_lint] avoid_manual_providers_as_generated_provider_dependency #3470

Open
SheepYang1993 opened this issue Apr 3, 2024 · 2 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@SheepYang1993
Copy link

Describe the bug
vipTypeListInfoProvider.notifierwill show lint avoid_manual_providers_as_generated_provider_dependency

To Reproduce
This is my code

import 'package:qlzm_color_flutter/model/response/vip_type_list_response.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

import '../network/api/pay_api.dart';
import '../util/app_util.dart';
import '../util/storage_util.dart';

part 'vip_riverpod.g.dart';

@riverpod
Future<void> refreshVipTypeList(RefreshVipTypeListRef ref) async {
  VipTypeListResponse response = await PayApi.getVipTypeList();
  List<VipTypeListData>? vipTypeList = response.data;
  await StorageUtil().write(StorageUtil.keyVipTypeList, vipTypeList);
  ref.read(vipTypeListInfoProvider.notifier).set(vipTypeList);
}

@Riverpod(keepAlive: true)
class VipTypeListInfo extends _$VipTypeListInfo {
  @override
  List<VipTypeListData>? build() {
    List<VipTypeListData>? vipTypeList = StorageUtil()
        .read<List<VipTypeListData>>(StorageUtil.keyVipTypeList,
            fromJson: (jsonList) {
      if (jsonList is List) {
        return jsonList.map((json) {
          return VipTypeListData.fromJson(json);
        }).toList();
      }
      return <VipTypeListData>[];
    });
    return vipTypeList;
  }

  set(List<VipTypeListData>? vipTypeList) {
    state = vipTypeList;
    AppUtil().saveVipTypeList(vipTypeList);
  }
}

Expected behavior
I'm not sure if it's a code issue or a Lint error

@rrousselGit
Copy link
Owner

Generally, it's just the IDE that's out of date.
You're most likely facing dart-lang/sdk#54113.

Does the warning disappear if you restart the IDE or open the generated file?

@rrousselGit rrousselGit added question Further information is requested and removed needs triage labels Apr 3, 2024
@SheepYang1993
Copy link
Author

SheepYang1993 commented Apr 5, 2024

Generally, it's just the IDE that's out of date. You're most likely facing dart-lang/sdk#54113.

Does the warning disappear if you restart the IDE or open the generated file?

Restart the IDE or reopen the generated file, lint will not disappear.

When I added a parameter and run build_runner build, Lint disappeared.

@riverpod
Future<void> refreshVipTypeList(
  RefreshVipTypeListRef ref, {
  bool showLoading = false,
})

My Flutter version is 3.19.3
flutter_riverpod: 2.5.1
riverpod_annotation: 2.3.5
riverpod_generator: 2.4.0
riverpod_lint: 2.3.10

I haven't tried the method of upgrading IDE and Flutter yet, but I will try it out in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants