pencil_kit 1.0.8 copy "pencil_kit: ^1.0.8" to clipboard
pencil_kit: ^1.0.8 copied to clipboard

PlatformiOS

A Flutter plugin that provides a iOS PencilKit widget on iOS.

Flutter iOS Pencil Kit #

PencilKitMJStudio

pub package All Contributors licence

Flutter plugin for using iOS Pencil Kit.

Note 📒 #

  • This package only provides iOS implementation. If you try use widget of this package other than iOS, you see a Red warning box.
  • iOS Pencil Kit is available from iOS 13.0

Supported Platforms 📱 #

  • iOS

Features & Todo 🌟 #

  • Drawing
  • Show/Hide palette
  • Undo/Redo
  • Clear
  • UI properties(background color, scrollability, isOpaque, etc...)
  • Import/Export drawing data
  • Manage drawing tools programmatically

Requirements ✅ #

  • iOS: Deployment target >= 9.0

Setup & Usage 🎉 #

flutter pub add pencil_kit

Available Methods #

Methods available for PencilKitController.

Method Description Throws
clear() Clear canvas X
show() Show Palette X
hide() Hide Palette X
redo() Redo last drawing action X
undo() Undo last drawing action X
save(): Future<String?> Save drawing data into file system, can return base 64 data if withBase64Data is true O
load(): Future<String?> Load drawing data from file system, can return base 64 data if withBase64Data is true O
getBase64Data(): Future Get current drawing data as base64 string form O
loadBase64Data(String base64Data): Future Load base64 drawing data into canvas O
setPKTool({required ToolType toolType, double? width, Color? color}): Future Set PKTool type with width and color X

Caution for setPKTool #

setPKTool can fail if tool type is not supported by device iOS version In eraser tools, the width parameter will work only from iOS 16.4 or above iOS version

You should check whether feature is available in user's iOS version with [ToolType.isAvailableFromIos16_4] and [ToolType.isAvailableFromIos17]

Read more about ToolType type definition.

Type definition
/// PKTool type enum for [PencilKitController.setPKTool]
enum ToolType {
  /// pen tool
  pen(false, false),

  /// pencil tool
  pencil(false, false),

  /// marker tool
  marker(false, false),

  /// monoline tool, available from iOS 17.0
  monoline(false, true),

  /// fountainPen tool, available from iOS 17.0
  fountainPen(false, true),

  /// watercolor tool, available from iOS 17.0
  watercolor(false, true),

  /// crayon tool, available from iOS 17.0
  crayon(false, true),

  /// vector eraser tool
  eraserVector(false, false),

  /// bitmap eraser tool
  eraserBitmap(false, false),

  /// fixed width bitmap eraser tool, available from iOS 16.4
  eraserFixedWidthBitmap(true, false),
  ;

  const ToolType(this.isAvailableFromIos16_4, this.isAvailableFromIos17);

  final bool isAvailableFromIos16_4;
  final bool isAvailableFromIos17;
}

PencilKit Widget Parameters #

All the available parameters.

Parameter Description
onPencilKitViewCreated A callback for platform view created. You can store PencilKitController from argument of this callback.
hitTestBehavior iOS UIKitView hitTestBehavior
unAvailableFallback A widget for render UnAvailable state. The default is A red box
alwaysBounceVertical A Boolean value that determines whether bouncing always occurs when vertical scrolling reaches the end of the content.
alwaysBounceHorizontal A Boolean value that determines whether bouncing always occurs when horizontal scrolling reaches the end of the content view.
isRulerActive A Boolean value that indicates whether a ruler view is visible on the canvas.
drawingPolicy The policy that controls the types of touches allowed when drawing on the canvas. This properties can be applied from iOS 14.0
onToolPickerVisibilityChanged A callback for tool picker visibility state changed
onRulerActiveChanged A callback for ruler activate state changed

Example #

Check example on pub.dev page or example project repo

Contributors ✨ #

Thanks goes to these wonderful people (emoji key):

MJ Studio
MJ Studio

🤔
Jack Szeto
Jack Szeto

💻
frybitsinc
frybitsinc

💻
bomb0069
bomb0069

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

25
likes
140
pub points
73%
popularity

Publisher

unverified uploader

A Flutter plugin that provides a iOS PencilKit widget on iOS.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on pencil_kit