TestEnvironment class

This builds a similar environment to the Flutter Widget Tree to be used for Unit Tests. This allows the environment for the widget tests and unit tests to be the same, so long as they use the same blocBuilders and repositoryBuilders.

For the Widget consumers of blocBuilders and repositoryBuilders, please look at MultiRepositoryProvider and MultiBlocProvider

Implemented types

Constructors

TestEnvironment({required List<BlocBuilder<Bloc>> blocBuilders, required List<RepositoryBuilder<Repository>> repositoryBuilders, RepositorySource? repositorySource})
Creates a test environment using blocBuilders and repositoryBuilders

Properties

blocBuilders List<BlocBuilder<Bloc>>
Creates the blocs for the environment
final
eventChannel BlocEventChannel
Convenience function to get the nearest BlocEventChannel, typically the BlocEventChannel of the last Bloc generated by blocBuilders.
no setter
hashCode int
The hash code for this object.
no setterinherited
initialized bool
Will be true once blocBuilders and repositoryBuilders have been ran.
getter/setter pair
repositoryBuilders List<RepositoryBuilder<Repository>>
Creates the repositories for the environment
final
repositorySource RepositorySource
The source for the BlocEventChannel and Repository
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Disposes this value to save memory. Implementations should be idempotent.
override
initialize() → void
Runs blocBuilders and repositoryBuilders if they haven't been ran before. You can access these using the read function.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read<T>({bool allowUninitialized = false}) → T
T will find an instance saved under that class in the environment. Will throw an error if none can be found.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited