Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/src/tawk_visitor.dart
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
20 changes: 10 additions & 10 deletions lib/src/tawk_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -36,7 +36,7 @@ class Tawk extends StatefulWidget {
}

class _TawkState extends State<Tawk> {
WebViewController _controller;
WebViewController? _controller;
bool _isLoading = true;

void _setUser(TawkVisitor visitor) {
Expand All @@ -57,7 +57,7 @@ class _TawkState extends State<Tawk> {
''';
}

_controller.evaluateJavascript(javascriptString);
_controller!.evaluateJavascript(javascriptString);
}

@override
Expand All @@ -79,18 +79,18 @@ class _TawkState extends State<Tawk> {
}

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(() {
Expand Down
42 changes: 21 additions & 21 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"
10 changes: 5 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down