Skip to main content

puck 0.0.2 copy "puck: ^0.0.2" to clipboard
puck: ^0.0.2 copied to clipboard

Floating, draggable pucks that spring to the left or right screen edge.

example/lib/main.dart

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

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

class PuckDemo extends StatefulWidget {
  const PuckDemo({super.key});

  @override
  State<PuckDemo> createState() => _PuckDemoState();
}

class _PuckDemoState extends State<PuckDemo> {
  bool _showDebugAnchors = false;

  @override
  Widget build(BuildContext context) => MaterialApp(
    title: 'Puck',
    theme: ThemeData(colorSchemeSeed: Colors.indigo),
    home: Scaffold(
      appBar: AppBar(title: const Text('Puck playground')),
      body: SafeArea(
        child: PuckOverlay(
          showDebugAnchors: _showDebugAnchors,
          onLongPress: () =>
              setState(() => _showDebugAnchors = !_showDebugAnchors),
          menuItems: [
            for (final icon in [Icons.home, Icons.search, Icons.settings])
              Material(
                color: Colors.indigo,
                child: IconButton(
                  onPressed: () => debugPrint('$icon tapped'),
                  icon: Icon(icon, color: Colors.white),
                ),
              ),
          ],
          puck: const ColoredBox(
            color: Colors.indigo,
            child: Icon(Icons.menu, color: Colors.white),
          ),
          child: const Center(
            child: Text(
              'Drag or fling the puck.\nTap to open or close the menu.\nLong-press to toggle anchor dots.',
              textAlign: TextAlign.center,
            ),
          ),
        ),
      ),
    ),
  );
}
0
likes
160
points
186
downloads

Documentation

API reference

Publisher

verified publisherflutterbountyhunters.com

Weekly Downloads

Floating, draggable pucks that spring to the left or right screen edge.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on puck