Skip to content

Non constant hooks considered constant #34

Open
@nhannah

Description

@nhannah

I have a useQuery hook that returns a record (tuple) of the selected state, and the refetch function.

Inside another hook I use useQuery and create a new function that uses refetch in a useCallback:

  final execute = useCallback(
    () async {
      skip.value = false;
      return refetch();
    },
    [refetch],
  );

Refetch is noted as being unneeded by the linter: Unnecessary key 'refetch' found. Remove the key, or ignore this line.dart(exhaustive_keys).

My settings do not have the useQuery hook as a constant, but I notice some other hooks also not noted as constant, like useAnimationController, also exhibit the same effect of being incorrectly noted as unneeded in a dependency array because I assume they are being treated as constant by the analyzer.

I am wondering if there is a way to correct this on my end of if a fix is required to the analyser.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions