flutter_camera_demo
flutter_camera_demo copied to clipboard
PreviewScreen throws error "Null check operator used on a null value" when opening video
PreviewScreen widget doesn't support video. So it throws the error "Null check operator used on a null value" when trying to open video.
@sreenath-n yes same issue , and when we move "Go to all capture" button , we are able to see only images which are we capture previously not videos. Means that we neither be able to record video nor be able to save it. Can you find any solution regarding this issue then please comment !!
@sbis04 Please note this issue.
same. anyone available to fix?
Put an if statement in. Not sure if this is the right approach but it works, so it'll do for now:
InkWell(
onTap: _isVideoCameraSelected
? () async {
if (_isRecordingInProgress) {
XFile? rawVideo =
await stopVideoRecording();
File videoFile =
File(rawVideo!.path);
int currentUnix = DateTime
.now()
.millisecondsSinceEpoch;
final directory =
await getApplicationDocumentsDirectory();
String fileFormat = videoFile
.path
.split('.')
.last;
_videoFile =
await videoFile.copy(
'${directory.path}/$currentUnix.$fileFormat',
);
// #bug1 _startVideoPlayer();
} else {
await startVideoRecording();
}
}
: () async {
XFile? rawImage =
await takePicture();
if (rawImage != null) {
File imageFile =
File(rawImage.path);
int currentUnix = DateTime
.now()
.millisecondsSinceEpoch;
final directory =
await getApplicationDocumentsDirectory();
String fileFormat = imageFile
.path
.split('.')
.last;
print(fileFormat);
await imageFile.copy(
'${directory.path}/$currentUnix.$fileFormat',
);
} else {}
refreshAlreadyCapturedImages();
},
child: Stack(
alignment: Alignment.center,
children: [
Icon(
Icons.circle,
color: _isVideoCameraSelected
? Colors.white
: Colors.white38,
size: 80,
),
Icon(
Icons.circle,
color: _isVideoCameraSelected
? Colors.red
: Colors.white,
size: 65,
),
_isVideoCameraSelected &&
_isRecordingInProgress
? Icon(
Icons.stop_rounded,
color: Colors.white,
size: 32,
)
: Container(),
],
),
),