persistent_canvas 1.0.5+5

  • Readme
  • Changelog
  • Example
  • Installing
  • 33

Persistent Canvas package for Flutter #

pub package

A Flutter package providing PixelBuffer and PersistentCanvas classes powered by PhotographTransducer.

1.0.3 - May 4, 2019 #

  • Add PersistentCanvasCoordinates

example/lib/main.dart

import 'dart:math';

import 'package:flutter/material.dart';

import 'package:persistent_canvas/persistent_canvas.dart';
import 'package:random_color/random_color.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

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

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  PersistentCanvas _canvas = PersistentCanvas(
    // [PersistentCanvas] will maintain a [ui.Image] of [Size] 'size'
    size: Size(250, 250),

    // Use "normalized" coordinates spanning [0,1]
    coordinates: PersistentCanvasCoordinates.preNormalized
  );

  RandomColor _randomColor = RandomColor();
  Random _random = Random();
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;

      // Draw a random circle
      _canvas.drawCircle(
        Offset(_random.nextDouble(), _random.nextDouble()),
        _random.nextDouble() / 20.0,
        Paint()..color = _randomColor.randomColor(),
      );
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
        actions: <Widget>[
          IconButton(
            icon: Icon(Icons.undo),
            onPressed: () => _canvas.model.walkVersion(-1),
          ),
          IconButton(
            icon: Icon(Icons.redo),
            onPressed: () => _canvas.model.walkVersion(1),
          ),
        ],
      ),

      body: Column(
        children: <Widget>[
          Container(
            padding: const EdgeInsets.all(40.0),
            alignment: Alignment.topCenter,
            child: Container(
              padding: const EdgeInsets.all(5.0),
              child: PersistentCanvasWidget(_canvas),
              decoration: BoxDecoration(
                border: Border.all(width: 5.0),
                borderRadius: BorderRadius.circular(5.0),
              ),
            )
          ),

          Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(
                  'You have pushed the button this many times:',
                ),
                Text(
                  '$_counter',
                  style: Theme.of(context).textTheme.display1,
                ),
              ],
            ),
          ),
        ],
      ),

      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  persistent_canvas: ^1.0.5+5

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:persistent_canvas/persistent_canvas.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
56
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
33
Learn more about scoring.

We analyzed this package on Apr 1, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health issues and suggestions

Fix lib/photograph_transducer.dart. (-25 points)

Analysis of lib/photograph_transducer.dart failed with 1 error:

line 90 col 23: The argument type 'void Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.

Fix lib/pixel_buffer.dart. (-25 points)

Analysis of lib/pixel_buffer.dart failed with 1 error:

line 224 col 24: 'PixelBufferImageProvider.load' ('ImageStreamCompleter Function(PixelBufferImageProvider)') isn't a valid override of 'ImageProvider.load' ('ImageStreamCompleter Function(PixelBufferImageProvider, Future

Format lib/persistent_canvas.dart.

Run flutter format to format lib/persistent_canvas.dart.

Format lib/persistent_canvas_stack.dart.

Run flutter format to format lib/persistent_canvas_stack.dart.

Maintenance issues and suggestions

No valid SDK. (-20 points)

The analysis could not detect a valid SDK that can use this package.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
busy_model ^1.0.0 1.0.0+0
flutter 0.0.0
image ^2.0.8 2.1.12
scoped_model ^1.0.1 1.0.1
Transitive dependencies
archive 2.0.13
args 1.6.0
charcode 1.1.3
collection 1.14.11 1.14.12
convert 2.1.1
crypto 2.1.4
meta 1.1.8
path 1.6.4
petitparser 3.0.2
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
xml 3.7.0 4.1.0