我相信一些库已经更改,现在由于某种原因我的应用程序不再运行。我正在使用GetIt将状态注入到我的窗口小部件树中,但是由于某种原因,copyWith函数不再在我的bloc上起作用(以前已经做到了)。
在我的injection.dart文件中,我有...
import 'package:injectable/injectable.dart';
import 'package:get_it/get_it.dart';
import 'injection.config.dart';
final getIt = GetIt.instance;
@injectableInit
void configureInjection(String env) {
$initGetIt(getIt, environment: env);
}
我正常运行pub_runner构建。这样我的jection.config.dart文件将使用我的注射器程序包自动创建。
GetIt $initGetIt(
GetIt get, {
String environment,
EnvironmentFilter environmentFilter,
}) {
final gh = GetItHelper(get, environment, environmentFilter);
final firebaseInjectableModule = _$FirebaseInjectableModule();
gh.lazySingleton<FirebaseAuth>(() => firebaseInjectableModule.firebaseAuth);
gh.lazySingleton<GoogleSignIn>(() => firebaseInjectableModule.googleSignIn);
gh.lazySingleton<IAuthFacade>(
() => FirebaseAuthFacade(get<FirebaseAuth>(), get<GoogleSignIn>()));
gh.factory<SignInFormBloc>(() => SignInFormBloc(get<IAuthFacade>()));
gh.factory<ThemeBloc>(() => ThemeBloc());
return get;
}
class _$FirebaseInjectableModule extends FirebaseInjectableModule {}
在我的应用程序的根目录中,我调用了configureInjection方法。
void main() {
WidgetsFlutterBinding.ensureInitialized();
Firebase.initializeApp();
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
.then((_) {
configureInjection(Environment.dev);
runApp(Constants(
child: BlocProvider(
create: (context) => getIt<ThemeBloc>(),
child: AppWidget(),
)));
});
}
我在我的SignInFormBloc,SignInFormState或SignInFormEvent中没有进行任何更改,但是如果您认为其中可能存在引起问题的内容,可以将其张贴。我有一个带有textFields的基本ListView,会导致错误。
child: Form(
autovalidateMode: AutovalidateMode.onUserInteraction,
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return ListView(
controller: listScrollController,
children: [
SizedBox(height: UIHelper.screenHeightWithOutSafeArea(context) / 14),
const SizedBox(height: UIHelper.spaceHuge),
TextFormField(
autocorrect: false,
keyboardType: TextInputType.emailAddress,
decoration: const InputDecoration().copyWith(hintText: Constants.email),
onChanged: (value) => context.bloc<SignInFormBloc().add(SignInFormEvent.emailChanged(value)),
validator: (_) => context.bloc<SignInFormBloc().state.emailAddress.value.fold(
(leftFailure) => leftFailure.maybeMap(invalidEmail: (_) => Constants.invalidEmail,
orElse: () => null),
(rightSuccess) => null,
),
),
任何帮助将不胜感激,因为我真的不明白该错误。也许我需要提供更多信息,如果可以,请告诉我。