Comments (4)
But I know that is not a good design because the bar
instance here does not hold any properties. It just like an access helper.
JFYI. Close it now. Thanks for reply.
from flutter_gen.
Since all generated values look like needn't to be evaluated in runtime? (can be static).
from flutter_gen.
Hi @nekocode!
Thanks for your feedback.
It seems like this problem does not relate to the getter method, but related to the path like structure we want to achieve.
For example, after changing the getter into a field it still cannot be used as the default parameter:
class Foo {
static const bar = Bar();
}
class Bar {
const Bar();
final value1 = "";
String get value2 => "";
}
void test({
String value1 = Foo.bar.value1, // The default value of an optional parameter must be constant.
String value2 = Foo.bar.value2, // The default value of an optional parameter must be constant.
}) {
//
}
Since Dart does not support the nested class, the Assets
class needs to hold some instances which hold the real asset path. And this caused the inconvenience usage for the default value. 😢
Speaking back to the getter, we just followed this lint rule avoid_field_initializers_in_const_classes.
Any further suggestions welcome! 😀
from flutter_gen.
Actually I means why not use static const field:
class Foo {
static const bar = Bar();
}
class Bar {
const Bar();
static const value1 = "";
}
So that we can access the const value1 by Foo.bar.value1
.
from flutter_gen.
Related Issues (20)
- [FR]: Thin & Upgrade dependencies
- [FR]: Linter to ensure the use of Assets.images instead of Image.asset(...)
- [BUG]: analyzer v6 is not supported HOT 4
- [BUG]: Unable to access the values when build with style: camel_case HOT 1
- [FR]: Support provider(..) for SVG images HOT 1
- [FR]: Asset path as const
- [FR]: Keyword name conflicts. Prefix the names? HOT 3
- Example links in README lead to Page Not Found
- [FR]: Add Localized Asset Generation HOT 1
- [FR]: Configure default image values HOT 1
- [BUG]: Including folders 1.0x, 2.0x, 3.0x, causes exception HOT 3
- [BUG]: The class 'FileSystemEvent' can't be extended HOT 9
- [BUG]: Why some json file doen't convert to LottieGenImage? HOT 4
- [FR]: Parsing colors into several separate classes. HOT 1
- [FR]: Support getting filename HOT 2
- [FR]: Fonts weight HOT 2
- [BUG]: flutter_svg `DefaultSvgTheme` not working
- [FR]: Support for useArtboardSize in RiveAnimation.asset
- [FR]: Conditionally bundling assets based on flavor HOT 3
- [FR]: Support for lottie zip archives
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_gen.