-
Notifications
You must be signed in to change notification settings - Fork 13
/
main.dart
79 lines (70 loc) · 2.01 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_help_scout/flutter_help_scout.dart';
void main() async {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Help Scout Example',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
// create an instance of Flutter Help Scout and pass the beacon ID and other values to it
FlutterHelpScout _beacon;
String beaconId = 'YOUR_BEACON_ID';
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initBeacon() async {
_beacon = FlutterHelpScout(
beaconId: beaconId,
email: 'example@example.com',
name: 'John Doe',
avatar: 'https://avatars3.githubusercontent.com/u/53996412?s=460&v=4');
// Platform messages may fail, so we use a try/catch PlatformException.
try {
_beacon.initialize();
} on PlatformException catch (e) {
debugPrint('${e.message}');
}
}
@override
void initState() {
// initialize beacon
initBeacon();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Help Scott Example'),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: RaisedButton(
child: Text(
'Open Beacon',
style: TextStyle(color: Colors.white),
),
color: Colors.blue,
onPressed: () {
_beacon.open(beaconId: beaconId);
},
)),
);
}
}