-
I have a Notifier:
I am mocking it with mocktail:
Supplying is at an override yields this error:
What should I do? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
extends Foo with Mock |
Beta Was this translation helpful? Give feedback.
-
This works:
|
Beta Was this translation helpful? Give feedback.
-
Hey i have the same Problem, but the solution above does not work for me. With the Line: class MockMyController extends AutoDisposeNotifier<MyModel> with Mock implements MyController {} i get this Error:
Both of the classes (AutoDisposeNotifier and MyController) have a build() method. I tried to override both of them, but this was not possible for me. Any Suggestions how to solve this Problem? This is my Code: class MockGroup extends Mock implements Group {}
// next line has the error
class MockMyController extends AutoDisposeNotifier<MyModel> with Mock implements MyController {}
void main() {
group('widget test group', () {
testWidgets('test', (tester) async {
final mockGroup = MockGroup();
final mockMyController = MockMyController();
await tester.pumpWidget(
ProviderScope(
overrides: [
// myControllerProvider has the type MyControllerFamily. I get the specific MyControllerProvider with the group-parameter
myControllerProvider(mockGroup).overrideWith(() => mockMyController),
],
child: MaterialApp(
home: Scaffold(body: TestWidget),
),
),
);
});
});
} |
Beta Was this translation helpful? Give feedback.
-
how did you return state ? |
Beta Was this translation helpful? Give feedback.
This works: