flutter capture image from camera
import 'package:image_picker/image_picker.dart';
final _imagePicker = ImagePicker();
var _pickedFile = await _imagePicker.getImage(source: ImageSource.camera);
File _imageFilePicked = File(_pickedFile.path);
flutter capture image from camera
import 'package:image_picker/image_picker.dart';
final _imagePicker = ImagePicker();
var _pickedFile = await _imagePicker.getImage(source: ImageSource.camera);
File _imageFilePicked = File(_pickedFile.path);
flutter crop captured image
import 'dart:io';
import 'dart:math';
import 'package:flutter/rendering.dart';
import 'package:image/image.dart' as IMG;
class ImageProcessor {
static Future cropSquare(String srcFilePath, String destFilePath, bool flip) async {
var bytes = await File(srcFilePath).readAsBytes();
IMG.Image src = IMG.decodeImage(bytes);
var cropSize = min(src.width, src.height);
int offsetX = (src.width - min(src.width, src.height)) ~/ 2;
int offsetY = (src.height - min(src.width, src.height)) ~/ 2;
IMG.Image destImage =
IMG.copyCrop(src, offsetX, offsetY, cropSize, cropSize);
if (flip) {
destImage = IMG.flipVertical(destImage);
}
var jpg = IMG.encodeJpg(destImage);
await File(destFilePath).writeAsBytes(jpg);
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us