widgetbook library
Widgetbook is a package to build widgets in isolation, test them in different states, and catalogue all your widgets in a single place.
Classes
-
Addon<
T> - Addons are like global Args, they change the state for all Storys. For example, you can manipulate the theme for all Storys, instead of doing it one-by-one using Args.
- AlignmentAddon
- An Addon for wrapping use-cases with Align widget.
- AlignmentMode
- AndroidViewports
- A collection of predefined Android viewports.
-
Arg<
T> - ArgsDocBlock
- A DocBlock that displays a table of Args for a Story, including Arg.name, Arg.value, and Arg.description.
- BoolArg
- BooleanField
- Field that builds Switch for bool values.
- BuilderAddon
- An Addon for wrapping use-cases with a builder.
-
BuilderArg<
T> - ChainedFinder
- Applies additional filtering against a parent widget finder.
- ColorArg
- ColorField
-
Field that builds
ColorPickerfor Color values using the ColorSpace to determine which format the Color is. - CommonFinders
- Provides lightweight syntax for getting frequently used Finders and SemanticsFinders through semantics.
- CommonSemanticsFinders
- Provides lightweight syntax for getting frequently used semantics finders.
- CommonTextRangeFinders
- Provides lightweight syntax for getting frequently used text range finders.
-
Component<
TWidget extends Widget, TArgs extends StoryArgs< TWidget> > - ComponentNameDocBlock
- A DocBlock that displays the name of the current Component in the documentation panel.
- ComposerDocBlock
- A DocBlock that composes multiple widgets or DocBlocks vertically in the documentation panel.
- Config
-
ConstArg<
T> - CupertinoThemeAddon
- An Addon for changing the active CupertinoThemeData via CupertinoTheme.
- CupertinoThemeMode
- CustomMatcher
- A base class for Matcher instances that match based on some feature of the value under test.
- DartCommentDocBlock
- A DocBlock that displays the documentation comments for the current Component.
- DateTimeArg
- DateTimeField
- A Field that builds a TextFormField for DateTime values, allowing users to select a date and time using a date and time picker.
-
Defaults<
TWidget extends Widget, TArgs extends StoryArgs< TWidget> > - DefaultTestVariant
-
The TestVariant that represents the "default" test that is run if no
variantsiterable is specified for testWidgets. - Description
- Matchers build up their error messages by appending to Description objects.
- DocBlock
- Abstract base class for all documentation blocks in Widgetbook.
- DoubleArg
- DoubleArgStyle
- DoubleInputField
- A Field that builds TextFormField for double values.
- DoubleSliderField
- A Field that builds Slider for double values.
- DropdownSingleArgStyle
- DurationArg
- DurationField
- A Field that represents a Duration value.
-
EnumArg<
T extends Enum> -
Field<
T> - Base class for all input fields in Widgetbook.
-
FieldsComposable<
T> - A FieldsComposable is a collection or a group of Fields that can be used to create a settings panel in Widgetbook. Each field in the group should have a unique name and can be used to configure addons or knobs.
- Finder
- A base class for creating finders that search the Element tree for Widgets.
-
FinderBase<
CandidateType> - Encapsulates the logic for searching a list of candidates and filtering the candidates to only those that meet the requirements defined by the finder.
-
FinderResult<
CandidateType> - The results of searching with a FinderBase.
- GridAddon
- InputDoubleArgStyle
- InputIntArgStyle
- IntArg
- IntArgStyle
- Integration
- Integrations are like lifecycle hooks that notifies implementer about WidgetbookState changes.
- IntInputField
- A Field that builds TextFormField for int values.
- IntSliderField
- A Field that builds Slider for int values.
- IosViewports
- A collection of predefined iOS viewports.
-
IterableArg<
T> -
IterableSegmentedField<
T> - A Field that builds SegmentedButton<Iterable<T>> for Iterable values.
- LinuxViewports
- A collection of predefined Linux viewports.
- LocaleAddon
- An Addon for changing the active Locale via Localizations.
- LocaleMode
- MacosViewports
- A collection of predefined macOS viewports.
- Matcher
- The base class for all matchers.
- MatchFinder
- Searches candidates for any that match a particular pattern.
- MaterialThemeAddon
- An Addon for changing the active ThemeData via Theme.
- MaterialThemeMode
-
Meta<
TWidget extends Widget> -
Metadata for generating code for a given
TWidget. -
MetaWithArgs<
TWidget extends Widget, TArgs> - Same as Meta but for custom StoryArgs.
-
Mode<
T> -
A Mode represents a specific configuration or state of an Addon.
It holds a value of type
Tthat defines the current setting of the addon. - NullableBoolArg
- NullableColorArg
- NullableDateTimeArg
- NullableDoubleArg
- NullableDurationArg
-
NullableEnumArg<
T extends Enum> - NullableIntArg
-
NullableIterableArg<
T> -
NullableSingleArg<
T> - NullableStringArg
-
NumInputField<
T extends num> - A base class for Fields that represent num values using a TextField.
-
NumSliderField<
T extends num> - A base class for Fields that represent num values using a slider.
-
ObjectDropdownField<
T> -
A Field that builds DropdownMenu<
T> for Object values. -
ObjectSegmentedField<
T> -
A Field that builds SegmentedButton<
T> for Object values. - OnPlatform
- An annotation for platform-specific customizations for a test suite.
- QueryGroup
- Retry
- An annotation for marking a test suite to be retried.
-
Scenario<
TWidget extends Widget, TArgs extends StoryArgs< TWidget> > - ScenarioConfig
- Configuration applied to every Scenario discovered from a Config.
- ScenarioDefinition
- Defines a template for generating scenarios.
- SegmentedSingleArgStyle
- SemanticsAddon
- An Addon for semantics.
- SemanticsFinder
- A base class for creating finders that search the semantics tree.
- SemanticsHandle
- A reference to the semantics information generated by the framework.
- SemanticsMode
-
SingleArg<
T> - SingleArgStyle
- Skip
- An annotation for marking a test suite as skipped.
- SliderDoubleArgStyle
- SliderIntArgStyle
- StoriesDocBlock
- A DocBlock that displays all stories for the current component.
-
Story<
TWidget extends Widget, TArgs extends StoryArgs< TWidget> > -
StoryArgs<
T> - StoryDocBlock
- A DocBlock that displays a single Story and its StoryArgs.
- StreamMatcher
-
A matcher that matches events from Streams or
StreamQueues. - StringArg
- StringDescription
- The default implementation of Description. This should rarely need substitution, although conceivably it is a place where other languages could be supported.
- StringField
- A Field that builds TextFormField for String values.
-
StyledArg<
T, TStyle> - An Arg that is associated with a style to define its UI representation.
- SubtitleDocBlock
- A DocBlock that displays text in subtitle styling in the documentation panel.
- Tags
- An annotation for applying a set of user-defined tags to a test suite.
- TargetPlatformVariant
- A TestVariant that runs tests with debugDefaultTargetPlatformOverride set to different values of TargetPlatform.
- TestOn
- An annotation indicating which platforms a test suite supports.
-
TestVariant<
T> - An abstract base class for describing test environment variants.
- TextDocBlock
- A DocBlock that displays a block of text in the documentation panel.
- TextRangeContext
-
The
CandidateTypeof finders that search for and filter substrings, within static text rendered by RenderParagraphs. - TextScaleAddon
- TextScaleMode
- An Addon for changing the active MediaQueryData.textScaler via MediaQuery.
-
ThemeAddon<
T> - An Addon for changing the active custom theme. A builder must be provided that returns an InheritedWidget or similar Widgets.
-
ThemeMode<
T> - Throws
- Use the throwsA function instead.
- TimeDilationAddon
- TimeDilationMode
- An Addon for changing timeDilation.
- Timeout
- A class representing a modification to the default timeout for a test.
- TitleDocBlock
- A DocBlock that displays a title in the documentation panel.
-
TypeMatcher<
T> - A Matcher subclass that supports validating the Type of the target object.
-
ValueVariant<
T> - A TestVariant that runs separate tests with each of the given values.
- ViewportAddon
- An Addon that allows switching between different viewports.
- ViewportData
- Data class representing a viewport configuration.
- ViewportMode
- Viewports
- A collection of all predefined viewports across platforms.
- WidgetbookState
- Central state management for the Widgetbook application.
- WidgetDocBlock
- A DocBlock that displays a custom widget in the documentation.
- WidgetTester
- Class that programmatically interacts with widgets and the test environment.
- WindowsViewports
- A collection of predefined Windows viewports.
- ZoomAddon
- An Addon for zoom/scaling.
- ZoomMode
Enums
- ColorSpace
- Represents the different color space formats that can be used for color representation and conversion.
- LayoutPanel
- Represents the main sections of the Widgetbook layout.
- Plurality
- Describes how a string of text should be pluralized.
- ScenarioStrategy
- Defines how a ScenarioDefinition from ScenarioConfig.definitions is expanded into Scenarios for each Story.
- ScenarioType
Mixins
-
ChainedFinderMixin<
CandidateType> - A mixin that applies additional filtering to the results of a parent Finder.
-
MatchFinderMixin<
CandidateType> - A mixin for creating finders that search candidates for those that match a given pattern.
-
NoFields<
T> - A mixin that provides an empty implementation for FieldsComposables that do not have any fields.
-
SingleFieldOnly<
T> - Provides a default implementation for FieldsComposables that consist of a single Field only.
Extensions
-
DocBlockListExtension
on List<
DocBlock> - Extension methods for manipulating lists of DocBlocks. Provides utilities to insert or replace DocBlocks.
Constants
- anything → const Matcher
- A matcher that matches any value.
- clipsWithBoundingRect → const Matcher
- Asserts that a Finder locates a single object whose root RenderObject is a RenderClipRect with no clipper set, or an equivalent RenderClipPath.
- colorEpsilon → const double
- Default threshold for isSameColorAs and isSameColorSwatchAs.
- defaultStoryHeight → const double
- The default height in logical pixels for story previews in documentation.
- find → const CommonFinders
- Some frequently used Finders and SemanticsFinders.
- findsAny → const Matcher
- Asserts that the FinderBase locates at least one matching candidate.
- findsNothing → const Matcher
- Asserts that the FinderBase matches nothing in the available candidates.
- findsOne → const Matcher
- Asserts that the FinderBase finds exactly one matching candidate.
- findsOneWidget → const Matcher
- Asserts that the FinderBase locates at exactly one widget in the widget tree.
- findsWidgets → const Matcher
- Asserts that the FinderBase locates at least one widget in the widget tree.
- hasAGoodToStringDeep → const Matcher
- Asserts that an object's toStringDeep() is a plausible multiline description.
- hasNoImmediateClip → const Matcher
- Asserts that a Finder locates a single object whose root RenderObject is not a RenderClipRect, RenderClipRRect, RenderClipOval, or RenderClipPath.
- hasOneLineDescription → const Matcher
- Asserts that an object's toString() is a plausible one-line description.
-
isArgumentError
→ const TypeMatcher<
ArgumentError> - A matcher for ArgumentError.
-
isCastError
→ const TypeMatcher<
TypeError> - A matcher for TypeError.
-
isConcurrentModificationError
→ const TypeMatcher<
ConcurrentModificationError> - A matcher for ConcurrentModificationError.
-
isCyclicInitializationError
→ const TypeMatcher<
Error> - A matcher for Error.
- isEmpty → const Matcher
- Returns a matcher that matches the isEmpty property.
-
isException
→ const TypeMatcher<
Exception> - A matcher for Exception.
- isFalse → const Matcher
- A matcher that matches anything except the Boolean value true.
-
isFormatException
→ const TypeMatcher<
FormatException> - A matcher for FormatException.
- isInCard → const Matcher
- Asserts that the Finder locates a single widget that has at least one Card widget ancestor.
-
isList
→ const TypeMatcher<
List> - A matcher for List.
-
isMap
→ const TypeMatcher<
Map> - A matcher for Map.
- isNaN → const Matcher
- A matcher that matches the numeric value NaN.
- isNegative → const Matcher
- A matcher which matches if the match argument is negative.
- isNonNegative → const Matcher
- A matcher which matches if the match argument is zero or positive.
- isNonPositive → const Matcher
- A matcher which matches if the match argument is zero or negative.
- isNonZero → const Matcher
- A matcher which matches if the match argument is non-zero.
-
isNoSuchMethodError
→ const TypeMatcher<
NoSuchMethodError> - A matcher for NoSuchMethodError.
- isNotEmpty → const Matcher
- Returns a matcher that matches the isNotEmpty property.
- isNotInCard → const Matcher
- Asserts that the Finder locates a single widget that has no Card widget ancestors.
- isNotNaN → const Matcher
- A matcher that matches any non-NaN value.
- isNotNull → const Matcher
- A matcher that matches any non-null value.
- isNull → const Matcher
- A matcher that matches any null value.
-
isNullThrownError
→ const TypeMatcher<
TypeError> - A matcher for TypeError.
- isOffstage → const Matcher
- Asserts that the Finder locates a single widget that has at least one Offstage widget ancestor.
- isOnstage → const Matcher
- Asserts that the Finder locates a single widget that has no Offstage widget ancestors.
- isPositive → const Matcher
- A matcher which matches if the match argument is positive.
-
isRangeError
→ const TypeMatcher<
RangeError> - A matcher for RangeError.
-
isStateError
→ const TypeMatcher<
StateError> - A matcher for StateError.
- isTrue → const Matcher
- A matcher that matches the Boolean value true.
-
isUnimplementedError
→ const TypeMatcher<
UnimplementedError> - A matcher for UnimplementedError.
-
isUnsupportedError
→ const TypeMatcher<
UnsupportedError> - A matcher for UnsupportedError.
- isZero → const Matcher
- A matcher which matches if the match argument is zero.
- kDebugWarning → const String
- The warning message to show when a benchmark is performed with assert on.
- returnsNormally → const Matcher
- A matcher that matches a function call against no exception.
- scenarioNameSeparator → const String
- Separator used by defaultScenarioNameBuilder between the name of the base scenario and the name of the ScenarioDefinition it is crossed with.
- throws → const Matcher
- This function is deprecated.
- throwsArgumentError → const Matcher
- A matcher for functions that throw ArgumentError.
- throwsConcurrentModificationError → const Matcher
- A matcher for functions that throw ConcurrentModificationError.
- throwsCyclicInitializationError → const Matcher
- A matcher for functions that throw CyclicInitializationError.
- throwsException → const Matcher
- A matcher for functions that throw Exception.
- throwsFormatException → const Matcher
- A matcher for functions that throw FormatException.
- throwsNoSuchMethodError → const Matcher
- A matcher for functions that throw NoSuchMethodError.
- throwsNullThrownError → const Matcher
- A matcher for functions that throw NullThrownError.
- throwsRangeError → const Matcher
- A matcher for functions that throw RangeError.
- throwsStateError → const Matcher
- A matcher for functions that throw StateError.
- throwsUnimplementedError → const Matcher
- A matcher for functions that throw Exception.
- throwsUnsupportedError → const Matcher
- A matcher for functions that throw UnsupportedError.
Properties
- completes → Matcher
-
Matches a Future that completes successfully with any value.
final
- doesNotComplete → Matcher
-
Matches a Future that does not complete.
final
- emitsDone → StreamMatcher
-
Returns a StreamMatcher that asserts that the stream emits a "done" event.
final
-
isAssertionError
→ TypeMatcher<
AssertionError> -
A matcher for AssertionError.
final
-
isFlutterError
→ TypeMatcher<
FlutterError> -
A matcher for FlutterError.
final
- neverCalled → Null Function([Object?, Object?, Object?, Object?, Object?, Object?, Object?, Object?, Object?, Object?])
-
Returns a function that causes the test to fail if it's called.
no setter
- throwsAssertionError → Matcher
-
A matcher for functions that throw AssertionError.
final
- throwsFlutterError → Matcher
-
A matcher for functions that throw FlutterError.
final
Functions
-
$initArg<
T> (String name, Arg< T> ? userArg, Arg<T> ? defaultArg) → Arg<T> ? -
Used to initialize an Arg with either a default value or a user-provided
value.
If both
defaultArganduserArgare null, it returns null. -
addStateInfo(
Map matchState, Map values) → void - Useful utility for nesting match states.
-
addTearDown(
FutureOr callback()) → void - Registers a function to be run after the current test.
-
allOf(
Object? arg0, [Object? arg1, Object? arg2, Object? arg3, Object? arg4, Object? arg5, Object? arg6]) → Matcher - This returns a matcher that matches if all of the matchers passed as arguments (up to 7) match.
-
anyElement(
Object? valueOrMatcher) → Matcher -
Returns a matcher which matches Iterables in which at least one
element matches the given
valueOrMatcher. -
anyOf(
Object? arg0, [Object? arg1, Object? arg2, Object? arg3, Object? arg4, Object? arg5, Object? arg6]) → Matcher - Matches if any of the given matchers evaluate to true.
-
benchmarkWidgets(
WidgetTesterCallback callback, {bool mayRunWithAsserts = false, bool semanticsEnabled = false}) → Future< void> -
Runs the
callbackinside the Flutter benchmark environment. -
clipsWithBoundingRRect(
{required BorderRadius borderRadius}) → Matcher -
Asserts that a Finder locates a single object whose root RenderObject
is a RenderClipRRect with no clipper set, and border radius equals to
borderRadius, or an equivalent RenderClipPath. -
clipsWithShapeBorder(
{required ShapeBorder shape}) → Matcher -
Asserts that a Finder locates a single object whose root RenderObject
is a RenderClipPath with a ShapeBorderClipper that clips to
shape. -
closeTo(
num value, num delta) → Matcher -
Returns a matcher which matches if the match argument is within
deltaof somevalue. -
collapseWhitespace(
String string) → String - Utility function to collapse whitespace runs to single spaces and strip leading/trailing whitespace.
-
completion(
Object? matcher, [String? description]) → Matcher -
Matches a Future that completes successfully with a value that matches
matcher. -
contains(
Object? expected) → Matcher - Returns a matcher that matches if the match argument contains the expected value.
-
containsAll(
Iterable expected) → Matcher -
Matches Iterables which contain an element matching every value in
expectedin any order, and may contain additional values. -
containsAllInOrder(
Iterable expected) → Matcher -
Matches Iterables which contain an element matching every value in
expectedin the same order, but may contain additional values interleaved throughout. -
containsOnce(
Object? expected) → Matcher - Matches Iterables where exactly one element matches the expected value, and all other elements don't match.
-
containsPair(
Object? key, Object? valueOrMatcher) → Matcher -
Returns a matcher which matches maps containing the key-value pair
with
key=>valueOrMatcher. -
containsSemantics(
{String? identifier, String? traversalParentIdentifier, String? traversalChildIdentifier, String? label, AttributedString? attributedLabel, String? hint, AttributedString? attributedHint, String? value, AttributedString? attributedValue, String? increasedValue, AttributedString? attributedIncreasedValue, String? decreasedValue, AttributedString? attributedDecreasedValue, String? tooltip, TextDirection? textDirection, Rect? rect, Size? size, double? elevation, double? thickness, int? platformViewId, int? maxValueLength, int? currentValueLength, SemanticsValidationResult? validationResult, SemanticsInputType? inputType, String? maxValue, String? minValue, bool? hasCheckedState, bool? isChecked, bool? isCheckStateMixed, bool? isSelected, bool? hasSelectedState, bool? isButton, bool? isSlider, bool? isKeyboardKey, bool? isLink, bool? isFocused, bool? isFocusable, bool? isTextField, bool? isReadOnly, bool? hasEnabledState, bool? isEnabled, bool? isInMutuallyExclusiveGroup, bool? isHeader, bool? isObscured, bool? isMultiline, bool? namesRoute, bool? scopesRoute, bool? isHidden, bool? isImage, bool? isLiveRegion, bool? hasToggledState, bool? isToggled, bool? hasImplicitScrolling, bool? hasExpandedState, bool? isExpanded, bool? hasRequiredState, bool? isRequired, bool? hasTapAction, bool? hasFocusAction, bool? hasLongPressAction, bool? hasScrollLeftAction, bool? hasScrollRightAction, bool? hasScrollUpAction, bool? hasScrollDownAction, bool? hasIncreaseAction, bool? hasDecreaseAction, bool? hasShowOnScreenAction, bool? hasMoveCursorForwardByCharacterAction, bool? hasMoveCursorBackwardByCharacterAction, bool? hasMoveCursorForwardByWordAction, bool? hasMoveCursorBackwardByWordAction, bool? hasSetTextAction, bool? hasSetSelectionAction, bool? hasCopyAction, bool? hasCutAction, bool? hasPasteAction, bool? hasDidGainAccessibilityFocusAction, bool? hasDidLoseAccessibilityFocusAction, bool? hasDismissAction, String? onTapHint, String? onLongPressHint, List< CustomSemanticsAction> ? customActions, List<Matcher> ? children}) → Matcher - Asserts that a SemanticsNode contains the specified information.
-
containsValue(
Object? value) → Matcher -
Returns a matcher which matches maps containing the given
value. -
coversSameAreaAs(
Path expectedPath, {required Rect areaToCompare, int sampleSize = 20}) → Matcher - Asserts that 2 paths cover the same area by sampling multiple points.
-
cupertinoAppBuilder(
BuildContext context, Widget child) → Widget -
defaultDocsBuilder(
) → List< DocBlock> -
defaultMergeModes(
List< Mode> storyModes, List<Mode> scenarioModes) → List<Mode> - The default function to merge modes of a story and a scenario. It puts the modes of the scenario first, and then adds the modes of the story that are not already defined in the scenario.
-
defaultScenarioNameBuilder(
ScenarioDefinition definition, Story< Widget, StoryArgs< story, Scenario<Widget> >Widget, StoryArgs< scenario) → StringWidget> > - The default ScenarioNameBuilder.
-
doesNotMeetGuideline(
AccessibilityGuideline guideline) → AsyncMatcher - The inverse matcher of meetsGuideline.
-
emits(
Object? matcher) → StreamMatcher -
Returns a StreamMatcher for
matcher. -
emitsAnyOf(
Iterable matchers) → StreamMatcher -
Returns a StreamMatcher that matches the stream if at least one of
matchersmatches. -
emitsError(
Object? matcher) → StreamMatcher -
Returns a StreamMatcher that matches a single error event that matches
matcher. -
emitsInAnyOrder(
Iterable matchers) → StreamMatcher -
Returns a StreamMatcher that matches the stream if each matcher in
matchersmatches, in any order. -
emitsInOrder(
Iterable matchers) → StreamMatcher -
Returns a StreamMatcher that matches the stream if each matcher in
matchersmatches, one after another. -
emitsThrough(
Object? matcher) → StreamMatcher -
Returns a StreamMatcher that matches any number of events followed by
events that match
matcher. -
endsWith(
String suffixString) → Matcher -
Returns a matcher that matches if the match argument is a string and
ends with
suffixString. -
equals(
Object? expected, [int limit = 100]) → Matcher -
Returns a matcher that matches if the value is structurally equal to
expected. -
equalsIgnoringCase(
String value) → Matcher -
Returns a matcher which matches if the match argument is a string and
is equal to
valuewhen compared case-insensitively. -
equalsIgnoringHashCodes(
Object value) → Matcher -
Asserts that two Strings or
Iterable<String>s are equal after normalizing likely hash codes. -
equalsIgnoringWhitespace(
String value) → Matcher -
Returns a matcher which matches if the match argument is a string and
is equal to
value, ignoring whitespace. -
escape(
String str) → String -
Returns
strwith all whitespace characters represented as their escape sequences. -
everyElement(
Object? valueOrMatcher) → Matcher -
Returns a matcher which matches Iterables in which all elements
match the given
valueOrMatcher. -
expect(
dynamic actual, dynamic matcher, {String? reason, dynamic skip}) → void -
Assert that
actualmatchesmatcher. -
expectAsync(
Function callback, {int count = 1, int max = 0, String? id, String? reason}) → Function - This function is deprecated because it doesn't work well with strong mode. Use expectAsync0, expectAsync1, expectAsync2, expectAsync3, expectAsync4, expectAsync5, or expectAsync6 instead.
-
expectAsync0<
T> (T callback(), {int count = 1, int max = 0, String? id, String? reason}) → Func0< T> -
Informs the framework that the given
callbackof arity 0 is expected to be calledcountnumber of times (by default 1). -
expectAsync1<
T, A> (T callback(A), {int count = 1, int max = 0, String? id, String? reason}) → Func1< T, A> -
Informs the framework that the given
callbackof arity 1 is expected to be calledcountnumber of times (by default 1). -
expectAsync2<
T, A, B> (T callback(A, B), {int count = 1, int max = 0, String? id, String? reason}) → Func2< T, A, B> -
Informs the framework that the given
callbackof arity 2 is expected to be calledcountnumber of times (by default 1). -
expectAsync3<
T, A, B, C> (T callback(A, B, C), {int count = 1, int max = 0, String? id, String? reason}) → Func3< T, A, B, C> -
Informs the framework that the given
callbackof arity 3 is expected to be calledcountnumber of times (by default 1). -
expectAsync4<
T, A, B, C, D> (T callback(A, B, C, D), {int count = 1, int max = 0, String? id, String? reason}) → Func4< T, A, B, C, D> -
Informs the framework that the given
callbackof arity 4 is expected to be calledcountnumber of times (by default 1). -
expectAsync5<
T, A, B, C, D, E> (T callback(A, B, C, D, E), {int count = 1, int max = 0, String? id, String? reason}) → Func5< T, A, B, C, D, E> -
Informs the framework that the given
callbackof arity 5 is expected to be calledcountnumber of times (by default 1). -
expectAsync6<
T, A, B, C, D, E, F> (T callback(A, B, C, D, E, F), {int count = 1, int max = 0, String? id, String? reason}) → Func6< T, A, B, C, D, E, F> -
Informs the framework that the given
callbackof arity 6 is expected to be calledcountnumber of times (by default 1). -
expectAsyncUntil0<
T> (T callback(), bool isDone(), {String? id, String? reason}) → Func0< T> -
Informs the framework that the given
callbackof arity 0 is expected to be called untilisDonereturns true. -
expectAsyncUntil1<
T, A> (T callback(A), bool isDone(), {String? id, String? reason}) → Func1< T, A> -
Informs the framework that the given
callbackof arity 1 is expected to be called untilisDonereturns true. -
expectAsyncUntil2<
T, A, B> (T callback(A, B), bool isDone(), {String? id, String? reason}) → Func2< T, A, B> -
Informs the framework that the given
callbackof arity 2 is expected to be called untilisDonereturns true. -
expectAsyncUntil3<
T, A, B, C> (T callback(A, B, C), bool isDone(), {String? id, String? reason}) → Func3< T, A, B, C> -
Informs the framework that the given
callbackof arity 3 is expected to be called untilisDonereturns true. -
expectAsyncUntil4<
T, A, B, C, D> (T callback(A, B, C, D), bool isDone(), {String? id, String? reason}) → Func4< T, A, B, C, D> -
Informs the framework that the given
callbackof arity 4 is expected to be called untilisDonereturns true. -
expectAsyncUntil5<
T, A, B, C, D, E> (T callback(A, B, C, D, E), bool isDone(), {String? id, String? reason}) → Func5< T, A, B, C, D, E> -
Informs the framework that the given
callbackof arity 5 is expected to be called untilisDonereturns true. -
expectAsyncUntil6<
T, A, B, C, D, E, F> (T callback(A, B, C, D, E, F), bool isDone(), {String? id, String? reason}) → Func6< T, A, B, C, D, E, F> -
Informs the framework that the given
callbackof arity 6 is expected to be called untilisDonereturns true. -
expectLater(
dynamic actual, dynamic matcher, {String? reason, dynamic skip}) → Future< void> - Just like expect, but returns a Future that completes when the matcher has finished matching.
-
expectSync(
dynamic actual, dynamic matcher, {String? reason}) → void -
Assert that
actualmatchesmatcher. -
fail(
String message) → Never -
Convenience method for throwing a new TestFailure with the provided
message. -
findsAtLeast(
int n) → Matcher - Asserts that the FinderBase locates at least the given number of candidates.
-
findsAtLeastNWidgets(
int n) → Matcher - Asserts that the FinderBase locates at least a number of widgets in the widget tree.
-
findsExactly(
int n) → Matcher - Asserts that the FinderBase locates the specified number of candidates.
-
findsNWidgets(
int n) → Matcher - Asserts that the FinderBase locates the specified number of widgets in the widget tree.
-
greaterThan(
Object value) → Matcher -
Returns a matcher which matches if the match argument is greater
than the given
value. -
greaterThanOrEqualTo(
Object value) → Matcher -
Returns a matcher which matches if the match argument is greater
than or equal to the given
value. -
hasLength(
Object? matcher) → Matcher -
Returns a matcher that matches if an object has a length property
that matches
matcher. -
inClosedOpenRange(
num low, num high) → Matcher -
Returns a matcher which matches if the match argument is greater
than or equal to a
lowand less thanhigh. -
inExclusiveRange(
num low, num high) → Matcher -
Returns a matcher which matches if the match argument is greater
than
lowand less thanhigh. -
inInclusiveRange(
num low, num high) → Matcher -
Returns a matcher which matches if the match argument is greater
than or equal to
lowand less than or equal tohigh. -
inOpenClosedRange(
num low, num high) → Matcher -
Returns a matcher which matches if the match argument is greater
than
lowand less than or equal tohigh. -
isA<
T> () → TypeMatcher< T> -
Returns a matcher that matches objects with type
T. -
isAccessibilityAnnouncement(
String message, {TextDirection? textDirection, Assertiveness? assertiveness, int? viewId}) → Matcher - Asserts that a CapturedAccessibilityAnnouncement matches the expected message.
-
isIn(
Object? expected) → Matcher - Returns a matcher that matches if the match argument is in the expected value. This is the converse of contains.
-
isInstanceOf<
T> () → TypeMatcher< T> - A matcher that compares the type of the actual value to the type argument T.
-
isMethodCall(
String name, {required dynamic arguments}) → Matcher -
A matcher for MethodCalls, asserting that it has the specified
method
nameandarguments. -
isNot(
Object? valueOrMatcher) → Matcher -
Returns a matcher that inverts
valueOrMatcherto its logical negation. -
isRenderObjectAncestorOfTarget(
RenderObject renderObject, HitTestTarget target) → bool -
Returns true if
renderObjectis equal totargetor is an ancestor oftargetin the render tree. -
isSameColorAs(
Color color, {double threshold = colorEpsilon}) → Matcher -
Asserts that the object represents the same color as
colorwhen used to paint. -
isSameColorSwatchAs<
T> (ColorSwatch< T> color, {double threshold = colorEpsilon}) → Matcher -
Asserts that the object represents the same color swatch as
colorwhen used to paint. -
isSemantics(
{String? identifier, String? traversalParentIdentifier, String? traversalChildIdentifier, String? label, AttributedString? attributedLabel, String? hint, AttributedString? attributedHint, String? value, AttributedString? attributedValue, String? increasedValue, AttributedString? attributedIncreasedValue, String? decreasedValue, AttributedString? attributedDecreasedValue, String? tooltip, TextDirection? textDirection, Rect? rect, Size? size, double? elevation, double? thickness, int? platformViewId, int? maxValueLength, int? currentValueLength, SemanticsValidationResult? validationResult, SemanticsInputType? inputType, String? maxValue, String? minValue, bool? hasCheckedState, bool? isChecked, bool? isCheckStateMixed, bool? isSelected, bool? hasSelectedState, bool? isButton, bool? isSlider, bool? isKeyboardKey, bool? isLink, bool? isFocused, bool? isFocusable, bool? isTextField, bool? isReadOnly, bool? hasEnabledState, bool? isEnabled, bool? isInMutuallyExclusiveGroup, bool? isHeader, bool? isObscured, bool? isMultiline, bool? namesRoute, bool? scopesRoute, bool? isHidden, bool? isImage, bool? isLiveRegion, bool? hasToggledState, bool? isToggled, bool? hasImplicitScrolling, bool? hasExpandedState, bool? isExpanded, bool? hasRequiredState, bool? isRequired, bool? hasTapAction, bool? hasFocusAction, bool? hasLongPressAction, bool? hasScrollLeftAction, bool? hasScrollRightAction, bool? hasScrollUpAction, bool? hasScrollDownAction, bool? hasIncreaseAction, bool? hasDecreaseAction, bool? hasShowOnScreenAction, bool? hasMoveCursorForwardByCharacterAction, bool? hasMoveCursorBackwardByCharacterAction, bool? hasMoveCursorForwardByWordAction, bool? hasMoveCursorBackwardByWordAction, bool? hasSetTextAction, bool? hasSetSelectionAction, bool? hasCopyAction, bool? hasCutAction, bool? hasPasteAction, bool? hasDidGainAccessibilityFocusAction, bool? hasDidLoseAccessibilityFocusAction, bool? hasDismissAction, String? onTapHint, String? onLongPressHint, List< CustomSemanticsAction> ? customActions, List<Matcher> ? children}) → Matcher - Asserts that a SemanticsNode contains the specified information.
-
isSorted<
T extends Comparable< (T> >) → Matcher - Matches Iterables which are sorted.
-
isSortedBy<
T, K extends Comparable< (K> >K keyOf(T)) → Matcher -
Matches Iterables which are sorted by the
keyOfproperty. -
isSortedByCompare<
T, K> (K keyOf(T), Comparator< K> compare) → Matcher -
Matches Iterables which are
compare-sorted by theirkeyOfproperty. -
isSortedUsing<
T> (Comparator< T> compare) → Matcher -
Matches Iterables which are
compare-sorted. -
isSystemTextScaler(
{double? withScaleFactor}) → Matcher - Asserts that the object is a TextScaler that reflects the user's font scale preferences from the platform's accessibility settings.
-
lessThan(
Object value) → Matcher -
Returns a matcher which matches if the match argument is less
than the given
value. -
lessThanOrEqualTo(
Object value) → Matcher -
Returns a matcher which matches if the match argument is less
than or equal to the given
value. -
markTestSkipped(
String message) → void - Marks the current test as skipped.
-
matches(
Pattern re) → Matcher -
Returns a matcher that matches if the match argument is a string and
matches the regular expression given by
re. -
matchesGoldenFile(
Object key, {int? version}) → AsyncMatcher -
Asserts that a Finder, Future<ui.Image>, or ui.Image matches the
golden image file identified by
key, with an optionalversionnumber. -
matchesReferenceImage(
Image image) → AsyncMatcher -
Asserts that a Finder, Future<ui.Image>, or ui.Image matches a
reference image identified by
image. -
matchesSemantics(
{String? identifier, String? traversalParentIdentifier, String? traversalChildIdentifier, String? label, AttributedString? attributedLabel, String? hint, AttributedString? attributedHint, String? value, AttributedString? attributedValue, String? increasedValue, AttributedString? attributedIncreasedValue, String? decreasedValue, AttributedString? attributedDecreasedValue, String? tooltip, TextDirection? textDirection, Rect? rect, Size? size, double? elevation, double? thickness, int? platformViewId, int? maxValueLength, int? currentValueLength, SemanticsValidationResult validationResult = SemanticsValidationResult.none, SemanticsInputType? inputType, String? maxValue, String? minValue, bool hasCheckedState = false, bool isChecked = false, bool isCheckStateMixed = false, bool isSelected = false, bool hasSelectedState = false, bool isButton = false, bool isSlider = false, bool isKeyboardKey = false, bool isLink = false, bool isFocused = false, bool isFocusable = false, bool isTextField = false, bool isReadOnly = false, bool hasEnabledState = false, bool isEnabled = false, bool isInMutuallyExclusiveGroup = false, bool isHeader = false, bool isObscured = false, bool isMultiline = false, bool namesRoute = false, bool scopesRoute = false, bool isHidden = false, bool isImage = false, bool isLiveRegion = false, bool hasToggledState = false, bool isToggled = false, bool hasImplicitScrolling = false, bool hasExpandedState = false, bool isExpanded = false, bool hasRequiredState = false, bool isRequired = false, bool hasTapAction = false, bool hasFocusAction = false, bool hasLongPressAction = false, bool hasScrollLeftAction = false, bool hasScrollRightAction = false, bool hasScrollUpAction = false, bool hasScrollDownAction = false, bool hasIncreaseAction = false, bool hasDecreaseAction = false, bool hasShowOnScreenAction = false, bool hasMoveCursorForwardByCharacterAction = false, bool hasMoveCursorBackwardByCharacterAction = false, bool hasMoveCursorForwardByWordAction = false, bool hasMoveCursorBackwardByWordAction = false, bool hasSetTextAction = false, bool hasSetSelectionAction = false, bool hasCopyAction = false, bool hasCutAction = false, bool hasPasteAction = false, bool hasDidGainAccessibilityFocusAction = false, bool hasDidLoseAccessibilityFocusAction = false, bool hasDismissAction = false, String? onTapHint, String? onLongPressHint, List< CustomSemanticsAction> ? customActions, List<Matcher> ? children}) → Matcher - Asserts that a SemanticsNode contains the specified information.
-
materialAppBuilder(
BuildContext context, Widget child) → Widget -
matrix3MoreOrLessEquals(
Matrix3 value, {double epsilon = precisionErrorTolerance}) → Matcher -
Asserts that two
Matrix3s are equal, within some tolerated error. -
matrixMoreOrLessEquals(
Matrix4 value, {double epsilon = precisionErrorTolerance}) → Matcher - Asserts that two Matrix4s are equal, within some tolerated error.
-
mayEmit(
Object? matcher) → StreamMatcher -
Returns a StreamMatcher that allows (but doesn't require)
matcherto match the stream. -
mayEmitMultiple(
Object? matcher) → StreamMatcher -
Returns a StreamMatcher that matches any number of events that match
matcher. -
meetsGuideline(
AccessibilityGuideline guideline) → AsyncMatcher -
Asserts that the currently rendered widget meets the provided accessibility
guideline. -
moreOrLessEquals(
double value, {double epsilon = precisionErrorTolerance}) → Matcher - Asserts that two doubles are equal, within some tolerated error.
-
neverEmits(
Object? matcher) → StreamMatcher -
Returns a StreamMatcher that matches a stream that never matches
matcher. -
offsetMoreOrLessEquals(
Offset value, {double epsilon = precisionErrorTolerance}) → Matcher - Asserts that two Offsets are equal, within some tolerated error.
-
orderedEquals(
Iterable expected) → Matcher -
Returns a matcher which matches Iterables that have the same
length and the same elements as
expected, in the same order. -
pairwiseCompare<
S, T> (Iterable< S> expected, bool comparator(S, T), String description) → Matcher - A pairwise matcher for Iterables.
-
predicate<
T> (bool f(T), [String description = 'satisfies function']) → Matcher - Returns a matcher that uses an arbitrary function that returns whether the value is considered a match.
-
printOnFailure(
String message) → void -
Prints
messageif and when the current test fails. -
prints(
Object? matcher) → Matcher -
Matches a Function that prints text that matches
matcher. -
pumpEventQueue(
{int times = 20}) → Future -
Returns a Future that completes after the event loop has run the given
number of
times(20 by default). -
rectMoreOrLessEquals(
Rect value, {double epsilon = precisionErrorTolerance}) → Matcher - Asserts that two Rects are equal, within some tolerated error.
-
registerException(
Object error, [StackTrace stackTrace = StackTrace.empty]) → void - Registers an exception that was caught for the current test.
-
rendersOnPhysicalModel(
{BoxShape? shape, BorderRadius? borderRadius, double? elevation}) → Matcher - Asserts that a Finder locates a single object whose root RenderObject is a RenderPhysicalModel or a RenderPhysicalShape.
-
rendersOnPhysicalShape(
{required ShapeBorder shape, double? elevation}) → Matcher -
Asserts that a Finder locates a single object whose root RenderObject
is RenderPhysicalShape that uses a ShapeBorderClipper that clips to
shapeas its clipper. Ifelevationis non null asserts thatRenderPhysicalShape.elevationis equal toelevation. -
runWidgetbook(
Config config) → void -
same(
Object? expected) → Matcher -
Returns a matches that matches if the value is the same instance
as
expected, using identical. -
spawnHybridCode(
String dartCode, {Object? message, bool stayAlive = false}) → StreamChannel -
Spawns a VM isolate that runs the given
dartCode, which is loaded as the contents of a Dart library. -
spawnHybridUri(
Object uri, {Object? message, bool stayAlive = false}) → StreamChannel -
Spawns a VM isolate for the given
uri, which may be a Uri or a String. -
startsWith(
String prefixString) → Matcher -
Returns a matcher that matches if the match argument is a string and
starts with
prefixString. -
stringContainsInOrder(
List< String> substrings) → Matcher -
Returns a matcher that matches if the match argument is a string and
contains a given list of
substringsin relative order. -
testWidgets(
String description, WidgetTesterCallback callback, {bool? skip, Timeout? timeout, bool semanticsEnabled = true, TestVariant< Object?> variant = const DefaultTestVariant(), dynamic tags, int? retry, LeakTesting? experimentalLeakTesting}) → void -
Runs the
callbackinside the Flutter test environment. -
throwsA(
Object? matcher) → Matcher - This can be used to match three kinds of objects:
-
tryDecodeComponent(
String component) → String? -
Decodes
componentusing Uri.decodeComponent, but returns null if the decoding fails due to non-ASCII characters. -
unorderedEquals(
Iterable expected) → Matcher -
Returns a matcher which matches Iterables that have the same length and
the same elements as
expected, but not necessarily in the same order. -
unorderedMatches(
Iterable expected) → Matcher -
Returns a matcher which matches Iterables whose elements match the
matchers in
expected, but not necessarily in the same order. -
widgetsAppBuilder(
BuildContext context, Widget child) → Widget -
within<
T> ({required num distance, required T from, DistanceFunction< T> ? distanceFunction}) → Matcher - Asserts that two values are within a certain distance from each other.
-
wrapMatcher(
Object? valueOrMatcher) → Matcher - Takes an argument and returns an equivalent Matcher.
Typedefs
- AnyDistanceFunction = num Function(Never a, Never b)
- The type of a union of instances of DistanceFunction<T> for various types T.
- AppBuilder = Widget Function(BuildContext context, Widget child)
- Function signature for building the app wrapper around use cases.
-
ArgBuilder<
T> = T Function(BuildContext context) - ChildBuilder = Widget Function(BuildContext context, Widget child)
- DescribeMatchCallback = String Function(Plurality plurality)
- Signature for FinderBase.describeMatch.
-
DistanceFunction<
T> = num Function(T a, T b) - Computes the distance between two values.
-
DocsBuilderFunction
= List<
DocBlock> Function(List<DocBlock> blocks) - Signature for a function that takes a list of DocBlocks and returns a new list of DocBlocks.
- ElementPredicate = bool Function(Element element)
- Signature for CommonFinders.byElementPredicate.
- ErrorFormatter = String Function(Object? actual, Matcher matcher, String? reason, Map matchState, bool verbose)
-
The type used for functions that can be used to build up error reports
upon failures in
expect. -
Func0<
T> = T Function() -
Func1<
T, A> = T Function([A a]) -
Func2<
T, A, B> = T Function([A a, B b]) -
Func3<
T, A, B, C> = T Function([A a, B b, C c]) -
Func4<
T, A, B, C, D> = T Function([A a, B b, C c, D d]) -
Func5<
T, A, B, C, D, E> = T Function([A a, B b, C c, D d, E e]) -
Func6<
T, A, B, C, D, E, F> = T Function([A a, B b, C c, D d, E e, F f]) -
ModesMerger
= List<
Mode> Function(List<Mode> storyModes, List<Mode> scenarioModes) -
ScenarioCallback
= Future<
void> Function(WidgetTester tester, Scenario<Widget, StoryArgs< scenario)Widget> > - Callback invoked around each Scenario run by testWidgetbook.
-
ScenarioNameBuilder
= String Function(ScenarioDefinition definition, Story<
Widget, StoryArgs< story, Scenario<Widget> >Widget, StoryArgs< scenario)Widget> > - Builds the name of a crossed Scenario that is generated when a ScenarioDefinition with ScenarioStrategy.perScenario or ScenarioStrategy.both is applied to a Story.
-
ScenarioRunner<
TArgs extends StoryArgs> = Future< void> Function(WidgetTester tester, TArgs args) -
ScenarioWrapper
= Future<
void> Function(WidgetTester tester, Scenario<Widget, StoryArgs< scenario, Future<Widget> >void> body()) - Callback wrapping the entire execution of a Scenario during testWidgetbook.
- SemanticsNodePredicate = bool Function(SemanticsNode node)
- Signature for CommonSemanticsFinders.byPredicate.
-
SetupBuilder<
TWidget extends Widget, TArgs extends StoryArgs< TWidget> > = Widget Function(BuildContext context, Widget child, TArgs args) -
StoryWidgetBuilder<
TWidget extends Widget, TArgs extends StoryArgs< TWidget> > = TWidget Function(BuildContext context, TArgs args) -
ThemeBuilder<
T> = Widget Function(BuildContext context, T theme, Widget child) - WidgetPredicate = bool Function(Widget widget)
- Signature for CommonFinders.byWidgetPredicate.
-
WidgetTesterCallback
= Future<
void> Function(WidgetTester tester) - Signature for callback to testWidgets and benchmarkWidgets.
Exceptions / Errors
- TestFailure
- An exception thrown when a test assertion fails.