### Install Dependencies Source: https://pub.dev/packages/flutter_gen_runner Run 'flutter pub get' to install the dependencies listed in your pubspec.yaml file. ```bash flutter pub get ``` -------------------------------- ### Install fluttergen using Homebrew Source: https://pub.dev/packages/flutter_gen_runner Install the fluttergen command-line tool on macOS and Linux using the Homebrew package manager. ```bash brew install FlutterGen/tap/fluttergen ``` -------------------------------- ### Example pubspec.yaml Entry Source: https://pub.dev/packages/flutter_gen_runner/versions/3.1.1/install This is how the dependency will appear in your pubspec.yaml file after running the add command. ```yaml dependencies: flutter_gen_runner: ^3.1.1 ``` -------------------------------- ### Example pubspec.yaml Dependency Source: https://pub.dev/packages/flutter_gen_runner/versions/3.0.2/install This is an example of how the flutter_gen_runner dependency will appear in your pubspec.yaml file after running the add command. ```yaml dependencies: flutter_gen_runner: ^3.0.2 ``` -------------------------------- ### Flutter Gen Runner Example Usage Source: https://pub.dev/packages/flutter_gen_runner/example This example demonstrates how to use the generated code from flutter_gen_runner to display assets, apply fonts, and use colors. It includes examples for images, SVGs, Rive, Lottie, custom fonts, and theme colors. ```dart import 'package:example_resources/gen/assets.gen.dart'; import 'package:flutter/material.dart'; import 'gen/assets.gen.dart'; import 'gen/colors.gen.dart'; import 'gen/fonts.gen.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); // await Firebase.initializeApp( // options: DefaultFirebaseOptions.currentPlatform, // ); runApp(MaterialApp( title: 'Flutter Demo', theme: ThemeData( // Auto generated font from FlutterGen. fontFamily: MyFontFamily.raleway, primarySwatch: MyColorName.crimsonRed, ), home: Scaffold( appBar: AppBar( title: const Text('FlutterGen'), ), body: Center( child: SingleChildScrollView( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ // Auto generated image from FlutterGen. SizedBox( width: 200, height: 200, child: MyAssets.rive.vehicles.rive( fit: BoxFit.contain, ), ), SizedBox( width: 200, height: 200, child: MyAssets.lottie.hamburgerArrow.lottie( fit: BoxFit.contain, ), ), SizedBox( width: 200, height: 200, child: MyAssets.lottie.geometricalAnimation.lottie( fit: BoxFit.contain, ), ), SizedBox( width: 200, height: 200, child: MyAssets.lottie.alarmClockLottieV440.lottie( fit: BoxFit.contain, ), ), MyAssets.images.chip1.image(), Container( height: 400, decoration: BoxDecoration( image: DecorationImage( image: MyAssets.images.chip1.provider(), ), ), child: const Center(child: Text('Deco')), ), // Use from example_resource package. MyAssets.images.icons.kmm.svg(key: const Key("kmm_svg")), MyAssets.images.icons.fuchsia.svg(), MyAssets.images.icons.paint.svg( width: 120, height: 120, ), // MyAssets.pictures.chip5.image( // key: const Key("chip5"), // width: 120, // height: 120, // fit: BoxFit.scaleDown, // ), // example_resource package. Text(MyAssets.images.icons.kmm.path), Text(MyAssets.images.icons.kmm.keyName), Text(ResAssets.images.dart.path), Text(ResAssets.images.dart.keyName), ResAssets.images.flutter3.image(), ResAssets.images.dart.svg(), SizedBox( width: 200, height: 200, child: ResAssets.images.skills.rive( fit: BoxFit.contain, ), ), SizedBox( width: 200, height: 200, child: ResAssets.images.runningCarOnRoad.lottie( fit: BoxFit.contain, ), ), const Text( 'Hi there, I\'m FlutterGen', style: TextStyle( // Auto generated color from FlutterGen. color: MyColorName.black60, // Auto generated font from FlutterGen. fontFamily: MyFontFamily.robotoMono, fontFamilyFallback: [MyFontFamily.raleway], ), ), ], ), ), ), ), )); } ``` -------------------------------- ### Add and Install fluttergen using asdf Source: https://pub.dev/packages/flutter_gen_runner Add the fluttergen plugin to asdf and install the latest version for macOS and Linux. ```bash # add plugin asdf plugin add fluttergen # or asdf plugin add fluttergen https://github.com/FlutterGen/asdf-fluttergen.git # install fluttergen asdf install fluttergen latest ``` -------------------------------- ### Example pubspec.yaml Dependency Source: https://pub.dev/packages/flutter_gen_runner/versions/2.0.1/install This is how the dependency will appear in your pubspec.yaml file after running the add command. ```yaml dependencies: flutter_gen_runner: ^2.0.1 ``` -------------------------------- ### Check flutter_gen --version Source: https://pub.dev/packages/flutter_gen_runner/versions/4.1.0/changelog Command to display the installed flutter_gen version. ```bash % fluttergen --version FlutterGen v4.1.0 ``` -------------------------------- ### Check FlutterGen Version Source: https://pub.dev/packages/flutter_gen_runner/versions/4.2.1/changelog Command to display the installed version of FlutterGen. ```bash % fluttergen --version FlutterGen v4.1.0 ``` -------------------------------- ### Example pubspec.yaml Entry Source: https://pub.dev/packages/flutter_gen_runner/versions/2.0.1-dev.0/install This is how the flutter_gen_runner dependency will appear in your pubspec.yaml file after running the add command. ```yaml dependencies: flutter_gen_runner: ^2.0.1-dev.0 ``` -------------------------------- ### Integrate Lottie Files Source: https://pub.dev/packages/flutter_gen_runner/versions/5.13.0%2B1/changelog Example of how to use Lottie files with the Assets.lottie integration. Ensure the lottie file is correctly placed in your assets folder. ```dart SizedBox( width: 200, height: 200, child: Assets.lottie.hamburgerArrow.lottie( fit: BoxFit.contain, ), ), ``` -------------------------------- ### Generate Dartdoc for Assets and Colors Source: https://pub.dev/packages/flutter_gen_runner/versions/4.1.0/changelog Example of generated dartdoc for asset images and color constants. ```dart /// File path: pictures/chip5.jpg AssetGenImage get chip5 => const AssetGenImage('pictures/chip5.jpg'); /// Color: #979797 static const Color gray410 = Color(0xFF979797); ``` -------------------------------- ### Generated Font Class Example Source: https://pub.dev/packages/flutter_gen_runner Example of a generated font class that includes package information, allowing for package-specific font references. ```dart class Fonts { Fonts._(); static const String package = 'test'; static const String raleway = 'packages/$package/Raleway'; static const String robotoMono = 'packages/$package/RobotoMono'; } ``` -------------------------------- ### Generate Dartdoc for Assets Source: https://pub.dev/packages/flutter_gen_runner/versions/4.2.1/changelog Example of how Dartdoc is generated for asset images and color constants. ```dart /// File path: pictures/chip5.jpg AssetGenImage get chip5 => const AssetGenImage('pictures/chip5.jpg'); /// Color: #979797 static const Color gray410 = Color(0xFF979797); ``` -------------------------------- ### Example pubspec.yaml Dependency Source: https://pub.dev/packages/flutter_gen_runner/versions/2.0.0/install This is how the flutter_gen_runner dependency will appear in your pubspec.yaml file after running the add command. ```yaml dependencies: flutter_gen_runner: ^2.0.0 ``` -------------------------------- ### Usage Example of Generated Colors Source: https://pub.dev/packages/flutter_gen_runner Demonstrates how to use the generated color constants in a Flutter application's `TextStyle`. ```dart Text( 'Hi there, I\'m FlutterGen', style: TextStyle( color: ColorName.denim, ), ``` -------------------------------- ### Generate ImageProvider for Assets Source: https://pub.dev/packages/flutter_gen_runner/changelog Example of how to use the generated ImageProvider for assets. This is useful for applying images as decorations or in other widgets that accept an ImageProvider. ```dart // Assets.images.chip.provider() Container( height: 400, decoration: BoxDecoration( image: DecorationImage( image: Assets.images.chip.provider(), ), ), child: const Center(child: Text('Deco')), ), ``` -------------------------------- ### Use ImageProvider for Assets Source: https://pub.dev/packages/flutter_gen_runner/versions/5.0.1/changelog Example of using the generated ImageProvider for assets, which can be directly used in widgets like BoxDecoration. Ensure assets are correctly configured in pubspec.yaml. ```dart // Assets.images.chip.provider() Container( height: 400, decoration: BoxDecoration( image: DecorationImage( image: Assets.images.chip.provider(), ), ), child: const Center(child: Text('Deco')), ), ``` -------------------------------- ### Generated Assets Class with Package Constant Source: https://pub.dev/packages/flutter_gen_runner Example of an `Assets` class generated when `package_parameter_enabled` is true, including a `package` constant. ```dart class Assets { const Assets._(); static const String package = 'test'; static const $AssetsImagesGen images = $AssetsImagesGen(); static const $AssetsUnknownGen unknown = $AssetsUnknownGen(); } ``` -------------------------------- ### Configure flutter_gen for Null Safety Source: https://pub.dev/packages/flutter_gen_runner/versions/4.0.0/changelog Configuration example for flutter_gen enabling null safety and setting output directory and line length. ```yaml flutter_gen: output: lib/gen/ line_length: 80 null_safety: true # Optional (default: true) ``` -------------------------------- ### Use setup-fluttergen GitHub Action Source: https://pub.dev/packages/flutter_gen_runner Integrate the setup-fluttergen GitHub Action into your CI/CD workflow to manage fluttergen versions. ```yaml - uses: FlutterGen/setup-fluttergen@v1 with: version: ${{ fluttergen_version }} ``` -------------------------------- ### FlutterGen CLI Help Source: https://pub.dev/packages/flutter_gen_runner Displays help information for the fluttergen command. ```bash fluttergen -h ``` -------------------------------- ### Update flutter_gen_runner Dependency Source: https://pub.dev/packages/flutter_gen_runner/versions/4.1.2%2B1/changelog Example of updating the dev_dependencies to use flutter_gen_runner. ```yaml dev_dependencies: flutter_gen_runner: ^2.0.0 ``` -------------------------------- ### Generate Lottie Animation Widget Source: https://pub.dev/packages/flutter_gen_runner/changelog Example of how to use the generated Lottie animation provider method. Ensure Lottie files are correctly placed in the assets folder. ```dart SizedBox( width: 200, height: 200, child: Assets.lottie.hamburgerArrow.lottie( fit: BoxFit.contain, ), ), ``` -------------------------------- ### Handle At Symbol in Filenames Source: https://pub.dev/packages/flutter_gen_runner/changelog Example of generating an AssetGenImage for a file containing an at symbol (@) in its name. ```dart AssetGenImage get logo2x => const AssetGenImage('assets/images/logo@2x.png'); ``` -------------------------------- ### Configure Asset Output Options Source: https://pub.dev/packages/flutter_gen_runner/versions/5.0.0/changelog Configure `package_parameter_enabled` and `style` for asset generation. These options are now nested under `assets.outputs`. ```yaml flutter_gen: # ... assets: package_parameter_enabled: true style: snake-case outputs: class_name: MyAssets ``` ```yaml flutter_gen: # ... assets: outputs: class_name: MyAssets package_parameter_enabled: true style: snake-case ``` -------------------------------- ### AssetGenImage with Special Characters in Filename Source: https://pub.dev/packages/flutter_gen_runner/versions/4.2.1/changelog Example demonstrating support for the '@' symbol in asset file names. ```dart AssetGenImage get logo2x => const AssetGenImage('assets/images/logo@2x.png'); ``` -------------------------------- ### Support '@' Symbol in File Names Source: https://pub.dev/packages/flutter_gen_runner/versions/4.1.0/changelog Example of generating an SvgGenImage with a file name containing the '@' symbol. ```dart SvgGenImage get logo2x => const SvgGenImage('assets/images/logo@2x.png'); ``` -------------------------------- ### Implicit Asset Usage with Package Source: https://pub.dev/packages/flutter_gen_runner Demonstrates implicit usage of assets with the package name when `package_parameter_enabled` is true. This is suitable for widgets like `Image`, `SvgPicture`, and `Lottie`. ```dart // Implicit usage for `Image`/`SvgPicture`/`Lottie`. Widget build(BuildContext context) { return Assets.images.icons.paint.svg( width: 120, height: 120, ); } ``` -------------------------------- ### Generated asset image constant Source: https://pub.dev/packages/flutter_gen_runner/versions/5.12.0/changelog Example of a generated constant for an asset image, used for handling duplicate file names. ```dart // generated codes static const AssetGenImage imagesProfileJpg = AssetGenImage('assets/images/profile.jpg'); static const AssetGenImage imagesProfilePng = AssetGenImage('assets/images/profile.png'); ``` -------------------------------- ### Import flutter_gen_runner in Dart Code Source: https://pub.dev/packages/flutter_gen_runner/versions/2.0.0/install Import the necessary build file from the package into your Dart code to start using its features. ```dart import 'package:flutter_gen_runner/build.dart'; ```