From 61cbcaa228d21d8cd54b084b9187ee9333df9565 Mon Sep 17 00:00:00 2001 From: Rohan Kandwal Date: Fri, 13 Aug 2021 18:41:50 +0530 Subject: [PATCH] WebView updated & Null Safety added --- lib/src/tawk_visitor.dart | 6 +++--- lib/src/tawk_widget.dart | 20 +++++++++---------- pubspec.lock | 42 +++++++++++++++++++-------------------- pubspec.yaml | 10 +++++----- 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/lib/src/tawk_visitor.dart b/lib/src/tawk_visitor.dart index 6042ffb..7110bdf 100644 --- a/lib/src/tawk_visitor.dart +++ b/lib/src/tawk_visitor.dart @@ -1,13 +1,13 @@ /// Use [TawkVisitor] to set the visitor name and email. class TawkVisitor { /// Visitor's name. - final String name; + final String? name; /// Visitor's email. - final String email; + final String? email; /// [Secure mode](https://developer.tawk.to/jsapi/#SecureMode). - final String hash; + final String? hash; TawkVisitor({ this.name, diff --git a/lib/src/tawk_widget.dart b/lib/src/tawk_widget.dart index 4ab7f4b..ceb91c3 100644 --- a/lib/src/tawk_widget.dart +++ b/lib/src/tawk_widget.dart @@ -9,19 +9,19 @@ import 'tawk_visitor.dart'; /// [Tawk] Widget. class Tawk extends StatefulWidget { /// Tawk direct chat link. - final String directChatLink; + final String? directChatLink; /// Object used to set the visitor name and email. - final TawkVisitor visitor; + final TawkVisitor? visitor; /// Called right after the widget is rendered. - final Function() onLoad; + final Function()? onLoad; /// Called when a link pressed. - final Function(String url) onLinkTap; + final Function(String url)? onLinkTap; /// Render your own loading widget. - final Widget placeholder; + final Widget? placeholder; Tawk({ @required this.directChatLink, @@ -36,7 +36,7 @@ class Tawk extends StatefulWidget { } class _TawkState extends State { - WebViewController _controller; + WebViewController? _controller; bool _isLoading = true; void _setUser(TawkVisitor visitor) { @@ -57,7 +57,7 @@ class _TawkState extends State { '''; } - _controller.evaluateJavascript(javascriptString); + _controller!.evaluateJavascript(javascriptString); } @override @@ -79,18 +79,18 @@ class _TawkState extends State { } if (widget.onLinkTap != null) { - widget.onLinkTap(request.url); + widget.onLinkTap!(request.url); } return NavigationDecision.prevent; }, onPageFinished: (_) { if (widget.visitor != null) { - _setUser(widget.visitor); + _setUser(widget.visitor!); } if (widget.onLoad != null) { - widget.onLoad(); + widget.onLoad!(); } setState(() { diff --git a/pubspec.lock b/pubspec.lock index 038f0e9..0e92c11 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,49 +7,49 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.15.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -66,21 +66,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -92,63 +92,63 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" webview_flutter: dependency: "direct main" description: name: webview_flutter url: "https://pub.dartlang.org" source: hosted - version: "1.0.7" + version: "2.0.2" sdks: - dart: ">=2.10.0-110 <2.11.0" - flutter: ">=1.22.0 <2.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.22.0" diff --git a/pubspec.yaml b/pubspec.yaml index 3c590a7..ff560a8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,17 +1,17 @@ name: flutter_tawk description: Tawk widget for Flutter. -version: 0.0.5 -homepage: https://github.com/ayoubamine/flutter_tawk +version: 0.0.5+1 +homepage: https://github.com/teewhydope/flutter_tawk environment: - sdk: '>=2.7.0 <3.0.0' - flutter: '>=1.17.0 <2.0.0' + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: sdk: flutter - webview_flutter: ^1.0.7 + webview_flutter: + dev_dependencies: flutter_test: