相机0.2.0和抖动0.9.0面临的问题

时间:2019-03-28 07:23:06

标签: dart flutter

我正在尝试将相机0.2.0设置为0.9.0抖动,以使应用程序适合非AndroidX手机,但我面临着奇怪的错误。在最新稳定版本的flutter中,我没有收到此错误。

我的main.dart代码文件是

import 'package:flutter/material.dart';
import './app/alert_on_crises.dart';
import 'package:flutter/services.dart';
import 'package:camera/camera.dart';
import 'dart:async';
List<CameraDescription> cameras;

Future<void> main() async {
  // SystemChrome.setPreferredOrientations([
     //   DeviceOrientation.portraitUp,
    //   DeviceOrientation.portraitDown
  // ]);
  cameras = await availableCameras();
  runApp(new AlertOnCrises(cameras));
}

应用程序启动时会记录

E/flutter (12582): 
[ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] 
Unhandled exception:
E/flutter (12582): NoSuchMethodError: Attempted to use type 
'CameraDescription' as a function. Since types do not define a method 
'call', this is not possible. Did you intend to call the 
CameraDescription constructor and forget the 'new' operator? 
E/flutter (12582): Receiver: CameraDescription
E/flutter (12582): Tried calling: CameraDescription(lensDirection: 
Instance of 'CameraLensDirection', name: "0")
E/flutter (12582): #0 Object.noSuchMethod (dart:core- 
patch/dart:core/object_patch.dart:46)
E/flutter (12582): #1 availableCameras. 
(package:camera/camera.dart:55)
E/flutter (12582): #2 MappedListIterable.elementAt 
(dart:_internal/iterable.dart:414)
E/flutter (12582): #3 ListIterable.toList 
(dart:_internal/iterable.dart:219)
E/flutter (12582): #4 availableCameras (package:camera/camera.dart:59)
E/flutter (12582): 
E/flutter (12582): #5 main 
(file:///home/nishant/alert_on_crises/lib/main.dart:13)
E/flutter (12582): 
E/flutter (12582): #6 _startIsolate. (dart:isolate- 
patch/dart:isolate/isolate_patch.dart:279)
E/flutter (12582): #7 _RawReceivePortImpl._handleMessage 
(dart:isolate- 
patch/dart:isolate/isolate_patch.dart:165)
Syncing files to device vivo 1723... 5.8s

fire To hot reload your app on the fly, press "r". To restart the app 
entirely, press "R".
An Observatory debugger and profiler on vivo 1723 is available at: 
http://127.0.0.1:8101/
For a more detailed help message, press "h". To quit, press "q".

0 个答案:

没有答案