Skip to content

Commit 3c3e88a

Browse files
author
Md Shahed Uddin Emon
committed
fix: readme updated with new example
1 parent 67b5f24 commit 3c3e88a

File tree

1 file changed

+4
-30
lines changed

1 file changed

+4
-30
lines changed

README.md

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ import 'dart:io';
3131
import 'package:chatwoot_sdk/chatwoot_sdk.dart';
3232
import 'package:flutter/material.dart';
3333
import 'package:flutter/services.dart';
34-
import 'package:image/image.dart' as image;
35-
import 'package:image_picker/image_picker.dart' as image_picker;
36-
import 'package:path_provider/path_provider.dart';
3734
3835
void main() {
3936
runApp(MyApp());
@@ -54,7 +51,7 @@ class MyApp extends StatelessWidget {
5451
}
5552
5653
class MyHomePage extends StatefulWidget {
57-
MyHomePage({Key key, this.title}) : super(key: key);
54+
MyHomePage({Key? key, required this.title}) : super(key: key);
5855
5956
final String title;
6057
@@ -75,23 +72,21 @@ class _MyHomePageState extends State<MyHomePage> {
7572
title: Text("Chatwoot Example"),
7673
),
7774
body: ChatwootWidget(
78-
websiteToken: "websiteToken",
75+
websiteToken: "YOUR_TOKEN",
7976
baseUrl: "https://app.chatwoot.com",
8077
user: ChatwootUser(
8178
identifier: "[email protected]",
8279
name: "Tester test",
8380
8481
),
85-
locale: "fr",
82+
locale: "en",
8683
closeWidget: () {
8784
if (Platform.isAndroid) {
8885
SystemNavigator.pop();
89-
} else if (Platform.isIOS) {
86+
} else {
9087
exit(0);
9188
}
9289
},
93-
//attachment only works on android for now
94-
onAttachFile: _androidFilePicker,
9590
onLoadStarted: () {
9691
print("loading widget");
9792
},
@@ -105,28 +100,7 @@ class _MyHomePageState extends State<MyHomePage> {
105100
);
106101
}
107102
108-
Future<List<String>> _androidFilePicker() async {
109-
final picker = image_picker.ImagePicker();
110-
final photo =
111-
await picker.pickImage(source: image_picker.ImageSource.gallery);
112103
113-
if (photo == null) {
114-
return [];
115-
}
116-
117-
final imageData = await photo.readAsBytes();
118-
final decodedImage = image.decodeImage(imageData);
119-
final scaledImage = image.copyResize(decodedImage, width: 500);
120-
final jpg = image.encodeJpg(scaledImage, quality: 90);
121-
122-
final filePath = (await getTemporaryDirectory()).uri.resolve(
123-
'./image_${DateTime.now().microsecondsSinceEpoch}.jpg',
124-
);
125-
final file = await File.fromUri(filePath).create(recursive: true);
126-
await file.writeAsBytes(jpg, flush: true);
127-
128-
return [file.uri.toString()];
129-
}
130104
}
131105
```
132106

0 commit comments

Comments
 (0)