请帮助我,_scaffoldKey 和 _scaffoldKey.currentState 在修复代码时引发主要问题。
我有以下代码:
void customSnackBar(GlobalKey<ScaffoldState> _scaffoldKey, String msg,
{double height = 30, Color backgroundColor = Colors.black}) {
if (_scaffoldKey == null || _scaffoldKey.currentState == null) {
return;
}
_scaffoldKey.currentState.hideCurrentSnackBar();
final snackBar = SnackBar(
backgroundColor: backgroundColor,
content: Text(
msg,
style: TextStyle(
color: Colors.white,
),
),
);
_scaffoldKey.currentState.showSnackBar(snackBar);
}
Run Code Online (Sandbox Code Playgroud)
我已经阅读了ScaffoldMessenger文档,但无法理解如何转换上面的代码来使用ScaffoldMessenger?
出了什么问题:
任务“:app:checkDevDebugAarMetadata”执行失败。
无法解析配置“:app:devDebugRuntimeClasspath”的所有文件。无法解析 net.minidev:json-smart:[1.3.1,2.3]。需要者:project :app > project :react-native-code-push > com.nimbusds:nimbus-jose-jwt:5.1 > 无法列出 net.minidev:json-smart 的版本。> 无法从https://jcenter.bintray.com/net/minidev/json-smart/maven-metadata.xml加载 Maven 元数据。> 无法 HEAD 'https://jcenter.bintray.com/net/minidev/json-smart/maven-metadata.xml'。> org.apache.http.client.ClientProtocolException(无错误消息)
我在构建项目时遇到上述错误。无法解决请帮助我。