I was learning flutter about year ago and now im coming back after a break but i counter a problem, it's probalby pretty simple but i dont really understand it.
Im following a tutorial on Flutter Clean Architecture and when i'm writing my first test i have an error says "The non-nullable local variable 'mockNumberTriviaRepository' must be assigned before it can be used." I dont know how to write it to be a proper code.
My code is below:
class MockNumberTriviaRepository extends Mock
implements NumberTriviaRepository {}
void main() {
GetConcreteNumberTrivia usecase;
MockNumberTriviaRepository mockNumberTriviaRepository;
setUp(() {
MockNumberTriviaRepository mockNumberTriviaRepository = MockNumberTriviaRepository();
usecase = GetConcreteNumberTrivia(mockNumberTriviaRepository);
});
final tNumber = 1;
final tNumberTrivia = NumberTrivia(number: 1, text: 'test');
test('schould get trivia for the number from the repository', () async {
// arrange
when(**mockNumberTriviaRepository**.getConcreteNumberTrivia(1)).thenAnswer((_) async => Right(tNumberTrivia));
// act
// assert
});
}
Error appears in part between ** ** this signs after the when method in test function