From 210e9d98f13af976270900bd6522a5333de09c29 Mon Sep 17 00:00:00 2001 From: chonghorizons <36284839+chonghorizons@users.noreply.github.com> Date: Tue, 24 Dec 2019 18:03:39 -0800 Subject: [PATCH] Update README.md Needed the MyWidget example for snap with key to be stateful widget. It was giving an error that `currentState` was not a method of key. The docs for GlobalKey(https://api.flutter.dev/flutter/widgets/GlobalKey-class.html) says it only extends stateful widgets, i.e. ``` GlobalKey> class ``` Also, small typo of CamelCase on `snapOnTap` --- example/README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/example/README.md b/example/README.md index cc82456..6a75f4e 100644 --- a/example/README.md +++ b/example/README.md @@ -21,8 +21,14 @@ Widget build(BuildContext context) { #### Snap with a Key ```dart -class MyWidget extends StatelessWidget { +class MyWidget extends StatefulWidget { + @override + _MyWidgetState createState() => _MyWidgetState(); +} + +class _MyWidgetState extends State { final key = GlobalKey(); + @override Widget build(BuildContext context) { return Snappable( @@ -44,7 +50,7 @@ class MyWidget extends StatelessWidget { @override Widget build(BuildContext context) { return Snappable( - snapOntap: true, + snapOnTap: true, child: Text('This whill be snapped'), ); }