flutter_signature_pad 0.0.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 89

Flutter signature pad widget

Flutter widget to allow users to sign with finger and export the result as image.

Getting Started with Flutter

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

For help on editing package code, view the documentation.

Getting Started with the widget

This is a very simple widget that allow drawing by finger on a widget and be able to get the image back.

For very basic usage, please check the example file here

API

The constructor of the widget allow you to change the color (default to black) and the strokeWidth (default to 5.0)

clear: allow you to clear the area to start again

getData: allow you to retrieve the image

[0.0.1] - 05/07/2018.

  • Initial release.

example/example.dart

import 'dart:convert';
import 'dart:typed_data';
import 'dart:ui' as ui;

import 'package:flutter/material.dart';
import 'package:flutter_signature_pad/flutter_signature_pad.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 {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  ByteData _img = ByteData(0);

  @override
  Widget build(BuildContext context) {
    var sign = Signature(
      color: Colors.red,
      strokeWidth: 5.0,
    );
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              Expanded(child: sign),
              LimitedBox(
                  maxHeight: 200.0,
                  child: Image.memory(_img.buffer.asUint8List())),
              Padding(
                padding: EdgeInsets.all(25.0),
                child:
                    Row(mainAxisAlignment: MainAxisAlignment.center, children: [
                  MaterialButton(
                      color: Colors.green,
                      onPressed: () async {
                        //retrieve image data, do whatever you want with it (send to server, save locally...)
                        var data = await sign
                            .getData()
                            .toByteData(format: ui.ImageByteFormat.png);
                        setState(() {
                          _img = data;
                        });
                        debugPrint("onPressed " +
                            base64.encode(data.buffer.asUint8List()));
                      },
                      child: Text("Save")),
                  MaterialButton(
                      color: Colors.grey,
                      onPressed: () {
                        sign.clear();
                        debugPrint("cleared");
                      },
                      child: Text("Clear")),
                ]),
              )
            ],
          ),
        ) // This trailing comma makes auto-formatting nicer for build methods.
        );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_signature_pad: ^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:flutter_signature_pad/flutter_signature_pad.dart';
  
Version Uploaded Documentation Archive
0.0.2 Aug 24, 2018 Go to the documentation of flutter_signature_pad 0.0.2 Download flutter_signature_pad 0.0.2 archive
0.0.1 Jul 5, 2018 Go to the documentation of flutter_signature_pad 0.0.1 Download flutter_signature_pad 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
82
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
89
Learn more about scoring.

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

  • Dart: 2.0.0
  • pana: 0.12.3
  • Flutter: 0.8.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

Package is pre-v0.1 release.

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test