小编Ale*_*yth的帖子

如何在颤振应用程序顶部覆盖小部件?

我想要一个位于整个应用程序顶部的小部件。当我尝试使用Overlay.of(context).insert叠加层执行此操作时,在替换该路线后稍后会消失。有没有一种方法可以让我的应用程序顶部有一个小部件,即使屏幕稍后弹出?

flutter flutter-layout

26
推荐指数
3
解决办法
2万
查看次数

如何将Flutter CameraImage从图像流转换为以Base64编码的二进制数据对象

通过在0.2.8版的颤振相机中引入图像流,我尝试将其集成到我的项目中以与AWS一起使用。

Amazon要求图像采用以下格式:

  • 图像字节Blob,最大5 MB。
  • 类型:Base64编码的二进制数据对象
  • 长度限制:最小长度为1。最大长度为5242880。

以前,我使用Camera包拍摄图片,加载图片,然后根据需要将其转换为Amazon,但是使用ImageStream更适合我想做的事情。我以前的方法是:

// Take the picutre
await _cameraController.takePicture(path);

// Load it from my filesystem
File imagefile = new File(path); 

// Convert to amazon requirements
List<int> imageBytes = imagefile.readAsBytesSync();
String base64Image = base64Encode(imageBytes);
Run Code Online (Sandbox Code Playgroud)

但是,使用图像流,我找不到任何简单的方法将转换为CameraImage亚马逊所需的格式。我对图像没有太多的经验,所以我很困惑。

我试图操纵Firebase ml和相机流演示中使用的代码

final int numBytes =
    image.planes.fold(0, (count, plane) => count += plane.bytes.length);
final Uint8List allBytes = Uint8List(numBytes);

int nextIndex = 0;
for (int i = 0; i < image.planes.length; i++) {
  allBytes.setRange(nextIndex, nextIndex + image.planes[i].bytes.length,
      image.planes[i].bytes);
  nextIndex …
Run Code Online (Sandbox Code Playgroud)

camera amazon-web-services dart flutter

8
推荐指数
1
解决办法
1503
查看次数