티스토리 뷰

반응형

1) XFile? selectedImage;

Image.file(File(selectedImage!.path)

 

2) How to convert Uint8List to File in flutter

File.fromRawPath(Uint8List uint8List);

 

3) How to convert File to Uint8List in flutter

 

Unit8List? intPhoto = await rootBundle.load(File.path)).buffer.asUint8List();

 

var result = await FlutterImageCompress.compressWithFile(

rotatedImage.path); // Uint8List

 

3) How to convert File to Image to Uint8List 

final pic = 

imglib.decodeImage(File(rotatedImage.path).readAsBytesSync());

 

Uint8List pics = pic!.getBytes();

 

 

4) How to convert Image to File?

 

5) How to conver Image to Uint8List

 

6) How to convert Image to ImageProvider vice versa

 

Image vs ImageProvider

An image provider is what provides the image to an Image widget. ;D

The image provider doesn't necessarily have the image right there but it knows how to get it.

Getting an Image

If you need an Image widget, then use one of these:

  • Image.asset()
  • Image.network()
  • Image.file()
  • Image.memory()

Getting an ImageProvider

If you need an ImageProvider, then use one of these:

  • AssetImage()
  • NetworkImage()
  • FileImage()
  • MemoryImage()

Converting an ImageProvider to an Image

If you have an ImageProvider object and you want an Image widget, then do the following:

Image( image: myImageProvider, )

Converting an Image to an ImageProvider

If you have an Image widget and you need its ImageProvider, then do the following:

myImageWidget.image

 

 

7) How to get the path of an image in flutter?

 

반응형
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG more
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함