暂存代码

Flutter 获取图片像素数据(rgba)

import 'dart:ui' as ui;
import 'package:flutter/material.dart';

// 以本地图片为例:
List RGBAList;
// 1. 获取 ImageProvider: 通过 `ExactAssetImage('$local_img_uri')` 获取 ExactAssetImage 对象
//    ExactAssetImage 继承 AssetBundleImageProvider 继承 ImageProvider
ExactAssetImage provider = ExactAssetImage('$local_img_uri');

// 2. 通过 ImageProvider 获取 ui.Image 对象
ImageStream stream = provider.resolve(ImageConfiguration.empty);
Completer completer = Completer();
ImageStreamListener listener = ImageStreamListener((frame, sync) {
    ui.Image image = frame.image;
    completer.complete(image);
    stream.removeListener(listener);
})
stream.addListener(listener);

// 3. 通过 ui.Image 对象获得 rgba 像素数据
completer.then((ui.Image image) {
    image.toByteData(format: ui.ImageByteFormat.rowRgba).then((ByteData data) {
        RGBAList = data.buffer.asUint8List().toList();
    }); 
})

quick app flex basis 测试 & 根节点最小高度不生效








quick app 根节点最小高度不生效




你可能感兴趣的:(暂存代码)