How can I read (from disk) and resize an image, in

2020-02-09 04:03发布

In Flutter/Dart, how can I perform the following 3 steps:

  1. Read an image from disk,
  2. Read its original dimensions (width and height),
  3. Resize it.

Note: I must be able to display the final result with a regular Flutter Image widget.

CLARIFICATION: I don't want to save the image, but I do want to actually resize it in memory.

7条回答
我只想做你的唯一
2楼-- · 2020-02-09 04:39

You can use the Image widget in the Scaffold widget,

First of all you need to create assets folder in the root and add an images folder, after that add,

    flutter:
      assets:
        - assets/images/

to the pubspec.yaml file, after that

new Image(
          image: AssetImage('assets/images/pizzaFont.png'),
          height: 12,
          width:12, ......
   )

You can use width and height to change the size of the image.

For more information follow,

https://medium.com/@suragch/how-to-include-images-in-your-flutter-app-863889fc0b29

查看更多
登录 后发表回答