help_scout_flutter 0.0.2
help_scout_flutter: ^0.0.2 copied to clipboard
A new Flutter plugin for the implementation of HelpScout Beacon.
import 'package:flutter/material.dart';
import 'package:help_scout_flutter/help_scout_flutter.dart';
import 'package:help_scout_flutter/model.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late final HelpScoutFlutter _helpScoutFlutterPlugin;
void initBeacon() {
// Initialize with beacon ID and user info
final user = HSBeaconUser(
email: 'john@example.com',
name: 'John Doe',
company: 'Example Corp',
jobTitle: 'Developer',
avatar: 'https://example.com/avatar.png',
);
_helpScoutFlutterPlugin = HelpScoutFlutter(
beaconId: '*******beacon-id******',
user: user,
);
}
@override
void initState() {
initBeacon();
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Help Scout Example App')),
body: Center(
child: ElevatedButton(
onPressed: () async {
// Initialize and open the beacon
final initResult = await _helpScoutFlutterPlugin.initialize();
debugPrint('Initialize result: $initResult');
final openResult = await _helpScoutFlutterPlugin.open();
debugPrint('Open result: $openResult');
},
style: ButtonStyle(
backgroundColor: WidgetStateProperty.resolveWith(
(states) => Colors.blue[700]!,
),
),
child: const Text('HelpScout Button'),
),
),
),
);
}
}