vishna / as2f Goto Github PK
View Code? Open in Web Editor NEWAndroid Strings to Flutter
License: Other
Android Strings to Flutter
License: Other
I tested the example with:
flutter pub run as2f:codegen --run-once
is returning:
⚙️ as2f.yaml loaded
✏️ /Users/xxxx/AndroidStudioProjects/flutter/as2f/example/carrots_sample
👋 KTHXBAI
however the carrots.dart file is not being created. I'm using it in my project and it also stopped working.
flutter --version
Flutter 1.12.13+hotfix.8 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 0b8abb4724 (7 weeks ago) • 2020-02-11 11:44:36 -0800
Engine • revision e1e6ced81d
Tools • Dart 2.7.0
Hi
I tried this generator but couldn't make it work on Windows 10 with VSCode.
In the VSCode terminal when executing the flutter packages pub run as2f:codegen
command I first had the following error message:
Trying to download as2f-699a11e9e6.jar ...
CreateProcessW failed 2
Failed to download https://jitpack.io/com/github/vishna/as2f/cli/699a11e9e6/cli-699a11e9e6-all.jar
Please download the jar manually and save it to .jarCache/as2f-699a11e9e6.jar.
Once this is complete just rerun pub command.
pub finished with exit code 1
So I manually downloaded the jar file and re-ran the command. I then had the following error message:
? as2f.yaml not found, creating one for you...
with the generator hanging on forever (killed it after 2 or 3 min with CTRL+C) and the as2f.yaml was never generated.
So I manually created the as2f.yaml and filled it with the necessary informations and rerun the command but the generator is still hanging forever (had to manually kill it once again) with no error meassage this time. Any idea of what might be the issue? (I used the strings.xml files from the carrots example for this test so the issue is not with the content of this files)
In some cases you might want to be able to use strings in more dynamic manner, e.g. backend driven a/b test.
Since dart on flutter offers no reflection we could generate extension method that could achieve that.
class StringKeys {
StringKeys._();
static const carrot = "carrot";
static const apple = "apple";
}
extension StringKeysExtension on S {
dynamic operator [](String key) {
switch(key) {
case StringKeys.carrot: return carrot;
case StringKeys.apple: return apple;
default: return null;
}
}
}
You could then use it in your code:
final apple1 = strings.apple;
final apple2 = strings["apple"];
final apple3 = strings[StringKeys.apple];
Beware the returned apple might not be a string value but a function in which case you need to know what arguments you want to use.
RATIONALE: this will be more Windows friendly
I wanted to do it but was getting 500 error from jitpack while wget handles this gracefully :|
if you put as a key in the xml file one of the following values:
the generated class will no longer compile, quick workaround for this would be to put trailing underscore
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.