Git Product home page Git Product logo

assets_gen's Introduction

Hi there ๐Ÿ‘‹

GitHub stats

Top Langs

assets_gen's People

Contributors

chenenyu avatar hai046 avatar ricardodalarme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

assets_gen's Issues

Cannot use const assets name anymore

I have several const that defines some static data in my app.
Before using assets_gen, I could write something like this :
const breath = MultiSelectorItem('breath', 'assets/breath.svg', 'Breath');

But when using assets_gen, this line doesn't work anymore :
const breath = MultiSelectorItem('breath', Assets.breath.path, 'Breath');

It seems that it's because the generated class SvgGenImage.path is a getter, so NOT const.

class SvgGenImage {
  const SvgGenImage(this._assetName);

  final String _assetName;

  [...]

  String get path => _assetName;
  String get keyName => _assetName;
}

Do you have an idea how can I use the asset path in a const ?

EDIT :
I now I could remove flutter_svg: true in pubspec, but using this kind of code is also handy :
child: Assets.breath.svg()

Please format the generated code

Hi. Would you mind running 'flutter/dart fmt' on the generated code please.

Many of my projects have checks to ensure that the code is formatted correct. This is usually done with a simple dart format -o none --set-exit-if-changed .

However, dart/flutter don't provide a way to exclude files from the formatting, and the dart team don't plan on fixing this - dart-lang/dart_style#864 . This results in me having to implement the exclusion on my end, or format the generated code. I've finally done the latter, but I don't like having to add an explicit 'flutter format' for this package.

It would be awesome if this package could format its generated code. It would save me (and others) a lot of headache.

Generated Assets File has variable names with backslashes

When I run any of the build commands, the Assets file is broken because the variable names it creates contain backslashes.
Here is an example with only one asset in assets/images.

// GENERATED CODE - DO NOT MODIFY BY HAND

// **************************************************************************
// Total assets: 1.
// Generated by https://pub.dev/packages/assets_gen.
// **************************************************************************

// ignore_for_file: constant_identifier_names,non_constant_identifier_names,lines_longer_than_80_chars
class Assets {
  static const String package = 'mypackage';

  static const String assets\images\bottomCurvesPng = 'assets\images\bottom-curves.png';
  static const String mypackage$assets\images\bottomCurvesPng = 'packages/mypackage/assets\images\bottom-curves.png';
}

I have no idea if I'm doing something wrong or what the issue is.
Would be nice if it can be addressed any time soon.

Thanks!

Assets with _ in their name give an error

Hi. I have the following assets -

Animated_Checkmark.json                  No_Internet_-_Dark_Mode.json.json
Animated_X.json                          No_Orders_Yet.json
Loading_State.json                       No_Pending_Prescriptions.json
No_Internet_Animation_-_Light.json.json  Your_Cart_is_Empty_Animation.json.json

I'm running it with the following settings set in the pubspec.yaml file -

assets_gen:
  output: generated/assets.dart
  omit_path_levels: 1
  code_style: lowerCamelCase

I get the following error -

$ flutter pub run assets_gen build
[INFO] Building...
[INFO] Generating package:medl
Unhandled exception:
RangeError (end): Invalid value: Only valid value is 0: 1
#0      RangeError.checkValidRange (dart:core/errors.dart:363:9)
#1      _StringBase.substring (dart:core-patch/string_patch.dart:400:27)
#2      genContent (package:assets_gen/src/generator.dart:119:21)
#3      generate (package:assets_gen/src/generator.dart:17:22)
#4      runBuild (file:///home/vishesh/.pub-cache/hosted/pub.dartlang.org/assets_gen-1.3.0/bin/src/build.dart:17:3)
#5      main (file:///home/vishesh/.pub-cache/hosted/pub.dartlang.org/assets_gen-1.3.0/bin/assets_gen.dart:16:5)
#6      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:32)
#7      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
pub finished with exit code 255

Assets with space in file name don't work

Hello. I have some assets such as -

assets/lottie/Your Cart is Empty Animation.json.json which generates the following file -

static const String lottieYour Cart is Empty AnimationJsonJson = 'assets/lottie/Your Cart is Empty Animation.json.json';

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.