p5 0.0.2

  • README.md
  • Installing
  • Versions
  • new65


A Dart implementation of the Processing API for Flutter. Processing is a software sketchbook and a language for learning how to code within the context of the visual arts.

Getting Started

Add the p5 package to your Flutter app. For help using packages, see Flutter's online documentation.

You need to implement the widget containing the Processing sketch, and the sketch itself.

A simple widget tree is the follwing:

import 'package:flutter/material.dart';

import "package:p5/p5.dart";
import "sketch.dart";

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

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  _MyHomePageState createState() {
    return new _MyHomePageState();

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'P5 Demo',
      theme: new ThemeData(
        // This is the theme of your application.
        primarySwatch: Colors.blue,
      home: new MyHomePage(title: 'P5 Demo Home Page'),

class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
  MySketch sketch;
  PAnimator animator;

  void initState() {
    sketch = new MySketch();
    // Need an animator to call the draw() method in the sketch continuously,
    // otherwise it will be called only when touch events are detected.
    animator = new PAnimator(this);
    animator.addListener(() {
      setState(() {

  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(title: new Text("P5 Draw!")),
      backgroundColor: const Color.fromRGBO(200, 200, 200, 1.0),
      body: new Center(
        child:new PWidget(sketch),

The MySketch class has to extend the base PPainter clas in the p5 package, and implement the setup() and draw() functions:

class MySketch extends PPainter {
  void setup() {
    size(300, 300);

  void draw() {
    background(color(255, 255, 255));

Both pieces of code can be inside single dart file, or on separate files for better clarity.

A simple drawing sketch can be implemented by handling the mouse dragging, and storing the pointer positions in a list of PVector object holding the (x, y) coordinates, which are then used to draw lines:

class MySketch extends PPainter {
  var strokes = new List<List<PVector>>();

  void setup() {

  void draw() {
    background(color(255, 255, 255));

    stroke(color(10, 40, 200, 60));
    for (var stroke in strokes) {
      for (var p in stroke) {
        vertex(p.x, p.y);

  void mousePressed() {
    strokes.add([new PVector(mouseX, mouseY)]);

  void mouseDragged() {
    var stroke = strokes.last;
    stroke.add(new PVector(mouseX, mouseY));

Notice that the size of the drawing area can be made to fill the entire app by using fullScreen(). The app should give similar results for both iOS and Android:

P5 drawing sketch running in iPhone 6S and Nexus 5X

For help getting started with Flutter, view our online documentation.

For help on editing package code, view the documentation.

[0.0.1] - June 26, 2018.

  • First release with a few Processing API functions in PPainter.
  • PAnimator utility class to drive continuous frama animation.
  • Basic touch event handling

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  p5: "^0.0.2"

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

      import 'package:p5/p5.dart';
Version Uploaded Documentation Archive
0.0.2 Jun 26, 2018 Go to the documentation of p5 0.0.2 Download p5 0.0.2 archive
0.0.1 Jun 26, 2018 Go to the documentation of p5 0.0.1 Download p5 0.0.1 archive


We analyzed this package on Jul 13, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3
  • Flutter: 0.5.4


Describes how popular the package is relative to other packages. [more]
30 / 100
Code health derived from static analysis. [more]
99 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 2 hints.

    Run flutter format to format lib/p5.dart.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use p5.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.23.0 <2.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.6 1.14.10
meta 1.1.5
sky_engine 0.0.99
typed_data 1.1.5
vector_math 2.0.6 2.0.7
Dev dependencies