chore: bump dart sdk to 3.8 (#20355)

* chore: bump dart sdk to 3.8

* chore: make build

* make pigeon

* chore: format files

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
shenlong
2025-07-29 00:34:03 +05:30
committed by GitHub
parent 9b3718120b
commit e52b9d15b5
643 changed files with 32561 additions and 35292 deletions
+14 -41
View File
@@ -32,20 +32,10 @@ class CropImagePage extends HookWidget {
leading: CloseButton(color: context.primaryColor),
actions: [
IconButton(
icon: Icon(
Icons.done_rounded,
color: context.primaryColor,
size: 24,
),
icon: Icon(Icons.done_rounded, color: context.primaryColor, size: 24),
onPressed: () async {
final croppedImage = await cropController.croppedImage();
context.pushRoute(
EditImageRoute(
asset: asset,
image: croppedImage,
isEdited: true,
),
);
context.pushRoute(EditImageRoute(asset: asset, image: croppedImage, isEdited: true));
},
),
],
@@ -60,11 +50,7 @@ class CropImagePage extends HookWidget {
padding: const EdgeInsets.only(top: 20),
width: constraints.maxWidth * 0.9,
height: constraints.maxHeight * 0.6,
child: CropImage(
controller: cropController,
image: image,
gridColor: Colors.white,
),
child: CropImage(controller: cropController, image: image, gridColor: Colors.white),
),
Expanded(
child: Container(
@@ -81,28 +67,18 @@ class CropImagePage extends HookWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(
left: 20,
right: 20,
bottom: 10,
),
padding: const EdgeInsets.only(left: 20, right: 20, bottom: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: Icon(
Icons.rotate_left,
color: context.themeData.iconTheme.color,
),
icon: Icon(Icons.rotate_left, color: context.themeData.iconTheme.color),
onPressed: () {
cropController.rotateLeft();
},
),
IconButton(
icon: Icon(
Icons.rotate_right,
color: context.themeData.iconTheme.color,
),
icon: Icon(Icons.rotate_right, color: context.themeData.iconTheme.color),
onPressed: () {
cropController.rotateRight();
},
@@ -178,17 +154,14 @@ class _AspectRatioButton extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: Icon(
switch (label) {
'Free' => Icons.crop_free_rounded,
'1:1' => Icons.crop_square_rounded,
'16:9' => Icons.crop_16_9_rounded,
'3:2' => Icons.crop_3_2_rounded,
'7:5' => Icons.crop_7_5_rounded,
_ => Icons.crop_free_rounded,
},
color: aspectRatio.value == ratio ? context.primaryColor : context.themeData.iconTheme.color,
),
icon: Icon(switch (label) {
'Free' => Icons.crop_free_rounded,
'1:1' => Icons.crop_square_rounded,
'16:9' => Icons.crop_16_9_rounded,
'3:2' => Icons.crop_3_2_rounded,
'7:5' => Icons.crop_7_5_rounded,
_ => Icons.crop_free_rounded,
}, color: aspectRatio.value == ratio ? context.primaryColor : context.themeData.iconTheme.color),
onPressed: () {
cropController.crop = const Rect.fromLTRB(0.1, 0.1, 0.9, 0.9);
aspectRatio.value = ratio;
+29 -82
View File
@@ -29,51 +29,34 @@ class EditImagePage extends ConsumerWidget {
final Image image;
final bool isEdited;
const EditImagePage({
super.key,
required this.asset,
required this.image,
required this.isEdited,
});
const EditImagePage({super.key, required this.asset, required this.image, required this.isEdited});
Future<Uint8List> _imageToUint8List(Image image) async {
final Completer<Uint8List> completer = Completer();
image.image.resolve(const ImageConfiguration()).addListener(
ImageStreamListener(
(ImageInfo info, bool _) {
info.image.toByteData(format: ImageByteFormat.png).then((byteData) {
if (byteData != null) {
completer.complete(byteData.buffer.asUint8List());
} else {
completer.completeError('Failed to convert image to bytes');
}
});
},
onError: (exception, stackTrace) => completer.completeError(exception),
),
image.image
.resolve(const ImageConfiguration())
.addListener(
ImageStreamListener((ImageInfo info, bool _) {
info.image.toByteData(format: ImageByteFormat.png).then((byteData) {
if (byteData != null) {
completer.complete(byteData.buffer.asUint8List());
} else {
completer.completeError('Failed to convert image to bytes');
}
});
}, onError: (exception, stackTrace) => completer.completeError(exception)),
);
return completer.future;
}
Future<void> _saveEditedImage(
BuildContext context,
Asset asset,
Image image,
WidgetRef ref,
) async {
Future<void> _saveEditedImage(BuildContext context, Asset asset, Image image, WidgetRef ref) async {
try {
final Uint8List imageData = await _imageToUint8List(image);
await ref.read(fileMediaRepositoryProvider).saveImage(
imageData,
title: "${p.withoutExtension(asset.fileName)}_edited.jpg",
);
await ref
.read(fileMediaRepositoryProvider)
.saveImage(imageData, title: "${p.withoutExtension(asset.fileName)}_edited.jpg");
await ref.read(albumProvider.notifier).refreshDeviceAlbums();
context.navigator.popUntil((route) => route.isFirst);
ImmichToast.show(
durationInSecond: 3,
context: context,
msg: 'Image Saved!',
gravity: ToastGravity.CENTER,
);
ImmichToast.show(durationInSecond: 3, context: context, msg: 'Image Saved!', gravity: ToastGravity.CENTER);
} catch (e) {
ImmichToast.show(
durationInSecond: 6,
@@ -91,37 +74,23 @@ class EditImagePage extends ConsumerWidget {
title: Text("edit".tr()),
backgroundColor: context.scaffoldBackgroundColor,
leading: IconButton(
icon: Icon(
Icons.close_rounded,
color: context.primaryColor,
size: 24,
),
icon: Icon(Icons.close_rounded, color: context.primaryColor, size: 24),
onPressed: () => context.navigator.popUntil((route) => route.isFirst),
),
actions: <Widget>[
TextButton(
onPressed: isEdited ? () => _saveEditedImage(context, asset, image, ref) : null,
child: Text(
"save_to_gallery".tr(),
style: TextStyle(
color: isEdited ? context.primaryColor : Colors.grey,
),
),
child: Text("save_to_gallery".tr(), style: TextStyle(color: isEdited ? context.primaryColor : Colors.grey)),
),
],
),
backgroundColor: context.scaffoldBackgroundColor,
body: Center(
child: ConstrainedBox(
constraints: BoxConstraints(
maxHeight: context.height * 0.7,
maxWidth: context.width * 0.9,
),
constraints: BoxConstraints(maxHeight: context.height * 0.7, maxWidth: context.width * 0.9),
child: Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(
Radius.circular(7),
),
borderRadius: const BorderRadius.all(Radius.circular(7)),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.2),
@@ -132,13 +101,8 @@ class EditImagePage extends ConsumerWidget {
],
),
child: ClipRRect(
borderRadius: const BorderRadius.all(
Radius.circular(7),
),
child: Image(
image: image.image,
fit: BoxFit.contain,
),
borderRadius: const BorderRadius.all(Radius.circular(7)),
child: Image(image: image.image, fit: BoxFit.contain),
),
),
),
@@ -148,9 +112,7 @@ class EditImagePage extends ConsumerWidget {
margin: const EdgeInsets.only(bottom: 60, right: 10, left: 10, top: 10),
decoration: BoxDecoration(
color: context.scaffoldBackgroundColor,
borderRadius: const BorderRadius.all(
Radius.circular(30),
),
borderRadius: const BorderRadius.all(Radius.circular(30)),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
@@ -159,15 +121,9 @@ class EditImagePage extends ConsumerWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
IconButton(
icon: Icon(
Icons.crop_rotate_rounded,
color: context.themeData.iconTheme.color,
size: 25,
),
icon: Icon(Icons.crop_rotate_rounded, color: context.themeData.iconTheme.color, size: 25),
onPressed: () {
context.pushRoute(
CropImageRoute(asset: asset, image: image),
);
context.pushRoute(CropImageRoute(asset: asset, image: image));
},
),
Text("crop".tr(), style: context.textTheme.displayMedium),
@@ -177,18 +133,9 @@ class EditImagePage extends ConsumerWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
IconButton(
icon: Icon(
Icons.filter,
color: context.themeData.iconTheme.color,
size: 25,
),
icon: Icon(Icons.filter, color: context.themeData.iconTheme.color, size: 25),
onPressed: () {
context.pushRoute(
FilterImageRoute(
asset: asset,
image: image,
),
);
context.pushRoute(FilterImageRoute(asset: asset, image: image));
},
),
Text("filter".tr(), style: context.textTheme.displayMedium),
+15 -40
View File
@@ -18,21 +18,14 @@ class FilterImagePage extends HookWidget {
final Image image;
final Asset asset;
const FilterImagePage({
super.key,
required this.image,
required this.asset,
});
const FilterImagePage({super.key, required this.image, required this.asset});
@override
Widget build(BuildContext context) {
final colorFilter = useState<ColorFilter>(filters[0]);
final selectedFilterIndex = useState<int>(0);
Future<ui.Image> createFilteredImage(
ui.Image inputImage,
ColorFilter filter,
) {
Future<ui.Image> createFilteredImage(ui.Image inputImage, ColorFilter filter) {
final completer = Completer<ui.Image>();
final size = Size(inputImage.width.toDouble(), inputImage.height.toDouble());
final recorder = ui.PictureRecorder();
@@ -55,11 +48,13 @@ class FilterImagePage extends HookWidget {
Future<Image> applyFilterAndConvert(ColorFilter filter) async {
final completer = Completer<ui.Image>();
image.image.resolve(ImageConfiguration.empty).addListener(
ImageStreamListener((ImageInfo info, bool _) {
completer.complete(info.image);
}),
);
image.image
.resolve(ImageConfiguration.empty)
.addListener(
ImageStreamListener((ImageInfo info, bool _) {
completer.complete(info.image);
}),
);
final uiImage = await completer.future;
final filteredUiImage = await createFilteredImage(uiImage, filter);
@@ -76,20 +71,10 @@ class FilterImagePage extends HookWidget {
leading: CloseButton(color: context.primaryColor),
actions: [
IconButton(
icon: Icon(
Icons.done_rounded,
color: context.primaryColor,
size: 24,
),
icon: Icon(Icons.done_rounded, color: context.primaryColor, size: 24),
onPressed: () async {
final filteredImage = await applyFilterAndConvert(colorFilter.value);
context.pushRoute(
EditImageRoute(
asset: asset,
image: filteredImage,
isEdited: true,
),
);
context.pushRoute(EditImageRoute(asset: asset, image: filteredImage, isEdited: true));
},
),
],
@@ -100,10 +85,7 @@ class FilterImagePage extends HookWidget {
SizedBox(
height: context.height * 0.7,
child: Center(
child: ColorFiltered(
colorFilter: colorFilter.value,
child: image,
),
child: ColorFiltered(colorFilter: colorFilter.value, child: image),
),
),
SizedBox(
@@ -156,21 +138,14 @@ class _FilterButton extends StatelessWidget {
width: 80,
height: 80,
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(
Radius.circular(10),
),
borderRadius: const BorderRadius.all(Radius.circular(10)),
border: isSelected ? Border.all(color: context.primaryColor, width: 3) : null,
),
child: ClipRRect(
borderRadius: const BorderRadius.all(
Radius.circular(10),
),
borderRadius: const BorderRadius.all(Radius.circular(10)),
child: ColorFiltered(
colorFilter: filter,
child: FittedBox(
fit: BoxFit.cover,
child: image,
),
child: FittedBox(fit: BoxFit.cover, child: image),
),
),
),