Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PreviewScreen throws error "Null check operator used on a null value" when opening video #9

Open
sreenath-n opened this issue Jul 7, 2022 · 3 comments

Comments

@sreenath-n
Copy link

PreviewScreen widget doesn't support video. So it throws the error "Null check operator used on a null value" when trying to open video.

@idamsel
Copy link

idamsel commented Sep 14, 2022

@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.

@cmptscpeacock
Copy link

same. anyone available to fix?

@cmptscpeacock
Copy link

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(),
                                          ],
                                        ),
                                      ),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants