Skip to content

Commit 4ca6acc

Browse files
Merge pull request #1043 from Syncfusion-Content/development
DOCINFRA-2341_merged_using_automation
2 parents b262df9 + bdc627a commit 4ca6acc

File tree

8 files changed

+1169
-11
lines changed

8 files changed

+1169
-11
lines changed

Flutter/assistview/action-button.md

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ If no composer is added (by specifying the composer as null), the action button
2828
{% tabs %}
2929
{% highlight dart %}
3030

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+
3147
{% endhighlight %}
3248
{% endtabs %}
3349

@@ -38,6 +54,23 @@ The [child] property allows you to define a custom widget consisting of one or m
3854
{% tabs %}
3955
{% highlight dart %}
4056

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+
4174
{% endhighlight %}
4275
{% endtabs %}
4376

@@ -48,6 +81,38 @@ It is a callback that is invoked whenever the action button is pressed. Since th
4881
{% tabs %}
4982
{% highlight dart %}
5083

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+
51116
{% endhighlight %}
52117
{% endtabs %}
53118

@@ -58,6 +123,23 @@ The [`tooltip`] text describes the button's action when pressed. It is displayed
58123
{% tabs %}
59124
{% highlight dart %}
60125

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+
61143
{% endhighlight %}
62144
{% endtabs %}
63145

@@ -76,6 +158,27 @@ The [`splashColor`] property is the splash color of the button's InkWell. The de
76158
{% tabs %}
77159
{% highlight dart %}
78160

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+
79182
{% endhighlight %}
80183
{% endtabs %}
81184

@@ -92,6 +195,26 @@ The [`highlightElevation`] property determines the elevation when the button is
92195
{% tabs %}
93196
{% highlight dart %}
94197

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+
95218
{% endhighlight %}
96219
{% endtabs %}
97220

@@ -102,6 +225,23 @@ The [`mouseCursor`] property defines the type of cursor that appears when hoveri
102225
{% tabs %}
103226
{% highlight dart %}
104227

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+
105245
{% endhighlight %}
106246
{% endtabs %}
107247

@@ -112,6 +252,30 @@ The [`shape`] property sets the shape of the button's border, such as rounded or
112252
{% tabs %}
113253
{% highlight dart %}
114254

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+
115279
{% endhighlight %}
116280
{% endtabs %}
117281

@@ -122,6 +286,23 @@ The [`padding`] property defines the space inside the button between its border
122286
{% tabs %}
123287
{% highlight dart %}
124288

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+
125306
{% endhighlight %}
126307
{% endtabs %}
127308

@@ -132,6 +313,23 @@ The [`size`] property specifies the width and height of the button. By default,
132313
{% tabs %}
133314
{% highlight dart %}
134315

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+
135333
{% endhighlight %}
136334
{% endtabs %}
137335

0 commit comments

Comments
 (0)