This VS Code extension is used to automatically generate a dart class for managing Flutter assets.
How to use
After installing the plugin, when opening the Flutter project, it will start listening for file changes in the 'assets' directory and automatically generate the corresponding' assets. dart 'file after the changes The 'assets' directory name and the' assets. dart 'file name can both be customized and configured, as explained below.
Of course, you can also proactively execute the following two commands to trigger:
Add Custom Configuration
Add the following configuration information to pubspec.yaml.
The meaning of each field is as follows, with default values as shown in the code above.
Using in Code
You can simply use it this way. This will directly use the light image, ignoring the theme settings.
It is recommended to use it in conjunction with the provider. Like this below.
This usage may be a bit complicated and may seem a bit lengthy, but it can make the code versatile in any design style, such as MaterialApp, CupertinoApp, or other desktop style designs.
For ease of use, you can write your own extension for BuildContext, as shown below.
Then, you can easily obtain the required assets.