Home > front end >  Convert Image to Uint8List in Flutter
Convert Image to Uint8List in Flutter

Time:05-22

How to Convert Image to Uint8List in Flutter

I have Image it not from asset or file I want to convert Image to Uint8List

CodePudding user response:

Something like this could work.

final data = await image.toByteData();
final result = data.buffer.asUint8List();

CodePudding user response:

import 'dart:typed_data';
import 'package:flutter/services.dart';

final ByteData bytes = await rootBundle.load('assets/logo.jpg');
final Uint8List list = bytes.buffer.asUint8List();
  • Related