question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generate assets reference in the pubspec manifest (like R.java in android)

See original GitHub issue

Currently, we have to manual define the assets reference. Eg:

final logo = "assets/images/logo.png"

For small resource -> ok. But if we have many resources => it would be good if we can generate those references. (Look likes R.java in android world).

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:18 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
quangson91commented, Jun 15, 2018

@zoechi I think this is different. https://github.com/flutter/flutter/pull/16413 => about including all assets by the given folder.

This issue is an extra step. After we scan the access -> we should generate an R.dart file which including references to the resource.

Example for this case: https://github.com/fmatosqg/flutter_problem/blob/variants_PR_16413/lib/main.dart#L105

Instead write: 'assets/ic_error_outline_black_36dp.png', We can use generate source R.dart like: R.image.ic_error_outline_black

R.dart is a source code file -> it can be autocomplete by the IDE.

1reaction
jaumardcommented, Jul 25, 2018

Would like to see the same kind of generation for internationalization (like R.string in android) 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How *Exactly* to Access Flutter Assets From Within Android ...
There's a handy trick to list all packaged assets, which helps to see what path they are at, and that they got packaged....
Read more >
Indexing assets in a dart class just like R.java| Flutter - Medium
R.java contains a set of subclasses like drawable, mipmap etc which contains static variables to reference the assets & values.
Read more >
Integrate asset delivery (Kotlin & Java) - Android Developers
Place assets in the src/main/assets directory. You can create subdirectories in here as well. The directory structure for your app should now look...
Read more >
Flutter for Android developers
This document is meant for Android developers looking to apply their existing Android knowledge to build mobile apps with Flutter.
Read more >
How to add Flutter modules to native Android project and test ...
Adding Flutter module to native Android · Depend on the Android Archive (AAR): This packages your Flutter library as a generic local Maven ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found