Skip to main content

apple_pencil_double_tap 2.0.0 copy "apple_pencil_double_tap: ^2.0.0" to clipboard
apple_pencil_double_tap: ^2.0.0 copied to clipboard

PlatformiOS

Flutter Apple Pencil double-tap and squeeze events on compatible iPads, with iPhone Duo compatibility and hardware-specific gesture availability.

example/lib/main.dart

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

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _applePencilDoubleTapPlugin = ApplePencilDoubleTap();

  @override
  void initState() {
    super.initState();
    initApplePencilListener();
  }

  void initApplePencilListener() {
    _applePencilDoubleTapPlugin.listen(
      v1Callback: (PreferredAction preferredAction) {
        debugPrint(
          'Double tap detected. Preferred user action: $preferredAction',
        );
      },
      onTapAction: (TapAction action) {
        debugPrint('TapAction: $action');
      },
      onSqueeze: (SqueezeAction action) {
        debugPrint('SqueezeAction: $action');
      },
      onError: (e) {
        debugPrint('Error: $e');
      },
    );
  }

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Apple pencil double tap plugin example app'),
        ),
        body: const Center(
          child: TextField(
            decoration: InputDecoration(
              hintText: "Write with Apple Pencil. On a supported iPad, double-tap or squeeze and check the logs.",
            ),
          ),
        ),
      ),
    );
  }
}
12
likes
160
points
2.37k
downloads

Documentation

API reference

Publisher

verified publishercodegrowers.tech

Weekly Downloads

Flutter Apple Pencil double-tap and squeeze events on compatible iPads, with iPhone Duo compatibility and hardware-specific gesture availability.

Homepage
Repository (GitHub)
View/report issues

Topics

#apple-pencil #ipad #iphone-duo #stylus #gestures

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on apple_pencil_double_tap

Packages that implement apple_pencil_double_tap