simplified code across the app and consolidated duplicated helpers

This commit is contained in:
2026-09-27 17:29:54 +02:00
parent 3e856d0b1c
commit ee1240f71a
155 changed files with 1772 additions and 2546 deletions
+2 -33
View File
@@ -1,7 +1,6 @@
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import '../routing/app_routes.dart';
import 'details_bottom_sheet.dart';
@@ -16,32 +15,8 @@ Future<Uint8List?> showChatBackgroundPickerSheet(BuildContext context) async {
Uint8List? result;
await showDetailsBottomSheet(
context,
children: (sheetContext) => [
ListTile(
leading: const Icon(Icons.photo_library_outlined),
title: const Text('Aus Galerie wählen'),
onTap: () async {
final bytes = await _pickRaw(
() => FilePick.singleGalleryPick(sheetContext, forCrop: true),
);
if (bytes == null || !sheetContext.mounted) return;
result = bytes;
Navigator.of(sheetContext).pop();
},
),
ListTile(
leading: const Icon(Icons.photo_camera_outlined),
title: const Text('Foto aufnehmen'),
onTap: () async {
final bytes = await _pickRaw(
() => FilePick.cameraPick(sheetContext, forCrop: true),
);
if (bytes == null || !sheetContext.mounted) return;
result = bytes;
Navigator.of(sheetContext).pop();
},
),
],
children: (sheetContext) =>
imageSourceTiles(sheetContext, onPicked: (bytes) => result = bytes),
);
return result;
}
@@ -53,9 +28,3 @@ Future<Uint8List?> cropChatBackgroundImage(
BuildContext context,
Uint8List bytes,
) => AppRoutes.openAvatarCrop(context, imageBytes: bytes, aspectRatio: null);
Future<Uint8List?> _pickRaw(Future<XFile?> Function() pick) async {
final picked = await pick();
if (picked == null) return null;
return picked.readAsBytes();
}