flutter_test_patterns 1.0.0 copy "flutter_test_patterns: ^1.0.0" to clipboard
flutter_test_patterns: ^1.0.0 copied to clipboard

A helper package providing a toolbox of widget testing patterns.

Flutter Test Patterns #

Pub Version Agent Skill License: MIT PRs Welcome Flutter Dart Testing Golden Tests

A toolbox of common, senior-level widget testing patterns for Flutter.

This package provides opt-in helpers to reduce boilerplate in your tests. It is NOT a testing framework. It does not impose a specific architecture or base class.

Philosophy #

  • Explicit is better than implicit. Helpers should not hide what they are doing.
  • Composition over inheritance. No BaseTest classes.
  • Isolation. State should not leak between tests or variants.

Patterns #

Pattern Purpose
Golden Variants Generate multiple visual variants (primary, hover, disabled) in a single test block with deterministic output.
Interaction Contracts Define and enforce reusable behavioral contracts (e.g., "tappable", "validates on blur").
State Matrix Ensure a widget behaves correctly across all defined states (loading, error, data, empty).

Installation #

dev_dependencies:
  flutter_test_patterns:
    path: . # Local path or git url

Quick Example (Golden Variants) #

testWidgets('Button variants', (tester) async {
  await goldenVariants(
    tester,
    'button',
    variants: {
      'primary': () => Button.primary(),
      'disabled': () => Button.disabled(),
    },
  );
});

See doc/patterns/ for detailed guides on each pattern.

Contributing #

Contributions are welcome! Please feel free to open an issue or submit a PR.

AI Agent Skill #

Use flutter_test_patterns directly inside Claude Code, Cursor, GitHub Copilot, Windsurf, and 39+ AI agents:

npx skills add Sourav-Sonkar/flutter_test_patterns

Then just ask your AI: "Write widget tests for this Flutter component"

License #

MIT

1
likes
0
points
117
downloads

Publisher

verified publisherconalyz.com

Weekly Downloads

A helper package providing a toolbox of widget testing patterns.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_test

More

Packages that depend on flutter_test_patterns