Я хочу щелкнуть изображение и отправить его на сервер. код работает хорошо, если мы используем gallery function
, но не работает, когда он поменяется на camera function
.
Я могу открыть камеру, щелкнуть изображение и после этого выбрать, если он правильный или неправильный.
после этого шага приложение cra sh. После этого шага изображение должно быть отправлено на экран обрезки.
вот код:
Future getImage() async {
// var image = await ImagePicker.pickImage(source: ImageSource.gallery);
var _image = await ImagePicker.pickImage(source: ImageSource.camera);
croppedFile = await ImageCropper.cropImage(
sourcePath: _image.path,
aspectRatioPresets: [
CropAspectRatioPreset.square,
CropAspectRatioPreset.ratio3x2,
CropAspectRatioPreset.original,
CropAspectRatioPreset.ratio4x3,
CropAspectRatioPreset.ratio16x9
],
androidUiSettings: AndroidUiSettings(
toolbarTitle: 'Cropper',
toolbarColor: Colors.deepOrange,
toolbarWidgetColor: Colors.white,
initAspectRatio: CropAspectRatioPreset.square,
lockAspectRatio: false),
iosUiSettings: IOSUiSettings(
minimumAspectRatio: 1.0,
)
);
if (_pickInProgress) {
return;
}
_pickInProgress = true;
if (_image != null) {
setState(() {
_newAvatar = croppedFile;
});
}
_pickInProgress = false;
}
в Android Studio
У меня есть журнал, когда фильтр используется с ключевым словом flutter
:
2020-02-19 17:51:48.404 10631-10631/in.x.demo D/FlutterActivity: Using the launch theme as normal theme.
2020-02-19 17:51:48.413 10631-10631/in.x.demo D/FlutterActivityAndFragmentDelegate: Setting up FlutterEngine.
2020-02-19 17:51:48.413 10631-10631/in.x.demo D/FlutterActivityAndFragmentDelegate: No preferred FlutterEngine was provided. Creating a new FlutterEngine for this FlutterFragment.
2020-02-19 17:51:48.795 10631-10701/in.x.demo I/flutter: Observatory listening on http://127.0.0.1:38436/ayKKbiBs2ts=/
2020-02-19 17:51:49.031 10631-10631/in.x.demo D/FlutterActivityAndFragmentDelegate: Attaching FlutterEngine to the Activity that owns this Fragment.
2020-02-19 17:51:49.112 10631-10631/in.x.demo D/FlutterView: Attaching to a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@178fa3d
2020-02-19 17:51:49.142 10631-10631/in.x.demo D/FlutterActivityAndFragmentDelegate: Executing Dart entrypoint: main, and sending initial route: /
2020-02-19 17:51:51.013 10631-10673/in.x.demo E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method 'contains' was called on null.
Receiver: null
Tried calling: contains("access_token")
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1 _SplashScreenState.didChangeDependencies (package:demo/screens/common/splash_screen.dart:58:28)
#2 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64)
#3 _rootRunUnary (dart:async/zone.dart:1134:38)
#4 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#5 _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
#6 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
#7 Future._propagateToListeners (dart:async/future_impl.dart:709:32)
#8 Future._propagateToListeners (dart:async/future_impl.dart:607:9)
#9 Future._completeWithValue (dart:async/future_impl.dart:524:5)
#10 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:554:7)
#11 _rootRun (dart:async/zone.dart:1126:13)
#12 _CustomZone.run (dart:async/zone.dart:1023:19)
#13 _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#14 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
#15 _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
#16 _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
2020-02-19 17:51:51.015 10631-10673/in.x.demo I/flutter: genesis started
2020-02-19 17:51:51.106 10631-10673/in.x.demo I/flutter: device ID: ee44d5897844a106
2020-02-19 17:51:52.078 10631-10673/in.x.demo I/flutter: genesis final completed
2020-02-19 17:51:52.102 10631-10673/in.x.demo I/flutter: genesis api called !
2020-02-19 17:51:52.102 10631-10673/in.x.demo I/flutter: hasToken true
2020-02-19 17:51:53.085 10631-10673/in.x.demo E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method 'findAncestorStateOfType' was called on null.
Receiver: null
Tried calling: findAncestorStateOfType<NavigatorState>()
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1 Navigator.of (package:flutter/src/widgets/navigator.dart:1492:19)
#2 _SplashScreenState.didChangeDependencies.<anonymous closure> (package:demo/screens/common/splash_screen.dart:54:23)
#3 new Future.delayed.<anonymous closure> (dart:async/future.dart:316:39)
#4 _rootRun (dart:async/zone.dart:1122:38)
#5 _CustomZone.run (dart:async/zone.dart:1023:19)
#6 _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#7 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
#8 _rootRun (dart:async/zone.dart:1126:13)
#9 _CustomZone.run (dart:async/zone.dart:1023:19)
#10 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:949:23)
#11 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:23:15)
#12 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:384:19)
#13 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:418:5)
#14 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
`