how can i add user defined variable in pubspec.yaml for flutter?
1,086
Is it possible to import another YAML file into pubspec.yaml
-
the answer to the above is No, it is not possible because
pubspec.yaml
does not support imports. -
Now for your main question : you can use YAML Anchors and Aliases for example :
# this line has the path , and stored in varName for future use we use *varName mydependancyPath : &varNam D:\mylocalDependancy # this line has the version number , so we can use *vers as a key that holds the value 2.8 myversion : &vers 2.8 #!join is to concatinate path : !join [*varName, *vers]
here is a more detailed resource because I'm not sure of the syntax but this should help with what you are looking for
Author by
Askarc Ali
Updated on December 25, 2022Comments
-
Askarc Ali over 1 year
Basically I required to assign version and my local dependencies URL as user defined variable and assign the same in the path or wherever I wish to
Example like below
mydependancyPath : D:\mylocalDependancy commonUtils: path: mydependancyPath
1.Please let me know how can I achieve as like above
2.Is it possible to import another YAML file into pubspec.yaml
In Android I can achieve as below
dagger_version=2.8 "com.google.dagger:dagger:${dagger_version}"