When I try to test Widget that contains
hintText: LocalizationResources.of(context).writecomment
I get an Exception saying:
The following NoSuchMethodError was thrown building CommentInput(dirty, state: _CommentInputState#32224): The getter 'writecomment' was called on null.
So, is there something that I'm missing? Widget builds nicely on a device and a simulator.
This is how my test looks like:
....
final Widget widget =
MaterialApp(home: CommentWallWidget(channelUid: '123456'), title: 'jelena',);
await tester.pumpWidget(widget);
And the LocalizationResources is just simple l10n:
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'l10n/messages_all.dart';
///class containing localization logic and string getters
class LocalizationResources {
static Future<LocalizationResources> load(Locale locale) {
final String name =
locale.countryCode.isEmpty ? locale.languageCode : locale.toString();
final String localeName = Intl.canonicalizedLocale(name);
return initializeMessages(localeName).then((_) {
Intl.defaultLocale = localeName;
return LocalizationResources();
});
}
static LocalizationResources of(BuildContext context) {
return Localizations.of<LocalizationResources>(
context, LocalizationResources);
}
....
Aucun commentaire:
Enregistrer un commentaire