flare_draw 1.0.0 copy "flare_draw: ^1.0.0" to clipboard
flare_draw: ^1.0.0 copied to clipboard

A high-performance Flutter drawing and signature canvas with Catmull-Rom bezier smoothing, pressure sensitivity, undo/redo, and PNG export.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flare_draw/flare_draw.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'FlareDraw Example',
      debugShowCheckedModeBanner: false,
      theme: ThemeData.dark(useMaterial3: true),
      home: const DrawingScreen(),
    );
  }
}

class DrawingScreen extends StatefulWidget {
  const DrawingScreen({super.key});
  @override
  State<DrawingScreen> createState() => _DrawingScreenState();
}

class _DrawingScreenState extends State<DrawingScreen> {
  late final FlareDrawController _controller;

  @override
  void initState() {
    super.initState();
    _controller = FlareDrawController(
      config: const FlareDrawConfig(
        backgroundColor: Colors.white,
        enablePressureSensitivity: true,
        maxUndoSteps: 50,
      ),
    );
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  Future<void> _exportPng() async {
    final bytes = await FlareDrawExporter.toPng(_controller, pixelRatio: 3.0);
    if (bytes == null || !mounted) return;
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(
        content: Text('Exported ${bytes.length ~/ 1024} KB PNG'),
        backgroundColor: Colors.green,
        behavior: SnackBarBehavior.floating,
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xFF0A0A15),
      appBar: AppBar(
        backgroundColor: const Color(0xFF0F0F1A),
        title: const Text('FlareDraw', style: TextStyle(fontWeight: FontWeight.bold)),
        actions: [
          IconButton(
            icon: const Icon(Icons.download_rounded),
            onPressed: _exportPng,
            tooltip: 'Export PNG',
          ),
        ],
      ),
      body: ClipRRect(
        child: FlareDrawCanvas(
          controller: _controller,
          config: const FlareDrawConfig(
            showToolbar: true,
            enablePressureSensitivity: true,
          ),
        ),
      ),
    );
  }
}
0
likes
130
points
30
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A high-performance Flutter drawing and signature canvas with Catmull-Rom bezier smoothing, pressure sensitivity, undo/redo, and PNG export.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flare_draw