A widget for entering gesture passwords for flutter.

Overview

GesturePasswordWidget GitHub stars GitHub forks

English | 简体中文

A gesture-unlocking widget for Flutter that supports a high degree of customization.

Use

dependencies:
  gesture_password_widget: latest-version
import 'package:gesture_password_widget/gesture_password_widget.dart';

Demo:

1)A simple and common demo.

Rendering:
image

Code:

GesturePasswordWidget(
      lineColor: const Color(0xff0C6BFE),
      errorLineColor: const Color(0xffFB2E4E),
      singleLineCount: 3,
      identifySize: 80.0,
      minLength: 4,
      errorItem: Image.asset(
        'images/error.png',
        color: const Color(0xffFB2E4E),
      ),
      normalItem: Image.asset('images/normal.png'),
      selectedItem: Image.asset(
        'images/selected.png',
        color: const Color(0xff0C6BFE),
      ),
      arrowItem: Image.asset(
        'images/arrow.png',
        width: 20.0,
        height: 20.0,
        color: const Color(0xff0C6BFE),
        fit: BoxFit.fill,
      ),
      errorArrowItem: Image.asset(
        'images/arrow.png',
        width: 20.0,
        height: 20.0,
        fit: BoxFit.fill,
        color: const Color(0xffFB2E4E),
      ),
      answer: [0, 1, 2, 4, 7],
      color: backgroundColor,
      onComplete: (data) {
        setState(() {
          result = data.join(', ');
        });
      },
    );

2)A complex demo. A line has four dots and supports the effect of the selection by set [hitItem].

Rendering:
image

Code:

GesturePasswordWidget(
      lineColor: Colors.white,
      errorLineColor: Colors.redAccent,
      singleLineCount: 4,
      identifySize: 80.0,
      minLength: 4,
      hitShowMilliseconds: 40,
      errorItem: Container(
        width: 10.0,
        height: 10.0,
        decoration: BoxDecoration(
          color: Colors.redAccent,
          borderRadius: BorderRadius.circular(50.0),
        ),
      ),
      normalItem: Container(
        width: 10.0,
        height: 10.0,
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(50.0),
        ),
      ),
      selectedItem: Container(
        width: 10.0,
        height: 10.0,
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(50.0),
        ),
      ),
      hitItem: Container(
        width: 15.0,
        height: 15.0,
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(50.0),
        ),
      ),
      answer: [0, 1, 2, 3, 6, 10, 14],
      color: backgroundColor,
      onComplete: (data) {
        setState(() {
          result = data.join(', ');
        });
      },
    )

Properties:

Property Description
size The width and height of GesturePasswordWidget.
identifySize The size of the area used to determine whether a point is selected, the larger the value of the more accurate identification.
normalItem Normal display of widget.
selectedItem The widget to display in the selected case.
errorItem The widget displayed in the error case will only work if minLength or answer is set.
(1) When minLength is not null, if the number of selected points is less than minLength, display errorItem, for example, minLength = 4 is set, but the result set of selected points is [0,1,3], a total of 3 points are selected, less than 4.
2) When answer is not null, the errorItem is displayed if the result set of the selected point and answer are not equal, e.g., answer = [0,1,2,4,7], but the result set of the selected point is [0,1,2,5,8], which is not equal to answer;
In addition, the display duration of the errorItem is controlled by completeWaitMilliseconds.
hitItem The widget to be displayed when this point is selected, its display duration is controlled by hitShowMilliseconds, continue to display selectedItem after reaching the display duration.
arrowItem Normal display of the arrow widget.
When following the gesture rotation, the x-axis is 0 degrees positive, so if you use arrows, make sure they are pointing in the x-axis positive direction.
errorArrowItem Arrow controls displayed in error conditions, if errorArrowItem is set, then arrowItem must be set, otherwise errorArrowItem will not be displayed.
When following the gesture rotation, the x-axis is 0 degrees positive, so if you use arrows, make sure they are pointing in the x-axis positive direction.
arrowXAlign The offset of arrowItem and errorArrowItem on the x-axis, with the origin in the center of normalItem.
When -1 < arrowXAlign < 1, arrowItem and errorArrowItem are drawn within the normalItem.
When arrowXAlign > 1 or arrowXAlign < -1, arrowItem and errorArrowItem are drawn outside the normalItem range.
arrowYAlign The arrowItem and errorArrowItem are offset on the y-axis, with the origin at the center of normalItem.
When -1 < arrowYAlign < 1, arrowItem and errorArrowItem are drawn within the normalItem.
The arrowItem draws outside the normalItem range when arrowYAlign > 1 or arrowYAlign < -1.
singleLineCount The total number of single lines is equal to singleLineCount * singleLineCount.
color The background color of GesturePasswordWidget,which defaults to Theme.of(context).scaffoldBackgroundColor.
onHitPoint The callback function when a point is selected.
onComplete The callback function at the end of a gesture slide.
lineColor The color of line in the normal case.
errorLineColor The color of line in the error casr, see [errorItem].
answer The right result,e.g., [0, 1, 2, 4, 7]
loose The default is true.
Consider this case: the points index=0 and index=6 are selected, and the point index=3 is not selected, but the point index=3 is on the line between index=0 and index=6. If loose=true, the gesture password obtained is [0,3,6] if loose=false, then the obtained gesture password is [0,6].
completeWaitMilliseconds The last selected point and the drawn line are displayed on the screen for the duration of the time, after which all points are cleared and the initial state is restored, and GesturePasswordWidget no longer accepts any gesture events until the time expires.
hitShowMilliseconds See hitItem.
minLength If this value is set, errorItem and errorLine are displayed if the length is short.
You might also like...

Widget to count the amount of nested widget tree, useful in the dynamic construction of the interface when it is important to know the depth of widget.

Widget to count the amount of nested widget tree, useful in the dynamic construction of the interface when it is important to know the depth of widget.

widget_tree_depth_counter Widget Tree Depth Counter WidgetTreeDepthCounter is a simple widget to count the amount of nested widget tree, useful in the

Aug 1, 2022

A simple detailed flutter widget that looks almost the same as the real instagram mention widget.

A simple detailed flutter widget that looks almost the same as the real instagram mention widget.

Instagram Mention Widgets 'small details do matter' ❤️ This package provides simple and almost the same UI details that the real Instagram mention wid

Oct 10, 2022

A customizable carousel slider widget in Flutter which supports inifinte scrolling, auto scrolling, custom child widget, custom animations and built-in indicators.

A customizable carousel slider widget in Flutter which supports inifinte scrolling, auto scrolling, custom child widget, custom animations and built-in indicators.

flutter_carousel_widget A customizable carousel slider widget in Flutter. Features Infinite Scroll Custom Child Widget Auto Play Horizontal and Vertic

Nov 26, 2022

A flutter widget which renders its child outside the original widget hierarchy.

 A flutter widget which renders its child outside the original widget hierarchy.

overlay_container A flutter widget which renders its child outside the original widget hierarchy. Demo. This demo is present as an example here. You c

Jun 10, 2022

Aris inheritedwidget - The Inherited Widget helps you to easily distribute your app state to every widget in your Flutter app

Aris inheritedwidget - The Inherited Widget helps you to easily distribute your app state to every widget in your Flutter app

Flutter Tutorial - Inherited Widget The InheritedWidget helps you to easily dist

Dec 29, 2021

FT-Custom-Widget - A Custom Widget Built With Flutter

FT-Custom-Widget - A Custom Widget Built With Flutter

Custom Widget Watch it on YouTube Product Screen Sample when you implement compl

Mar 29, 2022

A Flutter widget to show an icon collection to pick. This widget extend TextField and has a similar behavior as TextFormField

A Flutter widget to show an icon collection to pick. This widget extend TextField and has a similar behavior as TextFormField

icon_picker A Flutter widget to show an icon collection to pick. This widget extend TextField and has a similar behavior as TextFormField Usage In the

Sep 27, 2022

Flip widget - A Simple Flip widget For Flutter

Flip widget - A Simple Flip widget For Flutter

flip_widget Flip your widget. Usage FlipWidget( key: _flipKey, child: Co

Nov 13, 2022
Comments
  • selectedItem 位置不对

    selectedItem 位置不对

    我在安卓和web平台的测试都是如图的效果 GIF

    如果能将这里的 Stack 的参数 https://github.com/LuodiJackShen/GesturePasswordWidget/blob/f321b2ba96feb557c2981d3565a0940ac478e334/lib/widget/gesture_password_widget.dart#L405-L416 新增一行 alignment: AlignmentDirectional.center, 则可以修复

    opened by ltxhhz 4
  • 单击会出现BUG

    单击会出现BUG

    return GesturePasswordWidget( lineColor: Colors.white, errorLineColor: Colors.redAccent, singleLineCount: 3, identifySize: 80.0, minLength: 4, hitShowMilliseconds: 40, errorItem: Container( width: 10.0, height: 10.0, decoration: BoxDecoration( color: Colors.redAccent, borderRadius: BorderRadius.circular(50.0), ), ), normalItem: Container( width: 10.0, height: 10.0, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(50.0), ), ), selectedItem: Container( width: 10.0, height: 10.0, decoration: BoxDecoration( color: Colors.blue, borderRadius: BorderRadius.circular(50.0), ), ), hitItem: Container( width: 15.0, height: 15.0, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(50.0), ), ), answer: [0, 1, 2, 4, 7], color: Color(0xff252534), onComplete: (data) { print(data); }, ); } 现在就是用注释里的demo,可以试试多点击几个按钮,手指摁下后显示selectedItem,松手之后并没有还原为normalItem,并且点击多个会出现连线状态,而且手离开屏幕连线状态还是会保持,请复现bug时使用单击并且不要滑动

    opened by Godfather6666 2
  • 手势校验完成后如果直接关闭页面会闪退

    手势校验完成后如果直接关闭页面会闪退

    536行刷新操作是在延迟了[widget.completeWaitMilliseconds]之后进行操作的,但是在这之前会执行[widget.onComplete?.call(result)],如果业务上在onComplete中关闭页面就会报错,建议在刷新之前可以检查mounted情况,当然如果有其他可以解决该问题的手段也可以。

    opened by 528526221 1
Releases(v2.0.0)
Owner
老黑牛
老黑牛
Cupertino back gesture - Flutter package to set custom width of iOS back swipe gesture area

cupertino_back_gesture A Flutter package to set custom width of iOS back swipe gesture area. Usage To use this package, add cupertino_back_gesture as

null 28 Dec 7, 2022
A Dart widget for entering international telephone numbers with dropdown searching input countries

Dart Tel Input A Dart widget for entering international telephone numbers with dropdown searching input countries Getting Started Add the following li

աɨռɢӄաօռɢ 8 Oct 29, 2020
Sample Flutter app for creating basic login forms validation for email and passwords

Email validation Flutter example Sample flutter app showing how to validate a e-mail login form. This example uses the email_validator package for val

Fredrik Eilertsen 22 Dec 15, 2022
Generate passwords using different algorithms. https://kghandour.com/KGPassGen

KG Password Generator Generate passwords using on different algorithms. This project is based on SuperGenPass [ https://chriszarate.github.io/supergen

Karim ElGhandour 3 Nov 8, 2022
A widget that can be dragged and scrolled in a single gesture and snapped to a list of extents.

Sliding Sheet A widget that can be dragged and scrolled in a single gesture and snapped to a list of extents. Click here to view the full example. Ins

null 394 Mar 3, 2022
Easy to use, reliable and lightweight gesture detector for Flutter apps, exposing simple API for basic gestures

Simple Gesture Detector Easy to use, reliable and lightweight gesture detector for Flutter apps. Exposes simple API to react to basic gestures. Featur

Aleksander Woźniak 26 Nov 4, 2022
A Flutter package which provides 360 view of the images with rotation and gesture customisations.

imageview360 A Flutter package which provides 360 view of the images with rotation and gesture customisations. Supported Dart Versions Dart SDK versio

hd-motion 104 Dec 1, 2022
This Flutter plugin provides some widgets with gesture handlers.

Clickable Widget This Flutter plugin provides some flutter widgets having gesture handlers their don't natively have in Flutter. By default some flutt

Gael Vinou 7 Nov 17, 2022
Alarm app where user setting with touch gesture by moving the hand clock

Alarm App Using Flutter Flutter alarm app where user setting with touch gesture by moving the hand clock How to run Clone this repository Run flutter

null 3 Sep 3, 2022
A page transition which supports drag-down-to-pop gesture.

drag_down_to_pop A page transition which supports drag-down-to-pop gesture. The main source code is copied from the cupertino/route.dart in Flutter SD

nekocode 16 Aug 6, 2022