tss_poster 1.4.4 copy "tss_poster: ^1.4.4" to clipboard
tss_poster: ^1.4.4 copied to clipboard

A professional Canva-style poster editor with realistic templates, advanced editing tools, drag-and-drop, and cross-platform support for all devices.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:tss_poster/tss_poster.dart';
import 'dart:ui' as ui;

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'TSS Poster Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: PosterHomePage(),
      debugShowCheckedModeBanner: false,
    );
  }
}

class PosterHomePage extends StatefulWidget {
  @override
  _PosterHomePageState createState() => _PosterHomePageState();
}

class _PosterHomePageState extends State<PosterHomePage> {
  late PosterController controller;

  @override
  void initState() {
    super.initState();
    // Start with the first available template
    final templates = TemplateFactory.getAllTemplates();
    controller = PosterController(
      poster: templates.isNotEmpty
          ? templates.first.poster
          : PosterModel(
              backgroundColor: Colors.white,
              size: const Size(1080, 1920),
            ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('TSS Poster Editor'),
        actions: [
          IconButton(
            icon: const Icon(Icons.download),
            onPressed: () => _exportPoster(),
            tooltip: 'Export Poster',
          ),
        ],
      ),
      body: PosterEditor(
        controller: controller,
        initialPoster: controller.poster,
      ),
    );
  }

  Future<void> _exportPoster() async {
    try {
      // 1. Capture the image from the controller
      final image = await controller.exportAsImage();

      if (image == null) {
        if (mounted) {
          ScaffoldMessenger.of(context).showSnackBar(
            const SnackBar(content: Text('Failed to capture poster image')),
          );
        }
        return;
      }

      // 2. Save/Download the image using ExportService
      final result = await ExportService.saveImageToDevice(
        image: image,
        format: ExportFormat.png,
        quality: ExportQuality.high,
        filename: 'my_awesome_poster',
      );

      if (mounted) {
        ScaffoldMessenger.of(
          context,
        ).showSnackBar(SnackBar(content: Text(result.message)));
      }
    } catch (e) {
      if (mounted) {
        ScaffoldMessenger.of(
          context,
        ).showSnackBar(SnackBar(content: Text('Export failed: $e')));
      }
    }
  }

  @override
  void dispose() {
    controller.dispose();
    super.dispose();
  }
}
11
likes
0
points
849
downloads

Publisher

verified publishertechsukras.com

Weekly Downloads

A professional Canva-style poster editor with realistic templates, advanced editing tools, drag-and-drop, and cross-platform support for all devices.

Repository (GitHub)
View/report issues

Topics

#image-editor #canvas #poster #design

License

unknown (license)

Dependencies

file_picker, flutter, flutter_colorpicker, google_fonts, image_picker, path_provider, share_plus, uuid, web

More

Packages that depend on tss_poster