小编Nie*_*ijk的帖子

Flutter Application Bloc 侦听器未接收状态更新

我使用 flutter Bloc 将用户导航到登录页面或主屏幕,具体取决于用户是否经过身份验证。但是,在初始状态更改后,当我更改身份验证状态时,侦听器不会触发。

听众:

Widget build(BuildContext context) {
  return BlocListener<AuthenticationBloc, AuthenticationState>(
    listener: (context, state) {
      // Listener never gets called on statechange after the initial app startup

      // navigation based on authentication 
      }
    },
    child: SplashPage(),
  );
}
Run Code Online (Sandbox Code Playgroud)

提供者在父小部件中初始化:

AuthenticationRepository authRepo = AuthenticationRepository();

Widget build(BuildContext context) {
  return MultiBlocProvider(
    providers: [
      BlocProvider<AuthenticationBloc>(
        create: (BuildContext context) =>
            AuthenticationBloc(authenticationRepository: authRepo),
      ),
      /*
         Other Providers
      */
    ],
    child: MaterialApp(
      title: 'myApp',
      home: StartUpPage(),
    ),
  );
Run Code Online (Sandbox Code Playgroud)

当用户登录时,mapEventState 在 AuthenticationBloc 中被调用:

class AuthenticationBloc
    extends …
Run Code Online (Sandbox Code Playgroud)

dart flutter bloc flutter-bloc

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

AdMob 不在 iOS 版本上投放广告。错误代码 8,找不到具有以下名称的广告网络适配器:(“com.google.DummyAdapter”)

每当我尝试在我的 iOS 应用程序的发布版本上加载广告时,我都会收到以下 admob 错误:

找不到名称为 ("com.google.DummyAdapter") 的广告网络适配器。请记住链接所有必需的广告网络适配器和 SDK,并在构建目标的“其他链接器标志”设置中设置 -ObjC。

我在我的 flutter 2.2.1 项目中使用了 google_mobile_ads 0.13.0 包。广告在应用程序的 android 版本上正确显示,我在 iOS 模拟器中从这些单元获取测试广告。

到目前为止,我已经尝试过:

  • 在构建设置的链接部分的其他链接器标志下设置“-ObjC”标志
  • 限制广告跟踪已关闭,我正在使用的 iPad 上没有这样的选项。
  • 添加 iAd.framework 以在构建阶段将二进制文件与库链接
  • 将 io.flutter.embedded_views_preview 键添加到 info.plist
  • 我已按照 google_mobile_ads 的 pub.dev 页面上的设置说明进行操作
  • 我正在使用为 iOS 配置的正确单元和应用程序 ID。
  • 自创建广告单元以来已经过了足够的时间来开始投放广告

使用的链接:

广告单元目前正被应用商店中的应用使用,而该项目正在 testflight 上进行测试。我不确定这是否对其有任何影响,看看广告如何在 android 上正常工作,android 也使用活动应用程序正在使用的单位。更改有效每千次展示费用不是一种选择,因为广告目前正在不同的实时应用中使用。但这会引发同样的问题,即为什么它适用于 android 和其他实时 iOS 应用程序。

我对 iOS 开发还是太陌生了,不知道是什么导致了这个错误,我非常感谢任何帮助解决这个问题。

admob ios flutter google-mobile-ads

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

标签 统计

flutter ×2

admob ×1

bloc ×1

dart ×1

flutter-bloc ×1

google-mobile-ads ×1

ios ×1