Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振/飞镖-获得者';路径';在null上调用了。接收方:null尝试调用:路径_Flutter_Dart_Null_Conditional Statements - Fatal编程技术网

Flutter 颤振/飞镖-获得者';路径';在null上调用了。接收方:null尝试调用:路径

Flutter 颤振/飞镖-获得者';路径';在null上调用了。接收方:null尝试调用:路径,flutter,dart,null,conditional-statements,Flutter,Dart,Null,Conditional Statements,我正在使用一个基于flatter\u audio\u recorder的播放器widget。虽然它可以按要求工作,但在编译和热重启时,我会收到一条恼人的错误消息,因为路径一开始是空的。路径为空,因为尚未加载音频文件。但是一旦我使用的PageView.builder完成,音频就会被加载,因此错误消息对实际操作没有影响。然而,错误消息变得令人讨厌。所以我想从我的服务器提供一个默认的音频文件,这样错误就会停止 错误消息说 ════════ Exception caught by widgets l

我正在使用一个基于
flatter\u audio\u recorder
的播放器widget。虽然它可以按要求工作,但在编译和热重启时,我会收到一条恼人的错误消息,因为路径一开始是空的。路径为空,因为尚未加载音频文件。但是一旦我使用的
PageView.builder
完成,音频就会被加载,因此错误消息对实际操作没有影响。然而,错误消息变得令人讨厌。所以我想从我的服务器提供一个默认的音频文件,这样错误就会停止

错误消息说

  ════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following NoSuchMethodError was thrown building SpeakRecorder(dirty, dependencies: [_InheritedProviderScope<SocialProvider>], state: SpeakRecorderState#5e63d):
The getter 'path' was called on null.
Receiver: null
Tried calling: path
我尝试了以下方法

String defaultaudio = _current.path ?? 'http://example.com/ping.m4a';
但它不能解决路径为空的错误。有人能看出我做错了什么吗

对null调用了getter“path”

此错误表示正在为其写入
对象的对象的路径为
null
。您可以像这样使用
?。
运算符:
对象?。某个
等价于:

对象=无效的object.something:null
您可以将其与您正在执行的
??
运算符配对。因此,您只需将您的声明更改为:

String defaultaudio=\u current?.pathhttp://example.com/ping.m4a';

该错误表示当前的
\u
null
无论它是什么。您可以改为编写
\u current?.pathhttp://example.com/ping.m4a';。成功了!我怎样才能给你信用呢?你能正式回答这个问题吗?
String defaultaudio = _current.path ?? 'http://example.com/ping.m4a';