You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
final channel =MethodChannel('flutter.io/cameraPlugin/camera$cameraId');
110
104
channel.setMethodCallHandler(
@@ -131,16 +125,15 @@ class MethodChannelCamera extends CameraPlatform {
131
125
132
126
@override
133
127
Future<void> dispose(int cameraId) async {
134
-
if (_channels.containsKey(cameraId)) {
135
-
final cameraChannel = _channels[cameraId];
136
-
cameraChannel?.setMethodCallHandler(null);
137
-
_channels.remove(cameraId);
138
-
}
139
-
140
128
await _channel.invokeMethod<void>(
141
129
'dispose',
142
130
<String, dynamic>{'cameraId': cameraId},
143
131
);
132
+
133
+
if (_channels.containsKey(cameraId)) {
134
+
_channels[cameraId].setMethodCallHandler(null);
135
+
_channels.remove(cameraId);
136
+
}
144
137
}
145
138
146
139
@override
@@ -176,9 +169,7 @@ class MethodChannelCamera extends CameraPlatform {
176
169
177
170
@override
178
171
Future<void> lockCaptureOrientation(
179
-
int cameraId,
180
-
DeviceOrientation orientation,
181
-
) async {
172
+
int cameraId, DeviceOrientation orientation) async {
182
173
await _channel.invokeMethod<String>(
183
174
'lockCaptureOrientation',
184
175
<String, dynamic>{
@@ -198,18 +189,10 @@ class MethodChannelCamera extends CameraPlatform {
198
189
199
190
@override
200
191
Future<XFile> takePicture(int cameraId) async {
201
-
final path =await _channel.invokeMethod<String>(
192
+
String path =await _channel.invokeMethod<String>(
202
193
'takePicture',
203
194
<String, dynamic>{'cameraId': cameraId},
204
195
);
205
-
206
-
if (path ==null) {
207
-
throwCameraException(
208
-
'INVALID_PATH',
209
-
'The platform "$defaultTargetPlatform" did not return a path while reporting success. The platform should always return a valid path or report an error.',
210
-
);
211
-
}
212
-
213
196
returnXFile(path);
214
197
}
215
198
@@ -219,7 +202,7 @@ class MethodChannelCamera extends CameraPlatform {
219
202
220
203
@override
221
204
Future<void> startVideoRecording(int cameraId,
222
-
{Duration? maxVideoDuration}) async {
205
+
{Duration maxVideoDuration}) async {
223
206
await _channel.invokeMethod<void>(
224
207
'startVideoRecording',
225
208
<String, dynamic>{
@@ -231,18 +214,10 @@ class MethodChannelCamera extends CameraPlatform {
'The platform "$defaultTargetPlatform" did not return a path while reporting success. The platform should always return a valid path or report an error.',
243
-
);
244
-
}
245
-
246
221
returnXFile(path);
247
222
}
248
223
@@ -280,10 +255,9 @@ class MethodChannelCamera extends CameraPlatform {
0 commit comments