小编Gwh*_*yyy的帖子

为什么将块提供程序放在单独的文件/类中会引发错误?

我有这个代码:

MultiBlocProvider(
  providers: [
    BlocProvider(
      create: (context) => CubitExample(),
    ),
  ],
  child: MaterialApp(
    home: Home(),
  ),
);
Run Code Online (Sandbox Code Playgroud)

它工作正常,我有很多肘节/块,所以我决定将提供者列表移动到一个单独的类:

MultiBlocProvider(
  providers: BlocProviders.blocs(),
  child: MaterialApp(
    home: Home(),
  ),
);
Run Code Online (Sandbox Code Playgroud)
// The class 
class BlocProviders {
  static List<BlocProvider> blocs() {
    return <BlocProvider>[
      BlocProvider(
        create: (context) => CubitExample(()),
      ),
    ];
  }
}
Run Code Online (Sandbox Code Playgroud)

现在抛出通常的块错误:

ProviderNotFoundException (Error: Could not find the correct Provider<ExampleCubit> above this BlocBuilder<ExampleCubit, ExampleState> Widget
Run Code Online (Sandbox Code Playgroud)

我不知道为什么当我尝试第二个代码时会抛出错误,为什么会抛出错误?

dart flutter bloc flutter-provider flutter-bloc

3
推荐指数
1
解决办法
456
查看次数

在 Flutter SDK 中找不到包 flutter_localization

我目前正在尝试在我的 Flutter 应用程序中实现本地化,但每当我尝试添加 的依赖项时flutter_localization,我都会收到以下错误消息:

由于定时器依赖的SDK不存在(在Flutter SDK中flutter_localization找不到包),版本解析失败。flutter_localization

我还在 Android Studio 中正确添加了 flutter 和 dart SDK 的路径。

这是我的pubspec.yaml文件:

publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.0.0+1

environment:
  sdk: '>=2.18.2 <3.0.0'

dependencies:
  flutter:
    sdk: flutter
  intl: ^0.17.0-nullsafety.2
  cupertino_icons: ^1.0.2
  sqflite: any
  shared_preferences: ^2.0.15
  path_provider: any
  flutter_localization:
    sdk: flutter
  flutter_cupertino_localizations: ^1.0.1

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^2.0.0

flutter:

  uses-material-design: true

Run Code Online (Sandbox Code Playgroud)

如果没有 flutter_localization,我无法访问 GlobalMaterialLocalizations,显然,这是最简单的解决方案。我已经尝试过许多解决方案,例如检查版本兼容性和更新所有依赖项。你们能帮我吗?

提前致谢!

升级SDK、升级依赖、重新安装flutter和Dart等

dependencies dart flutter flutter-localizations

2
推荐指数
1
解决办法
2396
查看次数

The element type 'int' can't be assigned to the map value type 'FieldValue' when trying to assign a new value

I have initial data which works fine.

var data = {field1: FieldValue.increment(1)};
Run Code Online (Sandbox Code Playgroud)

And it is also fine when I add another field to the data.

data.addAll({field2: FieldValue.increment(1)});
Run Code Online (Sandbox Code Playgroud)

But if I set the value to 0, it won't allow me to.

data.addAll({field3: 0});
Run Code Online (Sandbox Code Playgroud)

It will give an error of: The element type 'int' can't be assigned to the map value type 'FieldValue'.

I tried doing this but still, have the same issue.

data[field3] = 0;
Run Code Online (Sandbox Code Playgroud)

How will I set the field3 …

dart firebase flutter

2
推荐指数
1
解决办法
639
查看次数

Jitsi meet in flutter 不适用于 android 12

我已经集成了 jitsi_flutter 用于群组通话。但是,该应用程序未安装在最新的 Android 支持版本 12 中。

这是我使用过的 jitsi_flutter 的链接。 https://github.com/gunschu/jitsi_meet

当我尝试在 Android 12 支持的设备上运行该应用程序时,我遇到了此问题。

adb: failed to install E:\Flutter\flutter_jitsi\build\app\outputs\flutter-apk\app.apk: Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl502165721.tmp/base.apk (at Binary XML file line #110): org.jitsi.meet.sdk.ConnectionService: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]
Error launching application on sdk gphone64 x86 64.
Run Code Online (Sandbox Code Playgroud)

android flutter jitsi-meet lib-jitsi-meet android-12

1
推荐指数
1
解决办法
3041
查看次数

在颤振中全屏设置加载/进度的最佳方法是什么

我想在开始加载时添加带有灰色背景的全屏加载以FullScreen覆盖其中。

过去,我使用了Stack小部件,但堆栈没有覆盖我的应用程序栏。

我认为添加ScaffoldStack部件并不是一个好方法

dart flutter flutter-layout

0
推荐指数
1
解决办法
9660
查看次数