Я хочу отобразить обрезанное изображение во флаттере. Я использую виджет Image.memory. Когда я использую оригинальное изображение, это не проблема.
var tempStore = await ImagePicker.pickImage(source: ImageSource.camera);
List<int> byteListe = await tempStore.readAsBytes();
image = dartimage.Image.fromBytes(400, 400, byteList);
Но после того, как я использовал функцию copyCrop (), я получил исключение .. https://pub.dev/documentation/image/latest/image/copyCrop.html
cropImage = dartimage.copyCrop(image, 4, 0, 100, 100);
Expanded(
child: Container(
child: cropImage != null ? Image.memory(cropImage.getBytes()): Text('No Image'),
),
),
Это исключение!
════════ Exception caught by image resource service ════════════════════════════════════════════════
The following _Exception was thrown while resolving an image:
Exception: Could not instantiate image codec.
When the exception was thrown, this was the stack:
#0 _futurize (dart:ui/painting.dart:4304:5)
#1 instantiateImageCodec (dart:ui/painting.dart:1682:10)
#2 PaintingBinding.instantiateImageCodec (package:flutter/src/painting/binding.dart:88:12)
#3 MemoryImage._loadAsync (package:flutter/src/painting/image_provider.dart:714:18)
#4 MemoryImage.load (package:flutter/src/painting/image_provider.dart:706:14)
...
Image provider: MemoryImage(_Uint8ArrayView#a573e, scale: 1.0)
Image configuration: ImageConfiguration(bundle: PlatformAssetBundle#c13af(), devicePixelRatio: 4.0, locale: de_DE, textDirection: TextDirection.ltr, platform: android)
Image key: MemoryImage(_Uint8ArrayView#a573e, scale: 1.0)
════════════════════════════════════════════════════════════════════════════════════════════════════