diff --git a/packages/camera/camera_windows/CHANGELOG.md b/packages/camera/camera_windows/CHANGELOG.md index 9a001ea738d..0b82ead07bc 100644 --- a/packages/camera/camera_windows/CHANGELOG.md +++ b/packages/camera/camera_windows/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 0.2.6+3 +* Removes usage of the deprecated and ignored `maxVideoDuration` in the example. * Updates minimum supported SDK version to Flutter 3.29/Dart 3.7. ## 0.2.6+2 diff --git a/packages/camera/camera_windows/example/lib/main.dart b/packages/camera/camera_windows/example/lib/main.dart index 8a1e7215bd6..4ca9c3320fe 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( @@ -146,7 +145,6 @@ class _MyAppState extends State { _cameraIndex = 0; _previewSize = null; _recording = false; - _recordingTimed = false; _cameraInfo = 'Failed to initialize camera: ${e.code}: ${e.description}'; }); @@ -165,7 +163,6 @@ class _MyAppState extends State { _cameraId = -1; _previewSize = null; _recording = false; - _recordingTimed = false; _previewPaused = false; _cameraInfo = 'Camera disposed'; }); @@ -190,56 +187,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,19 +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 d064fa093a0..bfd8473363b 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+2 +version: 0.2.6+3 environment: sdk: ^3.7.0