Reputation: 21
It works good when I tab on selecting image from camera. After selecting image from camera it suddenly crashes and goes back to previous screen .. terminal is show no error .. m using try & catch method but it catch no error as well.
Future pickimage() async {
try{
await ImagePicker.pickImage(
source: ImageSource.camera,
imageQuality: 50,
).then((img) => setState(() {
immage = img;
imagefile = File(immage.path);
}));
if (imagefile != null) {
print('heloo data is saving to database');
await saveimage();
}
}catch(e){
print(e);
}
}
m using latest image_picker() version this is my pub dependences
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.0
carousel_slider: ^2.3.1
animated_text_kit: ^1.3.1
cloud_firestore: ^0.14.3
progress_dialog: ^1.2.4
firebase_auth: ^0.18.4+1
firebase_core: ^0.5.3
google_maps_flutter: ^1.0.6
geolocator: ^6.1.5
geoflutterfire: ^2.2.1
image_picker: ^0.6.7+22
firebase_storage: ^5.2.0
latlng: ^0.0.2
location: ^3.1.0
simple_animations: ^2.4.0
liquid_swipe: ^1.5.0
otp_text_field: ^1.0.1
charts_flutter: ^0.9.0
flutter_echarts: ^1.5.0
flutter_staggered_animations: "^0.1.2"
Upvotes: 1
Views: 3626
Reputation: 11
final ImagePicker picker = ImagePicker();
final XFile? image = await picker.pickImage(source: ImageSource.gallery);
final XFile? photo = await picker.pickImage(source: ImageSource.camera);
Things to change
ImagePicker picker = ImagePicker();
XFile? image = await picker.pickImage(source: ImageSource.gallery);
XFile? photo = await picker.pickImage(source: ImageSource.camera);
it's only working inside real device because it use your camera app
Upvotes: 1
Reputation: 370
Have you added few lines of configuration on AndroidManifest.xml ?
You should add:
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
check this url: https://pub.dev/packages/image_cropper/versions/1.3.1 and section: How to install
Upvotes: 4
Reputation: 370
In my case apps crush with message "Lost connection to device." both on real device and on simulator.
Upvotes: 0
Reputation: 21
Any Feedback on this?
It seems it happening every time i call pickImage.
Future getImage() async { final _imageFiles = await ImagePicker().getImage(source: ImageSource.gallery);
if (_imageFiles != null) {
File _imageFile = await Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => ImageCropper(file: File(_imageFiles.path))),
);
if (_imageFile != null) {
setState(() {
profilePicChange = _imageFile.path;
// Navigator.pop(context);
});
}
}
Upvotes: 0