개발하자

Flooth에서 바이트 배열을 이미지로 변환하시겠습니까?

Cuire 2023. 5. 21. 15:27
반응형

Flooth에서 바이트 배열을 이미지로 변환하시겠습니까?

나는 내 REST API 서비스에서 이미지를 얻고 싶지만, Flutter에서 이미지에 대한 바이트 배열이 될 응답 본문을 디코딩하는 방법에 대한 문서를 찾지 못했습니까? 도움이 되는 자원을 가진 사람은...




이미지 위젯에 사용합니다: Image.memory(바이트)입니다. 넌 할 수 있다.




위젯을 반환합니다

Image.memory(Uint8List);



최상위 응답은 float/widget.dart를 사용하므로 이는 오직

Future<Image> tinypng() async {
  final bytes = Uint8List.fromList([
    137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0,
    1, 0, 0, 0, 1, 8, 6, 0, 0, 0, 31, 21, 196, 137, 0, 0, 0, 10, 73, 68, 65,
    84, 120, 156, 99, 0, 1, 0, 0, 5, 0, 1, 13, 10, 45, 180, 0, 0, 0, 0, 73,
    69, 78, 68, 174, 66, 96, 130 // prevent dartfmt
  ]);

  // copy from decodeImageFromList of package:flutter/painting.dart
  final codec = await instantiateImageCodec(bytes);
  final frameInfo = await codec.getNextFrame();
  return frameInfo.image;
}



Container(
    height: MediaQuery.of(context).size.height * .2,
    width: MediaQuery.of(context).size.width * .9,
  
  child:Image.memory(
    base64.decode(controlleR.offersList[index].pictureEn.toString()),
  ),
);

반응형