Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would like to be able to avoid asset load errors at runtime #11477

Open
eseidelGoogle opened this issue Aug 2, 2017 · 3 comments
Open

Would like to be able to avoid asset load errors at runtime #11477

eseidelGoogle opened this issue Aug 2, 2017 · 3 comments
Labels
a: assets Packaging, accessing, or using assets framework flutter/packages/flutter repository. See also f: labels. P3 Issues that are less important to the Flutter project team-framework Owned by Framework team tool Affects the "flutter" command-line tool. See also t: labels. triaged-framework Triaged by Framework team

Comments

@eseidelGoogle
Copy link
Contributor

eseidelGoogle commented Aug 2, 2017

Currently with Flutter it's very easy to end up with asset load errors at runtime since assets are keyed off of strings, which are not in any way validated at analyze time (or generated/provided by the system).

Posse's currently most common crash in their live app is a failed asset string load.

They also have a manual file of string constants that they maintain from their pubspec.yaml (presumably could be autogenerated pretty easily).

This just seems like a pattern we could help with. This bug is about finding ideas to reduce the likelihood of this kind of failure.

FYI @yjbanov

@Hixie
Copy link
Contributor

Hixie commented May 8, 2018

We could autogenerate an enum of known asset names, or some such.

@Hixie Hixie added tool Affects the "flutter" command-line tool. See also t: labels. framework flutter/packages/flutter repository. See also f: labels. a: assets Packaging, accessing, or using assets labels May 8, 2018
@Hixie Hixie added this to the Stretch Goals milestone May 8, 2018
@fmatosqg
Copy link
Contributor

I'm still keen to deliver this, I was never sure what was flutter team's opinion on it. My POC is frozen since the beta days. I'll come up with some MVP clean enough that it could be a PR. Soon (TM).

@Hixie Hixie modified the milestones: Stretch Goals, New Stretch Goals Jan 7, 2020
@jmagman jmagman added this to Awaiting triage in Tools - assets review Jan 10, 2020
@jonahwilliams jonahwilliams moved this from Awaiting triage to Engineer reviewed in Tools - assets review Jan 15, 2020
@YK-Unit
Copy link

YK-Unit commented Feb 26, 2020

Hi, all:

I'm a member of Fly-Mix Team from NetEase company. My team did develop a flutter development tool: Flr(Flutter-R) to support the feature that you want.

Flr is a flutter resource manager tool, which can help flutter developer to auto specify assets in pubspec.yaml and generate r.g.dart file which likes R.java in Android after he changes the flutter project assets. With r.g.dart, flutter developer can apply the asset in code by referencing it's asset ID function, such as:

import 'package:flutter_r_demo/r.g.dart';

// test_sameName.png
var normalImageWidget = Image(
  width: 200,
  height: 120,
  image: R.image.test_sameName(),
);

// test_sameName.gif
var gifImageWidget = Image(
  image: R.mage.test_sameName_gif(),
);

// test.svg
var svgImageWidget = Image(
  width: 100,
  height: 100,
  image: R.svg.test(width: 100, height: 100),
);

// test.json
var jsonString = await R.text.test_json();

// test.yaml
var yamlString = await R.text.test_yaml();

PS: yes, it is just like the AAPT(Android Asset Packaging Tool) in Android.

Up to now, Flr has supported Android Studio Plugin, CLI, and VSCode Extension:

  1. Flr Android Studio Plugin Version

  2. Flr CLI Version

  3. Flr VSCode Extension Version

@kf6gpe kf6gpe added the P3 Issues that are less important to the Flutter project label May 29, 2020
@kf6gpe kf6gpe modified the milestone: Stretch Goals Jun 1, 2020
@Hixie Hixie removed this from the [DEPRECATED] Stretch Goals milestone Jun 16, 2020
@kf6gpe kf6gpe removed this from the [DEPRECATED] Stretch Goals milestone Jul 7, 2020
@kf6gpe kf6gpe modified the milestone: [DEPRECATED] Stretch Goals Jul 22, 2020
@Hixie Hixie removed this from the - milestone Aug 17, 2020
@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-framework Owned by Framework team triaged-framework Triaged by Framework team labels Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: assets Packaging, accessing, or using assets framework flutter/packages/flutter repository. See also f: labels. P3 Issues that are less important to the Flutter project team-framework Owned by Framework team tool Affects the "flutter" command-line tool. See also t: labels. triaged-framework Triaged by Framework team
Projects
Tools - assets review
  
Engineer reviewed
Development

No branches or pull requests

6 participants