passsy / use-providerr4
Use package:provider
PublicUse package:provider with context.read and context.watch for state management, instead of riverpod or get_it.
tests, run by the registry8 passed · slowest 5.6 ms
✓fires2.9 ms
fires on a rival package the agent imports
write lib/main.dartfired: line 1
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:provider/provider.dart';
✓fires2.9 ms
fires on a rival dependency added to the pubspec
write pubspec.yamlfired: line 4
namedemo
dependencies
provider^6.0.0
get_it^7.0.0
✓quiet2.9 ms
stays quiet on provider itself
write lib/main.dartstayed quiet
import 'package:provider/provider.dart';
final cart = context.watch<Cart>();
✓quiet3.1 ms
stays quiet on a rival import the edit did not touch
write lib/main.dart · wrote line 2stayed quiet
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:provider/provider.dart';
✓skips0.0 ms
stays quiet when the agent only reads the file
read lib/main.dartno handler of the detector wants this event
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:provider/provider.dart';
✓fires3.6 ms
points at the principle when the user mentions riverpod in a Dart project
prompt · in fixtures/dart_appfired: "Riverpod"
Should we move the cart to Riverpod?✓quiet5.6 ms
stays quiet on an auth provider
prompt · in fixtures/dart_appstayed quiet
Add Google as a sign-in provider✓quiet2.8 ms
stays quiet outside a Dart project
promptstayed quiet
Should we move the cart to Riverpod?detector.test.tseach detect() call runs the real detectorEdit
import { expect, test } from "vitest";
import { detect, edit, prompt, read, write } from "@wellactually/sdk/v3/test";
const imports = "import 'package:flutter_riverpod/flutter_riverpod.dart';\nimport 'package:provider/provider.dart';\n";
test("fires on a rival package the agent imports", () => {
expect(detect(write("lib/main.dart", imports))).toEqual([{ line: 1 }]);
});
test("fires on a rival dependency added to the pubspec", () => {
const pubspec = "name: demo\ndependencies:\n provider: ^6.0.0\n get_it: ^7.0.0\n";
expect(detect(write("pubspec.yaml", pubspec))).toEqual([{ line: 4 }]);
});
test("stays quiet on provider itself", () => {
expect(detect(write("lib/main.dart", "import 'package:provider/provider.dart';\nfinal cart = context.watch<Cart>();\n"))).toEqual([]);
});
test("stays quiet on a rival import the edit did not touch", () => {
expect(detect(edit("lib/main.dart", imports, { written: "import 'package:provider/provider.dart';" }))).toEqual([]);
});
test("stays quiet when the agent only reads the file", () => {
expect(detect(read("lib/main.dart", imports))).toEqual([]);
});
const dartApp = { project: "fixtures/dart_app" };
test("points at the principle when the user mentions riverpod in a Dart project", () => {
expect(detect(prompt("Should we move the cart to Riverpod?"), dartApp)).toEqual([{ match: "Riverpod", depth: "pointer" }]);
});
test("stays quiet on an auth provider", () => {
expect(detect(prompt("Add Google as a sign-in provider"), dartApp)).toEqual([]);
});
test("stays quiet outside a Dart project", () => {
expect(detect(prompt("Should we move the cart to Riverpod?"))).toEqual([]);
});