|
4 | 4 |
|
5 | 5 | ## Getting Started
|
6 | 6 |
|
7 |
| -For help getting started with Flutter, view our on |
| 7 | +For help getting started with Flutter, view our online [documentation](https://flutter.io/). |
| 8 | + |
| 9 | +For help on editing package code, view the [documentation](https://flutter.io/developing-packages/). |
| 10 | + |
| 11 | + |
| 12 | +## How to use ? |
| 13 | + |
| 14 | +1. Depend on it |
| 15 | + |
| 16 | +```yaml |
| 17 | +dependencies: |
| 18 | + gesture_password: "^0.0.4" |
| 19 | +``` |
| 20 | +
|
| 21 | +2. Install it |
| 22 | + |
| 23 | +```sh |
| 24 | +$ flutter packages get |
| 25 | +``` |
| 26 | + |
| 27 | +3. Import it |
| 28 | + |
| 29 | +```dart |
| 30 | +import 'package:gesture_password/gesture_password.dart'; |
| 31 | +import 'package:gesture_password/mini_gesture_password.dart'; |
| 32 | +``` |
| 33 | + |
| 34 | +## 属性 |
| 35 | +* width 控件宽度(xia-weiyang想法) |
| 36 | +* selectedColor 选中的颜色 |
| 37 | +* normalColor: 没选中的颜色 |
| 38 | +* lineStrokeWidth: 线宽 |
| 39 | +* circleStrokeWidth: 选中外圈圆宽 |
| 40 | +* smallCircleR: 小圆半径 |
| 41 | +* bigCircleR: 大圆半径 |
| 42 | +* focusDistance: 选中差值 越大越容易选中 |
| 43 | +* successCallback 选择4个以上松手回调,返回值为选中的index相加的字符串 |
| 44 | +* failCallback 选择4下以上松手回调 |
| 45 | +* selectedCallback 经过任意一个后回调,返回值为选中的index相加的字符串 |
| 46 | + |
| 47 | +## Example |
| 48 | +``` |
| 49 | +import 'package:flutter/material.dart'; |
| 50 | +import 'package:gesture_password/gesture_password.dart'; |
| 51 | +import 'package:gesture_password/mini_gesture_password.dart'; |
| 52 | +
|
| 53 | +void main() => runApp(new MyApp()); |
| 54 | +
|
| 55 | +class MyApp extends StatelessWidget { |
| 56 | + @override |
| 57 | + Widget build(BuildContext context) { |
| 58 | + return new MaterialApp( |
| 59 | + title: 'Flutter Demo', |
| 60 | + theme: new ThemeData( |
| 61 | + primarySwatch: Colors.blue, |
| 62 | + ), |
| 63 | + home: new MyHomePage(title: 'Flutter Demo Home Page'), |
| 64 | + ); |
| 65 | + } |
| 66 | +} |
| 67 | +
|
| 68 | +class MyHomePage extends StatefulWidget { |
| 69 | + MyHomePage({Key key, this.title}) : super(key: key); |
| 70 | +
|
| 71 | + final String title; |
| 72 | +
|
| 73 | + @override |
| 74 | + _MyHomePageState createState() => new _MyHomePageState(); |
| 75 | +} |
| 76 | +
|
| 77 | +class _MyHomePageState extends State<MyHomePage> { |
| 78 | + GlobalKey<MiniGesturePasswordState> miniGesturePassword = |
| 79 | + new GlobalKey<MiniGesturePasswordState>(); |
| 80 | +
|
| 81 | + GlobalKey<ScaffoldState> scaffoldState = new GlobalKey<ScaffoldState>(); |
| 82 | +
|
| 83 | + @override |
| 84 | + Widget build(BuildContext context) { |
| 85 | + return new MaterialApp( |
| 86 | + home: new Scaffold( |
| 87 | + key: scaffoldState, |
| 88 | + appBar: new AppBar( |
| 89 | + title: new Text('Plugin example app'), |
| 90 | + ), |
| 91 | + body: new Column( |
| 92 | + children: <Widget>[ |
| 93 | + new Center( |
| 94 | + child: new MiniGesturePassword(key: miniGesturePassword)), |
| 95 | + new LayoutBuilder( |
| 96 | + builder: (BuildContext context, BoxConstraints constraints) { |
| 97 | + return new Container( |
| 98 | + color: Colors.red, |
| 99 | + margin: const EdgeInsets.only(top: 100.0), |
| 100 | + child: new GesturePassword( |
| 101 | + successCallback: (s) { |
| 102 | + print("successCallback$s"); |
| 103 | + scaffoldState.currentState?.showSnackBar(new SnackBar( |
| 104 | + content: new Text('successCallback:$s'))); |
| 105 | + miniGesturePassword.currentState?.setSelected(''); |
| 106 | + }, |
| 107 | + failCallback: () { |
| 108 | + print('failCallback'); |
| 109 | + scaffoldState.currentState?.showSnackBar( |
| 110 | + new SnackBar(content: new Text('failCallback'))); |
| 111 | + miniGesturePassword.currentState?.setSelected(''); |
| 112 | + }, |
| 113 | + selectedCallback: (str) { |
| 114 | + miniGesturePassword.currentState?.setSelected(str); |
| 115 | + }, |
| 116 | + ), |
| 117 | + ); |
| 118 | + }, |
| 119 | + ), |
| 120 | + ], |
| 121 | + ), |
| 122 | + ), |
| 123 | + ); |
| 124 | + } |
| 125 | +} |
| 126 | +``` |
| 127 | + |
| 128 | +##### 有需求的话,后期再加入其他的吧 |
0 commit comments