fix somes issues
continuous-integration/drone/push Build is passing Details

fix/web-images
Lucas DELANIER 1 year ago
parent 5cacac45ee
commit a4c238d8e1

@ -1,6 +1,7 @@
import 'dart:io';
import 'package:animated_appear/animated_appear.dart';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
@ -39,6 +40,7 @@ class _EditablePostComponentState extends State<EditablePostComponent> with Tick
late AnimationController animationController;
late AnimationController _controller;
File? image;
Uint8List webImage = Uint8List(8);
Tuple2<String, String>? selectedCity;
@override
@ -59,20 +61,33 @@ class _EditablePostComponentState extends State<EditablePostComponent> with Tick
super.initState();
}
Future pickImage(ImageSource source) async {
Future<void> pickImage(ImageSource source) async {
try {
final image = await ImagePicker().pickImage(source: source, imageQuality: 20);
if (image == null) return;
final imageTemp = File(image.path);
setState(() {
this.image = imageTemp;
widget.callBackImage(imageTemp);
});
if (!kIsWeb) {
final imageTemp = File(image.path);
setState(() {
this.image = imageTemp;
widget.callBackImage(imageTemp);
});
} else {
final imageBytes = await image.readAsBytes();
setState(() {
webImage = imageBytes;
// Assurez-vous de traiter webImage comme vous le souhaitez ici
// Vous pourriez également utiliser Image.memory comme dans votre code original
widget.callBackImage(Image.memory(webImage));
});
}
} on PlatformException catch (e) {
print('Failed to pick image: $e');
}
}
void _updateDescription(String text) {
setState(() {
widget.callBackDescription(text);

@ -732,10 +732,10 @@ packages:
dependency: "direct main"
description:
name: image_picker
sha256: "6296e98782726d37f59663f0727d0e978eee1ced1ffed45ccaba591786a7f7b3"
sha256: "7d7f2768df2a8b0a3cefa5ef4f84636121987d403130e70b17ef7e2cf650ba84"
url: "https://pub.dev"
source: hosted
version: "1.0.1"
version: "1.0.4"
image_picker_android:
dependency: transitive
description:
@ -745,13 +745,13 @@ packages:
source: hosted
version: "0.8.7+4"
image_picker_for_web:
dependency: transitive
dependency: "direct main"
description:
name: image_picker_for_web
sha256: "869fe8a64771b7afbc99fc433a5f7be2fea4d1cb3d7c11a48b6b579eb9c797f0"
sha256: "50bc9ae6a77eea3a8b11af5eb6c661eeb858fdd2f734c2a4fd17086922347ef7"
url: "https://pub.dev"
source: hosted
version: "2.2.0"
version: "3.0.1"
image_picker_ios:
dependency: transitive
description:

@ -78,6 +78,7 @@ dependencies:
google_sign_in: ^6.1.4
flutter_launcher_icons: ^0.13.1
fullscreen_window: ^1.0.3
image_picker_for_web: ^3.0.1
dev_dependencies:
flutter_test:

Loading…
Cancel
Save