Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] How to access image in Android from Flutter?

Posted on November 14, 2022

Solution 1 :

Just like @jabamataro mentioned in the comments, define the path - android/app/src/main/res/mipmap-xxhdpi/ in the assets: section of the pubspec.yaml file like below:

assets:
    - android/app/src/main/res/mipmap-xxhdpi/

then the image could be used like:

AssetImage('android/app/src/main/res/mipmap-xxhdpi/temp.jpg');  

Hope this answer can help those new to Flutter development.

Solution 2 :

Load images folder in pubspec.yaml like

flutter:
  assets:
    - assets/images/

and then use it in image widget like

child: Image.asset('assets/images/splash_logo.png',
        height: 150,
        width: 150,
      fit: BoxFit.cover),

Problem :

I have a Flutter project that works well on both the iOS and Android platform.

In the Flutter project, there is an image located in android/app/src/main/res/mipmap-xxhdpi/temp.jpg,

and I want to load that image and use it in the Flutter widget.

I have tried to find answer in the document Adding assets and images and Flutter for Android developers but no luck.

How to do that? Thanks.

Comments

Comment posted by Flutter for Android

Flutter for Android

Comment posted by Shan

@Uni I know the way you mentioned, and it do works, but I was wondering how to access images that are

Comment posted by Shan

@jabamataro Yes, it works when I access the images located under the images folder, but not works for the path that I mentioned in the question.

Comment posted by jabamataro

@Shan have you tried changing the path to

Comment posted by Shan

@jabamataro It works!! You save my day, thanks! I am new to Flutter so did not realized it can work like that. I will update the answer based on your comments later. Really appreciate your help!

Comment posted by Ely Dantas

how can I do the opposite way, from Flutter directory to Android or xml’s src tag ?

READ  [ANSWERED] what the best practice to implement and alarm and reminder in android?
Powered by Inline Related Posts

Comment posted by Ely Dantas

can’t find example of using image reference in xml from android in flutter project, do you know how?

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress