asset_helper 1.0.4 copy "asset_helper: ^1.0.4" to clipboard
asset_helper: ^1.0.4 copied to clipboard

A Flutter package that automatically generates reference files for assets in a Flutter project

example/lib/main.dart

import 'package:flutter/material.dart';
// After running "flutter pub run asset_helper:generate", you'll be able to import:
// 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: 'Asset Helper Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Asset Helper 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(
              'Example App for Asset Helper',
              style: TextStyle(fontSize: 18),
            ),
            const SizedBox(height: 20),
            const Text(
              'After running the asset generator, you can use:',
              style: TextStyle(fontSize: 16),
            ),
            const SizedBox(height: 20),
            Container(
              padding: const EdgeInsets.all(16),
              decoration: BoxDecoration(
                color: Colors.grey[200],
                borderRadius: BorderRadius.circular(8),
              ),
              child: const Text(
                'Image.asset(Assets.IconsHomeSVG)',
                style: TextStyle(
                  fontFamily: 'monospace',
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
            const SizedBox(height: 10),
            Container(
              padding: const EdgeInsets.all(16),
              decoration: BoxDecoration(
                color: Colors.grey[200],
                borderRadius: BorderRadius.circular(8),
              ),
              child: const Text(
                '// For a PNG file at assets/images/logo.png',
                style: TextStyle(
                  fontFamily: 'monospace',
                ),
              ),
            ),
            const SizedBox(height: 5),
            Container(
              padding: const EdgeInsets.all(16),
              decoration: BoxDecoration(
                color: Colors.grey[200],
                borderRadius: BorderRadius.circular(8),
              ),
              child: const Text(
                'Image.asset(Assets.ImagesLogoPNG)',
                style: TextStyle(
                  fontFamily: 'monospace',
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () {
                // Here you would use generated asset references
                // if you had real assets in the project
              },
              child: const Text('Use Assets'),
            ),
          ],
        ),
      ),
    );
  }
}
1
likes
0
points
41
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package that automatically generates reference files for assets in a Flutter project

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

analyzer, args, flutter, path, yaml

More

Packages that depend on asset_helper