tss_poster 0.0.2
tss_poster: ^0.0.2 copied to clipboard
A comprehensive Flutter package for creating posters, flyers, and social media graphics.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:tss_poster/tss_poster.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Poster Creator Demo',
theme: ThemeData(
colorSchemeSeed: Colors.blue,
useMaterial3: true,
),
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Poster Creator Demo')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (_) => const PosterEditor()),
);
},
child: const Text('Create from Scratch'),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (_) => const AutoPosterPage()),
);
},
child: const Text('Auto Create Poster'),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (_) => const TemplatePage()),
);
},
child: const Text('Use Template'),
),
],
),
),
);
}
}
class AutoPosterPage extends StatelessWidget {
const AutoPosterPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Auto Poster')),
body: AutoPosterForm(
onGenerate: (poster) {
// Navigate to editor with generated poster
// Note: You'd need to pass the poster to the editor,
// which requires updating PosterEditor to accept an initial poster.
// For now, we'll just show a dialog.
showDialog(
context: context,
builder: (_) => AlertDialog(
title: const Text('Poster Generated'),
content:
Text('Generated poster with ${poster.layers.length} layers.'),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('OK'),
),
],
),
);
},
),
);
}
}
class TemplatePage extends StatelessWidget {
const TemplatePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Templates')),
body: TemplateGallery(
onSelect: (poster) {
if (poster.id.startsWith('paid')) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('This is a paid template!')),
);
} else {
// Navigate to editor
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Template selected!')),
);
}
},
),
);
}
}