How to Convert BASE64 String into Image in Flutter

A Base64 string is a sequence of characters that represent data in an ASCII format. It is commonly used to encode data for transmission over the internet.

A Base64 image is an image that has been encoded using the Base64 encoding algorithm. The result is a string of letters and numbers that can be used to represent the image.

There are many reasons for converting an image into a Base64 string. It will be useful when you need to transfer binary data or store it in a database.

In order to convert a BASE64 String into an image, we have to use the Base64Decoder class from the dart:convert library. This class has a static method called decodeImage that takes a BASE64 String as input and returns an Image instance. We can use this image in our Flutter app like any other image.

//convert Base64 string to Uint8List
Uint8List image = Base64Decoder().convert(imageString);

Use Image.memeory() to display Uint8List file.

Container(
	height: 240,
	width: 240,
	child: FittedBox(
	  fit: BoxFit.cover,
	  child: Image.memory(
	    image,
	    width: 240,
	    height: 240,
	  ),
	),
)