This commit is contained in:
timonrieger
2026-01-25 14:17:57 +01:00
parent 3d5693939b
commit 85623cb11f
@@ -28,13 +28,22 @@ class ProfilePictureCropPage extends HookConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final cropController = useCropController(); final cropController = useCropController();
final isLoading = useState<bool>(false); final isLoading = useState<bool>(false);
final didInitCropController = useRef(false);
// Lock aspect ratio to 1:1 for circular/square crop // Lock aspect ratio to 1:1 for circular/square crop
useEffect(() { useEffect(() {
cropController.aspectRatio = 1.0; // CropController depends on CropImage initializing its bitmap size.
WidgetsBinding.instance.addPostFrameCallback((_) {
if (didInitCropController.value) {
return;
}
didInitCropController.value = true;
cropController.crop = const Rect.fromLTRB(0.1, 0.1, 0.9, 0.9); cropController.crop = const Rect.fromLTRB(0.1, 0.1, 0.9, 0.9);
cropController.aspectRatio = 1.0;
});
return null; return null;
}, []); }, [cropController]);
// Create Image widget from asset // Create Image widget from asset
final image = Image(image: getFullImageProvider(asset)); final image = Image(image: getFullImageProvider(asset));