diff --git a/packages/camera/camera_windows/CHANGELOG.md b/packages/camera/camera_windows/CHANGELOG.md index a5fe77816e1..7316cdb8b1e 100644 --- a/packages/camera/camera_windows/CHANGELOG.md +++ b/packages/camera/camera_windows/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.6+4 + +* Removes usage of the deprecated and ignored `maxVideoDuration` in the example. + ## 0.2.6+3 * Updates to Pigeon 26. diff --git a/packages/camera/camera_windows/example/lib/main.dart b/packages/camera/camera_windows/example/lib/main.dart index 6745bcbdd6d..3957fe27c0b 100644 --- a/packages/camera/camera_windows/example/lib/main.dart +++ b/packages/camera/camera_windows/example/lib/main.dart @@ -28,7 +28,6 @@ class _MyAppState extends State { int _cameraId = -1; bool _initialized = false; bool _recording = false; - bool _recordingTimed = false; bool _previewPaused = false; Size? _previewSize; MediaSettings _mediaSettings = const MediaSettings( @@ -147,7 +146,6 @@ class _MyAppState extends State { _cameraIndex = 0; _previewSize = null; _recording = false; - _recordingTimed = false; _cameraInfo = 'Failed to initialize camera: ${e.code}: ${e.description}'; }); @@ -166,7 +164,6 @@ class _MyAppState extends State { _cameraId = -1; _previewSize = null; _recording = false; - _recordingTimed = false; _previewPaused = false; _cameraInfo = 'Camera disposed'; }); @@ -191,56 +188,22 @@ class _MyAppState extends State { _showInSnackBar('Picture captured to: ${file.path}'); } - Future _recordTimed(int seconds) async { - if (_initialized && _cameraId > 0 && !_recordingTimed) { - unawaited( - CameraPlatform.instance.onVideoRecordedEvent(_cameraId).first.then(( - VideoRecordedEvent event, - ) async { - if (mounted) { - setState(() { - _recordingTimed = false; - }); - - _showInSnackBar('Video captured to: ${event.file.path}'); - } - }), - ); - - await CameraPlatform.instance.startVideoRecording( - _cameraId, - maxVideoDuration: Duration(seconds: seconds), - ); - - if (mounted) { - setState(() { - _recordingTimed = true; - }); - } - } - } - Future _toggleRecord() async { if (_initialized && _cameraId > 0) { - if (_recordingTimed) { - /// Request to stop timed recording short. - await CameraPlatform.instance.stopVideoRecording(_cameraId); + if (!_recording) { + await CameraPlatform.instance.startVideoRecording(_cameraId); } else { - if (!_recording) { - await CameraPlatform.instance.startVideoRecording(_cameraId); - } else { - final XFile file = await CameraPlatform.instance.stopVideoRecording( - _cameraId, - ); + final XFile file = await CameraPlatform.instance.stopVideoRecording( + _cameraId, + ); - _showInSnackBar('Video captured to: ${file.path}'); - } + _showInSnackBar('Video captured to: ${file.path}'); + } - if (mounted) { - setState(() { - _recording = !_recording; - }); - } + if (mounted) { + setState(() { + _recording = !_recording; + }); } } } @@ -407,18 +370,7 @@ class _MyAppState extends State { const SizedBox(width: 5), ElevatedButton( onPressed: _initialized ? _toggleRecord : null, - child: Text( - (_recording || _recordingTimed) - ? 'Stop recording' - : 'Record Video', - ), - ), - const SizedBox(width: 5), - ElevatedButton( - onPressed: (_initialized && !_recording && !_recordingTimed) - ? () => _recordTimed(5) - : null, - child: const Text('Record 5 seconds'), + child: Text(_recording ? 'Stop recording' : 'Record Video'), ), if (_cameras.length > 1) ...[ const SizedBox(width: 5), diff --git a/packages/camera/camera_windows/lib/camera_windows.dart b/packages/camera/camera_windows/lib/camera_windows.dart index 360754fbfef..80005024b14 100644 --- a/packages/camera/camera_windows/lib/camera_windows.dart +++ b/packages/camera/camera_windows/lib/camera_windows.dart @@ -50,14 +50,11 @@ class CameraWindows extends CameraPlatform { @override Future> availableCameras() async { try { - final List cameras = await _hostApi.getAvailableCameras(); + final List cameras = await _hostApi.getAvailableCameras(); - return cameras.map((String? cameraName) { + return cameras.map((String cameraName) { return CameraDescription( - // This type is only nullable due to Pigeon limitations, see - // https://github.com/flutter/flutter/issues/97848. The native code - // will never return null. - name: cameraName!, + name: cameraName, // TODO(stuartmorgan): Implement these; see // https://github.com/flutter/flutter/issues/97540. lensDirection: CameraLensDirection.front, diff --git a/packages/camera/camera_windows/pubspec.yaml b/packages/camera/camera_windows/pubspec.yaml index c5cdce35b7f..ab42277ea39 100644 --- a/packages/camera/camera_windows/pubspec.yaml +++ b/packages/camera/camera_windows/pubspec.yaml @@ -2,7 +2,7 @@ name: camera_windows description: A Flutter plugin for getting information about and controlling the camera on Windows. repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_windows issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 -version: 0.2.6+3 +version: 0.2.6+4 environment: sdk: ^3.8.0