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

A helper package providing a toolbox of widget testing patterns.

Flutter Test Patterns #

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.

License #

MIT

0
likes
160
points
33
downloads

Documentation

API reference

Publisher

verified publisherconalyz.com

Weekly Downloads

A helper package providing a toolbox of widget testing patterns.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, flutter_test

More

Packages that depend on flutter_test_patterns