MaterialScreenWidgetDirector<Args> class
A specialized TestDirector for testing Flutter widgets that require a MaterialApp wrapper.
This director automatically wraps the target widget with a MaterialApp, making it suitable for testing screens or full-page widgets that depend on Material Design context.
Usage:
void main() {
late MaterialScreenWidgetDirector<(String, String)> director;
setUp(() {
director = MaterialScreenWidgetDirector<(String, String)>()
..setUnitFactory((args) => MyScreen(title: args.$1, subtitle: args.$2));
});
testWidgets('MyScreen displays correctly', (WidgetTester tester) async {
director.setArgs(('Test Title', 'Test Subtitle'));
await tester.pumpWidget(director.construct());
// Perform your test assertions here
});
}
@test For a complete example, see:
- Inheritance
-
- Object
- TestDirector<
Widget, Args> - MaterialScreenWidgetDirector
Constructors
Properties
- args ↔ Args
-
The built arguments, available after buildArgs is called.
latefinalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- unit ↔ Widget
-
The built unit, available after buildUnit is called.
latefinalinherited
Methods
-
addUnitArrangement(
Widget arrangement(Widget)) → void -
Adds an arrangement function to modify or wrap the unit after its initial creation.
inherited
-
buildArgs(
) → Args -
Builds the arguments using either the set args or the args factory.
inherited
-
buildUnit(
Args args) → Widget -
Builds the unit using the factory and applies all arrangements.
inherited
-
construct(
{Args? args}) → Widget -
Constructs the
Unitusing the providedArgs.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setArgs(
Args args) → void -
Sets the arguments directly.
inherited
-
setArgsFactory(
covariant ArgsFactory< Args> argsFactory) → void -
Sets the factory function used to create arguments.
inherited
-
setUnitFactory(
UnitFactory< Widget, Args> unitFactory) → void -
Sets the factory function used to create the initial unit.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
useMaterialApp(
) → void
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited