signature_pad_widget 2.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 88

Signature Pad Widget #

This is a fork, original project here: https://github.com/johnpryan/signature-pad-dart Flutter implementation of Signature Pad by Szymon Nowak.

2.0.0 - Feb 28th, 2020 #

  • Initial release

2.0.1 - Feb 28th, 2020 #

  • Minor pub fixes

example/lib/main.dart

import 'dart:async';

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

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

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        body: new Container(
          color: Colors.grey[300],
          child: new SafeArea(
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: new SignaturePadExample(),
            ),
          ),
        ),
      ),
    );
  }
}

class SignaturePadExample extends StatefulWidget {
  State<StatefulWidget> createState() {
    return new SignaturePadExampleState();
  }
}

class SignaturePadExampleState extends State<SignaturePadExample> {
  SignaturePadController _padController;
  bool isSignatureStarted = false;

  void initState() {
    super.initState();
    _padController = new SignaturePadController(onDrawStart: () {
      setState(() {
        isSignatureStarted = true;
      });
    });
  }

  Widget build(BuildContext context) {
    var signaturePad = new SignaturePadWidget(
      _padController,
      new SignaturePadOptions(
          dotSize: 5.0,
          minWidth: 1.0,
          maxWidth: 4.0,
          penColor: "#000000",
          signatureText: "Signed by Ringo Starr on Jan 1, 1962"),
    );
    return new Container(
      child: new Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          new Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              new Expanded(
                child: new Container(
                  height: 200.0,
                  child: new Center(
                    child: new AspectRatio(
                      aspectRatio: 3.0 / 1.0,
                      child: new Container(
                        decoration: new BoxDecoration(
                          color: Colors.white,
                          border: new Border.all(),
                        ),
                        child: signaturePad,
                      ),
                    ),
                  ),
                ),
              ),
            ],
          ),
          Padding(
            padding: const EdgeInsets.only(top: 8.0),
            child: new Row(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: <Widget>[
                new RaisedButton(
                  onPressed: _handleClear,
                  child: new Text("Clear"),
                  color: Colors.white,
                  textColor: Colors.black,
                ),
                new RaisedButton(
                  onPressed: isSignatureStarted ? _handleSavePng : null,
                  child: new Text("Save as PNG"),
                  color: Colors.white,
                  textColor: Colors.black,
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }

  void _handleClear() {
    setState(() {
      _padController.clear();
      isSignatureStarted = false;
    });
  }

  Future _handleSavePng() async {
    var result = await _padController.toPng();
    Navigator.of(context).push(
      new MaterialPageRoute(
        builder: (BuildContext context) {
          return new Scaffold(
            appBar: new AppBar(
              backgroundColor: Colors.grey[700],
            ),
            backgroundColor: Colors.grey[300],
            body: new Center(
              child: new Container(
                decoration: new BoxDecoration(
                  border: new Border.all(),
                  color: Colors.white,
                ),
                padding: new EdgeInsets.all(4.0),
                margin: new EdgeInsets.all(4.0),
                child: new Image.memory(result),
              ),
            ),
          );
        },
        fullscreenDialog: true,
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  signature_pad_widget: ^2.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support 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:signature_pad_widget/signature_pad_widget.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
75
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
88
Learn more about scoring.

We analyzed this package on Apr 7, 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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
flutter 0.0.0
stream_transform ^1.2.0 1.2.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
pedantic ^1.8.0+1