0

I'm writting a flutter app where the program creates an image object using the 'image' library:

import 'package:image/image.dart' as img;
***
var mapImage = img.decodePng(File('images/map3a.png').readAsBytesSync());

in pubspec.yaml I have:

  assets:
    - images/
    - images/map3a.png

When I run this, I get the following error: FileSystemException: Cannot open file, path = 'images/map3c.png' (OS Error: No such file or directory, errno = 2) See also: https://flutter.dev/docs/testing/errors

However the following widget displays the image 'map3a' perfectly fine:

Container(
  color: Colors.white,
  child: Image.asset(
    'images/map3a.png',

  ),
),

I've looked around online but have not been able to find a solution/other people with a similar problem other than this post:

Flutter: Cannot open file, path.= {assets/} , No such file or directory exists, [Errno 2]

There was 1 solution where the person reccomended this site:

https://docs.flutter.dev/development/ui/assets-and-images#loading-flutter-assets-in-android

However I havent been able to find anything that works

Eren77
  • 1

0 Answers0