当我运行类似于以下代码的代码时,出现以下错误:使用不包含 Bloc 的上下文调用 BlocProvider.of()。
复制
BlocProvider(
create: (context) => getIt<TheBloc>()
child: BlocBuilder<TheBloc, TheState>(
build: (context, state) =>
MaterialButton(
onPressed: () => _showModal(context),
child: const Text('SHOW BLOC MODAL'),
),
Run Code Online (Sandbox Code Playgroud)
...
void _showModal(BuildContext context) {
showModalBottomSheet<void>(
context: context,
builder: (_) {
return MaterialButton(
onPressed() {
context.bloc<TheBloc>().add(
TheEvent.someEvent(),
);
}
child: Text('Press button to add event to bloc')
);
},
);
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 sign_in_with_apple 并且我的登录可以用于 ios,但 android 组件不起作用。
我已经浏览了文档和问题,但没有明确的答案。https://github.com/aboutyou/dart_packages/tree/master/packages/sign_in_with_apple
我坚持这个插件的文档部分说:
在您的服务器上使用 Apple 回调登录(在 WebAuthenticationOptions.redirectUri 中指定),使用以下 URL 安全地重定向回您的 Android 应用程序:
intent://callback?${PARAMETERS_FROM_CALLBACK_BODY}#Intent;package=YOUR.PACKAGE.IDENTIFIER;scheme=signinwithapple;end
PARAMETERS FROM CALLBACK BODY 应填充您在端点上从 Apple 服务器接收到的 urlencoded 正文,并且应更改包参数以匹配您的应用程序的包标识符(如在 Google Play 商店中发布的)。保持回调路径和 signinwithapple 方案不变。
此外,在客户端处理传入凭据时,请确保仅在您自己的服务器验证传入代码参数后才覆盖用户的当前(来宾)会话,这样您的应用程序就不容易受到恶意传入链接(例如日志记录)的影响退出当前用户)。
部分说:来自回调主体的参数应填充您在端点上从 Apple 服务器接收的 urlencoded 主体。我不确定如何获得它并正确格式化重定向 URL 的 PARAMATERS_FROM_CALLBACK_BODY 部分以使其适用于 Android。
如何使用HookWidget从特定页面监控应用程序的生命周期状态,就像使用Stateful widget一样?
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
void dispose() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
if (state == AppLifecycleState.paused) {
...
}
if (state == AppLifecycleState.resumed) {
...
}
if (state == AppLifecycleState.detached) {
...
}
}
Run Code Online (Sandbox Code Playgroud) 我正在遵循本指南: https: //flutter.dev/docs/deployment/obfuscate
\n运行 Flutter 1.17.5 \xe2\x80\xa2 通道稳定
\n当我跑步时:
\nflutter build apk --obfuscate --split-debug-info=/sample/debug --target-platform android-arm,android-arm64,android-x64\nRun Code Online (Sandbox Code Playgroud)\n然后我收到以下错误:
\n Target android_aot_release_android-arm failed: FileSystemException: Creation failed, path =\n \'/sample\' (OS Error: Read-only file system, errno = 30)\n Target android_aot_release_android-x64 failed: FileSystemException: Creation failed, path = \n\'/sample\' (OS Error: Read-only file system, errno = 30)\n Target android_aot_release_android-arm64 failed: FileSystemException: Creation failed, path = \n\'/sample\' (OS Error: Read-only file system, errno = 30)\n build failed. \n \n FAILURE: Build failed …Run Code Online (Sandbox Code Playgroud)