To generate indexed constants for your assets in dart/flutter project! Inspired by android R.java concept
dev_dependencies:
assets_indexer: ^0.0.6
also, don't forget to add
dev_dependencies:
build_runner:
flutter packages pub run build_runner build
you can find your generated assets classes in lib/generated/<asset_dir_name>.asset.dart
flutter:
assets:
- assets/images
import 'package:example_app/generated/images.asset.dart';
import 'package:flutter/material.dart';
class Home extends StatelessWidget{
@override
Widget build(BuildContext context){
return Scaffold(
body: Center(
child: Image.asset(Images.icon,width: 100)
)
)
}
}