@@ -28,6 +28,22 @@ If no composer is added (by specifying the composer as null), the action button
28
28
{% tabs %}
29
29
{% highlight dart %}
30
30
31
+ final List<AssistMessage > _ messages = <AssistMessage >[ ] ;
32
+
33
+ @override
34
+ Widget build(BuildContext context) {
35
+ return Scaffold(
36
+ body: SfAIAssistView(
37
+ messages: _ messages,
38
+ actionButton: AssistActionButton(
39
+ onPressed: (String data) {
40
+ // Handle the send button click action here.
41
+ },
42
+ ),
43
+ ),
44
+ );
45
+ }
46
+
31
47
{% endhighlight %}
32
48
{% endtabs %}
33
49
@@ -38,6 +54,23 @@ The [child] property allows you to define a custom widget consisting of one or m
38
54
{% tabs %}
39
55
{% highlight dart %}
40
56
57
+ final List<AssistMessage > _ messages = <AssistMessage >[ ] ;
58
+
59
+ @override
60
+ Widget build(BuildContext context) {
61
+ return Scaffold(
62
+ body: SfAIAssistView(
63
+ messages: _ messages,
64
+ actionButton: AssistActionButton(
65
+ child: const Icon(Icons.chat),
66
+ onPressed: (String data) {
67
+ // Handle the send button click action here.
68
+ },
69
+ ),
70
+ ),
71
+ );
72
+ }
73
+
41
74
{% endhighlight %}
42
75
{% endtabs %}
43
76
@@ -48,6 +81,38 @@ It is a callback that is invoked whenever the action button is pressed. Since th
48
81
{% tabs %}
49
82
{% highlight dart %}
50
83
84
+ final List<AssistMessage > _ messages = <AssistMessage >[ ] ;
85
+
86
+ void _ generativeResponse(String data) async {
87
+ final String response = await _ getAIResponse(data);
88
+ setState(() {
89
+ _ messages.add(AssistMessage.response(data: response));
90
+ });
91
+ }
92
+
93
+ Future<String > _ getAIResponse(String data) async {
94
+ String response = '';
95
+ // Connect with your preferred AI to generate a response to the request.
96
+ return response;
97
+ }
98
+
99
+ @override
100
+ Widget build(BuildContext context) {
101
+ return Scaffold(
102
+ body: SfAIAssistView(
103
+ messages: _ messages,
104
+ actionButton: AssistActionButton(
105
+ onPressed: (String data) {
106
+ setState(() {
107
+ _ messages.add(AssistMessage.request(data: data));
108
+ _ generativeResponse(data);
109
+ });
110
+ },
111
+ ),
112
+ ),
113
+ );
114
+ }
115
+
51
116
{% endhighlight %}
52
117
{% endtabs %}
53
118
@@ -58,6 +123,23 @@ The [`tooltip`] text describes the button's action when pressed. It is displayed
58
123
{% tabs %}
59
124
{% highlight dart %}
60
125
126
+ final List<AssistMessage > _ messages = <AssistMessage >[ ] ;
127
+
128
+ @override
129
+ Widget build(BuildContext context) {
130
+ return Scaffold(
131
+ body: SfAIAssistView(
132
+ messages: _ messages,
133
+ actionButton: AssistActionButton(
134
+ tooltip: 'Send Message',
135
+ onPressed: (String data) {
136
+ // Handle the send button click action here.
137
+ },
138
+ ),
139
+ ),
140
+ );
141
+ }
142
+
61
143
{% endhighlight %}
62
144
{% endtabs %}
63
145
@@ -76,6 +158,27 @@ The [`splashColor`] property is the splash color of the button's InkWell. The de
76
158
{% tabs %}
77
159
{% highlight dart %}
78
160
161
+ final List<AssistMessage > _ messages = <AssistMessage >[ ] ;
162
+
163
+ @override
164
+ Widget build(BuildContext context) {
165
+ return Scaffold(
166
+ body: SfAIAssistView(
167
+ messages: _ messages,
168
+ actionButton: AssistActionButton(
169
+ foregroundColor: Colors.white,
170
+ backgroundColor: Colors.blue,
171
+ focusColor: Colors.lightBlueAccent,
172
+ hoverColor: Colors.blueAccent,
173
+ splashColor: Colors.white.withOpacity(0.3),
174
+ onPressed: (String data) {
175
+ // Handle the send button click action here.
176
+ },
177
+ ),
178
+ ),
179
+ );
180
+ }
181
+
79
182
{% endhighlight %}
80
183
{% endtabs %}
81
184
@@ -92,6 +195,26 @@ The [`highlightElevation`] property determines the elevation when the button is
92
195
{% tabs %}
93
196
{% highlight dart %}
94
197
198
+ final List<AssistMessage > _ messages = <AssistMessage >[ ] ;
199
+
200
+ @override
201
+ Widget build(BuildContext context) {
202
+ return Scaffold(
203
+ body: SfAIAssistView(
204
+ messages: _ messages,
205
+ actionButton: AssistActionButton(
206
+ elevation: 2.0,
207
+ focusElevation: 6.0,
208
+ hoverElevation: 4.0,
209
+ highlightElevation: 8.0,
210
+ onPressed: (String data) {
211
+ // Handle the send button click action here.
212
+ },
213
+ ),
214
+ ),
215
+ );
216
+ }
217
+
95
218
{% endhighlight %}
96
219
{% endtabs %}
97
220
@@ -102,6 +225,23 @@ The [`mouseCursor`] property defines the type of cursor that appears when hoveri
102
225
{% tabs %}
103
226
{% highlight dart %}
104
227
228
+ final List<AssistMessage > _ messages = <AssistMessage >[ ] ;
229
+
230
+ @override
231
+ Widget build(BuildContext context) {
232
+ return Scaffold(
233
+ body: SfAIAssistView(
234
+ messages: _ messages,
235
+ actionButton: AssistActionButton(
236
+ mouseCursor: SystemMouseCursors.forbidden,
237
+ onPressed: (String data) {
238
+ // Handle the send button click action here.
239
+ },
240
+ ),
241
+ ),
242
+ );
243
+ }
244
+
105
245
{% endhighlight %}
106
246
{% endtabs %}
107
247
@@ -112,6 +252,30 @@ The [`shape`] property sets the shape of the button's border, such as rounded or
112
252
{% tabs %}
113
253
{% highlight dart %}
114
254
255
+ final List<AssistMessage > _ messages = <AssistMessage >[ ] ;
256
+
257
+ @override
258
+ Widget build(BuildContext context) {
259
+ return Scaffold(
260
+ body: SfAIAssistView(
261
+ messages: _ messages,
262
+ actionButton: AssistActionButton(
263
+ shape: const ContinuousRectangleBorder(
264
+ borderRadius: BorderRadius.only(
265
+ topLeft: Radius.circular(30.0),
266
+ topRight: Radius.circular(15),
267
+ bottomRight: Radius.circular(30.0),
268
+ bottomLeft: Radius.circular(15)
269
+ ),
270
+ ),
271
+ onPressed: (String data) {
272
+ // Handle the send button click action here.
273
+ },
274
+ ),
275
+ ),
276
+ );
277
+ }
278
+
115
279
{% endhighlight %}
116
280
{% endtabs %}
117
281
@@ -122,6 +286,23 @@ The [`padding`] property defines the space inside the button between its border
122
286
{% tabs %}
123
287
{% highlight dart %}
124
288
289
+ final List<AssistMessage > _ messages = <AssistMessage >[ ] ;
290
+
291
+ @override
292
+ Widget build(BuildContext context) {
293
+ return Scaffold(
294
+ body: SfAIAssistView(
295
+ messages: _ messages,
296
+ actionButton: AssistActionButton(
297
+ padding: const EdgeInsetsDirectional.only(start: 8.0),
298
+ onPressed: (String data) {
299
+ // Handle the send button click action here.
300
+ },
301
+ ),
302
+ ),
303
+ );
304
+ }
305
+
125
306
{% endhighlight %}
126
307
{% endtabs %}
127
308
@@ -132,6 +313,23 @@ The [`size`] property specifies the width and height of the button. By default,
132
313
{% tabs %}
133
314
{% highlight dart %}
134
315
316
+ final List<AssistMessage > _ messages = <AssistMessage >[ ] ;
317
+
318
+ @override
319
+ Widget build(BuildContext context) {
320
+ return Scaffold(
321
+ body: SfAIAssistView(
322
+ messages: _ messages,
323
+ actionButton: AssistActionButton(
324
+ size: const Size.square(40.0),
325
+ onPressed: (String data) {
326
+ // Handle the send button click action here.
327
+ },
328
+ ),
329
+ ),
330
+ );
331
+ }
332
+
135
333
{% endhighlight %}
136
334
{% endtabs %}
137
335
0 commit comments