auto_gen_assets 1.0.5 copy "auto_gen_assets: ^1.0.5" to clipboard
auto_gen_assets: ^1.0.5 copied to clipboard

A Flutter package for automatically generating strongly-typed asset references from your assets directory.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'generated/assets.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Auto Gen Assets Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Auto Gen Assets Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'Assets loaded successfully!',
              style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
            ),
            const SizedBox(height: 20),
            const Text(
              'Generated asset paths:',
              style: TextStyle(fontSize: 18),
            ),
            const SizedBox(height: 10),
            Container(
              padding: const EdgeInsets.all(16),
              decoration: BoxDecoration(
                border: Border.all(color: Colors.grey),
                borderRadius: BorderRadius.circular(8),
              ),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text('Images: ${Assets.images.logo}'),
                  Text('Animations: ${Assets.animations.loading}'),
                  Text('Fonts: ${Assets.fonts.roboto}'),
                ],
              ),
            ),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () {
                // This would normally load the actual assets
                ScaffoldMessenger.of(context).showSnackBar(
                  const SnackBar(
                    content: Text('Asset paths are ready to use!'),
                  ),
                );
              },
              child: const Text('Test Asset Loading'),
            ),
          ],
        ),
      ),
    );
  }
}
1
likes
150
points
177
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package for automatically generating strongly-typed asset references from your assets directory.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, watcher

More

Packages that depend on auto_gen_assets