✨ Crop image for profile picture, background
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:croppy/croppy.dart' hide cropImage;
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -244,10 +245,23 @@ class EditChatScreen extends HookConsumerWidget {
|
||||
}, [chat]);
|
||||
|
||||
void setPicture(String position) async {
|
||||
final result = await ref
|
||||
var result = await ref
|
||||
.read(imagePickerProvider)
|
||||
.pickImage(source: ImageSource.gallery);
|
||||
if (result == null) return;
|
||||
if (!context.mounted) return;
|
||||
result = await cropImage(
|
||||
context,
|
||||
image: result,
|
||||
allowedAspectRatios: [
|
||||
if (position == 'background')
|
||||
CropAspectRatio(height: 7, width: 16)
|
||||
else
|
||||
CropAspectRatio(height: 1, width: 1),
|
||||
],
|
||||
);
|
||||
if (result == null) return;
|
||||
if (!context.mounted) return;
|
||||
|
||||
submitting.value = true;
|
||||
try {
|
||||
|
Reference in New Issue
Block a user