chatwoot_flutter 2.0.0-dev.2 copy "chatwoot_flutter: ^2.0.0-dev.2" to clipboard
chatwoot_flutter: ^2.0.0-dev.2 copied to clipboard

An unofficial flutter client sdk for chatwoot. Integrate Chatwoot into your flutter app.

example/lib/main.dart

// import 'dart:io';

// import 'package:chatwoot_flutter/chatwoot_flutter.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter/services.dart';
// import 'package:image/image.dart' as image;
// import 'package:image_picker/image_picker.dart' as image_picker;
// import 'package:path_provider/path_provider.dart';

// void main() {
//   runApp(MyApp());
// }

// class MyApp extends StatelessWidget {
//   // This widget is the root of your application.
//   @override
//   Widget build(BuildContext context) {
//     return MaterialApp(
//       title: 'Flutter Demo',
//       theme: ThemeData(
//         primarySwatch: Colors.blue,
//       ),
//       home: MyHomePage(title: 'Flutter Demo Home Page'),
//     );
//   }
// }

// class MyHomePage extends StatefulWidget {
//   MyHomePage({Key key, this.title}) : super(key: key);

//   final String title;

//   @override
//   _MyHomePageState createState() => _MyHomePageState();
// }

// class _MyHomePageState extends State<MyHomePage> {
//   @override
//   void initState() {
//     super.initState();
//   }

//   @override
//   Widget build(BuildContext context) {
//     return Scaffold(
//       appBar: AppBar(
//         title: Text("Chatwoot Example"),
//       ),
//       body: ChatwootWidget(
//         websiteToken: "websiteToken",
//         baseUrl: "https://app.chatwoot.com",
//         user: ChatwootUser(
//           identifier: "test@test.com",
//           name: "Tester test",
//           email: "test@test.com",
//         ),
//         locale: "en",
//         closeWidget: () {
//           if (Platform.isAndroid) {
//             SystemNavigator.pop();
//           } else if (Platform.isIOS) {
//             exit(0);
//           }
//         },
//         //attachment only works on android for now
//         onAttachFile: _androidFilePicker,
//         onLoadStarted: () {
//           print("loading widget");
//         },
//         onLoadProgress: (int progress) {
//           print("loading... ${progress}");
//         },
//         onLoadCompleted: () {
//           print("widget loaded");
//         },
//       ),
//     );
//   }

//   Future<List<String>> _androidFilePicker() async {
//     final picker = image_picker.ImagePicker();
//     final photo =
//         await picker.pickImage(source: image_picker.ImageSource.gallery);

//     if (photo == null) {
//       return [];
//     }

//     final imageData = await photo.readAsBytes();
//     final decodedImage = image.decodeImage(imageData);
//     final scaledImage = image.copyResize(decodedImage, width: 500);
//     final jpg = image.encodeJpg(scaledImage, quality: 90);

//     final filePath = (await getTemporaryDirectory()).uri.resolve(
//           './image_${DateTime.now().microsecondsSinceEpoch}.jpg',
//         );
//     final file = await File.fromUri(filePath).create(recursive: true);
//     await file.writeAsBytes(jpg, flush: true);

//     return [file.uri.toString()];
//   }
// }