assetgeneratorkit 0.1.0
assetgeneratorkit: ^0.1.0 copied to clipboard
Generate typed Flutter asset accessors for SVG, Lottie, image, and generic assets.
import 'package:flutter/material.dart';
import 'generated/assets.dart';
void main() {
runApp(const AssetGeneratorKitExampleApp());
}
class AssetGeneratorKitExampleApp extends StatelessWidget {
const AssetGeneratorKitExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Asset Generator Kit',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFF2563EB)),
useMaterial3: true,
),
home: const AssetsExampleScreen(),
);
}
}
class AssetsExampleScreen extends StatelessWidget {
const AssetsExampleScreen({super.key});
@override
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
return Scaffold(
appBar: AppBar(title: const Text('Asset Generator Kit')),
body: ListView(
padding: const EdgeInsets.all(24),
children: [
Text(
'Generated assets',
style: Theme.of(context).textTheme.headlineMedium,
),
const SizedBox(height: 8),
Text(
'These widgets are created from example/assets by running the generator.',
style: Theme.of(context).textTheme.bodyMedium,
),
const SizedBox(height: 32),
_AssetPreview(
title: 'SVG icon',
subtitle: 'AppAssets.home(size: 40, color: colors.primary)',
child: AppAssets.home(size: 40, color: colors.primary),
),
const SizedBox(height: 16),
_AssetPreview(
title: 'SVG logo',
subtitle: 'AppAssets.logo(size: 96)',
child: AppAssets.logo(size: 96),
),
const SizedBox(height: 16),
_AssetPreview(
title: 'Lottie animation',
subtitle: 'AppAssets.success(width: 96, repeat: true)',
child: AppAssets.success(width: 96, height: 96, repeat: true),
),
],
),
);
}
}
class _AssetPreview extends StatelessWidget {
const _AssetPreview({
required this.title,
required this.subtitle,
required this.child,
});
final String title;
final String subtitle;
final Widget child;
@override
Widget build(BuildContext context) {
return DecoratedBox(
decoration: BoxDecoration(
border: Border.all(color: Theme.of(context).colorScheme.outlineVariant),
borderRadius: BorderRadius.circular(8),
),
child: Padding(
padding: const EdgeInsets.all(16),
child: Row(
children: [
SizedBox(width: 104, height: 104, child: Center(child: child)),
const SizedBox(width: 16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: Theme.of(context).textTheme.titleMedium,
),
const SizedBox(height: 4),
Text(
subtitle,
style: Theme.of(context).textTheme.bodySmall,
),
],
),
),
],
),
),
);
}
}