Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
1f42579
Merge branch 'master' of https://github.com/syncfusion-content/Flutte…
DeepakRajSundar May 18, 2022
256ca28
Merge pull request #1171 from Syncfusion-Content/hotfix/hotfix-v29.1.33
SyncfusionBuild Mar 27, 2025
79140d5
Merge pull request #1175 from Syncfusion-Content/hotfix/hotfix-v29.1.33
SyncfusionBuild Mar 28, 2025
81d1adc
Added the release notes MD file and corresponding node entry in the T…
Mar 31, 2025
bb92d2e
Merge pull request #1176 from Syncfusion-Content/hotfix/hotfix-v29.1.33
SyncfusionBuild Mar 31, 2025
ef3df6b
FLUT-947290-[others]: Added RTL for chat and assist view and updated …
Mugunthan-Ramalingam Apr 1, 2025
bbae814
FLUT-947290-[others]: updated removed content
Mugunthan-Ramalingam Apr 1, 2025
50d2a1a
FLUT-947290-[others]: added RTL missed
Mugunthan-Ramalingam Apr 1, 2025
aae1d6d
Merge remote-tracking branch 'origin/master'
DeepakRajSundar Apr 2, 2025
c0a2bc1
removed the excess entry in flutter-toc.html
DeepakRajSundar Apr 2, 2025
a93fef1
FLUT-947290-[others]: removed RTL content
Mugunthan-Ramalingam Apr 2, 2025
2616ba8
FLUT-947290-[others]: updated review changes
Mugunthan-Ramalingam Apr 2, 2025
fd80796
FLUT-947290-[others]: removed unwanted changes
Mugunthan-Ramalingam Apr 2, 2025
c4d8bf4
FLUT-947290-[others]: removed unwanted changes
Mugunthan-Ramalingam Apr 2, 2025
d10e499
FLUT-947290-[others]: added RTL docs for chat and assist view
Mugunthan-Ramalingam Apr 2, 2025
4c84803
Merge pull request #1177 from syncfusion-content/FLUT-947290-Flutter-…
Apr 2, 2025
f032d2b
Merge pull request #1179 from Syncfusion-Content/hotfix/hotfix-v29.1.33
SyncfusionBuild Apr 2, 2025
0167c1f
FLUT-947290-[others]: updated UG changes
Mugunthan-Ramalingam Apr 3, 2025
a0d995a
Update placeholder.md
Apr 3, 2025
35239fa
Update flutter-toc.html
Apr 3, 2025
534748d
Merge pull request #1181 from syncfusion-content/FLUT-947290-UG-chagn…
Apr 3, 2025
446f3c0
Merge pull request #1183 from Syncfusion-Content/hotfix/hotfix-v29.1.33
SyncfusionBuild Apr 3, 2025
c234de1
FLUT-947290-[others]: updated code snippet for rtl docs
Mugunthan-Ramalingam Apr 3, 2025
a50e20d
Merge branch 'hotfix/hotfix-v29.1.33' of https://github.com/syncfusio…
Mugunthan-Ramalingam Apr 3, 2025
acb052f
FLUT-947290-[others]: updated missed and improper highlight property …
Mugunthan-Ramalingam Apr 4, 2025
4ea01c6
FLUT-949859-[others]: added how to section for chat and assistview wi…
Mugunthan-Ramalingam Apr 4, 2025
b48cf02
Merge pull request #1185 from syncfusion-content/FLUT-947290-highligh…
Apr 7, 2025
db36dce
Merge pull request #1188 from Syncfusion-Content/hotfix/hotfix-v29.1.33
SyncfusionBuild Apr 7, 2025
1d9cf3c
Added the release notes MD file and corresponding node entry in the T…
Apr 7, 2025
0663ede
FLUT-947290-[others]: updated review changes
Mugunthan-Ramalingam Apr 8, 2025
a4b224c
FLUT-947290-[others]: updated images
Mugunthan-Ramalingam Apr 8, 2025
a1013aa
FLUT-949859-[others]: updated images
Mugunthan-Ramalingam Apr 8, 2025
b66e082
Merge pull request #1178 from syncfusion-content/FLUT-947290-RTL-docs…
Apr 8, 2025
1509d08
Merge branch 'hotfix/hotfix-v29.1.33' into FLUT-949859-chat-assistvie…
Apr 8, 2025
954ced5
Merge pull request #1187 from syncfusion-content/FLUT-949859-chat-ass…
Apr 8, 2025
01f34d7
Merge remote-tracking branch 'remotes/origin/hotfix/hotfix-v29.1.33'
DeepakRajSundar Apr 8, 2025
5fe673b
FLUT-949859-[others]: updated issue in UG documentation
Mugunthan-Ramalingam Apr 10, 2025
749ac90
Merge pull request #1191 from syncfusion-content/FLUT-949859-Flutter-…
Apr 10, 2025
524bb4f
Merge pull request #1192 from Syncfusion-Content/hotfix/hotfix-v29.1.33
SyncfusionBuild Apr 10, 2025
dae7bba
Added the release notes MD file and corresponding node entry in the T…
Apr 14, 2025
b42b48b
Merge remote-tracking branch 'remotes/origin/hotfix/hotfix-v29.1.33'
DeepakRajSundar Apr 14, 2025
ab155ab
Removed the unwanted extra node from flutter-toc.html
DeepakRajSundar Apr 15, 2025
dc00e72
Merge remote-tracking branch 'remotes/origin/hotfix/hotfix-v29.1.33'
DeepakRajSundar Apr 15, 2025
7c88121
Added the release notes MD file and corresponding node entry in the T…
Apr 21, 2025
6af2389
Merge pull request #1194 from Syncfusion-Content/hotfix/hotfix-v29.1.33
SyncfusionBuild Apr 21, 2025
f965d4f
v29.1.33 UG images updated
KalaiyarasuR Apr 25, 2025
c04d8a4
Merge pull request #1195 from syncfusion-content/HF_29
Apr 25, 2025
5708aa0
FLUT-953870-[feature]: Removed mac os app center link
Hariram-SF4428 Apr 25, 2025
9b5d03f
Merge pull request #1198 from Syncfusion-Content/hotfix/hotfix-v29.1.33
SyncfusionBuild Apr 25, 2025
24a8b80
Added the release notes MD file and corresponding node entry in the T…
Apr 28, 2025
f5242e1
Merge pull request #1200 from Syncfusion-Content/hotfix/hotfix-v29.1.33
SyncfusionBuild Apr 28, 2025
dd45de9
Merge pull request #1197 from syncfusion-content/FLUT-953870-Remove-a…
Apr 29, 2025
7986092
Merge pull request #1201 from Syncfusion-Content/hotfix/hotfix-v29.1.33
SyncfusionBuild Apr 29, 2025
202cf77
IN-200360 Added the release notes MD file for v29.1.40 and correspond…
DeepakRajSundar Apr 30, 2025
3f6bb83
Merge remote-tracking branch 'remotes/origin/hotfix/hotfix-v29.1.33'
DeepakRajSundar Apr 30, 2025
a955fce
Added the release notes MD file and corresponding node entry in the T…
DeepakRajSundar May 5, 2025
021e8f3
Merge pull request #1202 from Syncfusion-Content/hotfix/hotfix-v29.1.33
SyncfusionBuild May 5, 2025
243b0c8
FLUT-956813-[others][flutter]: Resolved the conflicts.
BPraveenBalu May 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
294 changes: 161 additions & 133 deletions Flutter/ai-assistview/right-to-left.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
---
layout: post
title: Placeholder in Flutter Chat widget | Syncfusion
description: Learn here about the Right to Left(RTL) support in Syncfusion Flutter Chat (SfChat) widget and more.
title: Placeholder in Flutter AIAssistView widget | Syncfusion
description: Learn here about the RTL support in Syncfusion Flutter AIAssistView (SfAIAssistView) widget and more.
platform: flutter
control: SfChat
control: SfAIAssistView
documentation: ug
---


# Right To Left (RTL) in Flutter Chat (SfChat)
# Right To Left (RTL) in Flutter AIAssistView (SfAIAssistView)


Chat supports the right to left rendering for all the elements in the Chat widget.
AIAssistView supports the right to left rendering for all the elements in the AIAssistView widget.

## RTL rendering ways

Right to left rendering can be switched in the following ways:

### Wrapping the SfChat with Directionality widget
### Wrapping the SfAIAssistView with Directionality widget

To change the rendering direction from right to left, you can wrap the [`SfChat`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/SfChat-class.html) widget inside the [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget and set the [`textDirection`](https://api.flutter.dev/flutter/widgets/Directionality/textDirection.html) property as [`TextDirection.rtl`](https://api.flutter.dev/flutter/dart-ui/TextDirection.html).
To change the rendering direction from right to left, you can wrap the [`SfAIAssistView`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/assist_view/SfAIAssistView-class.html) widget inside the [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget and set the [`textDirection`](https://api.flutter.dev/flutter/widgets/Directionality/textDirection.html) property as [`TextDirection.rtl`](https://api.flutter.dev/flutter/dart-ui/TextDirection.html).

{% tabs %}
{% highlight dart hl_lines="5" %}
Expand All @@ -29,7 +29,7 @@ To change the rendering direction from right to left, you can wrap the [`SfChat`
return Scaffold(
body: Directionality(
textDirection: TextDirection.rtl,
child: SfChat(
child: SfAIAssistView(
//...
),
),
Expand All @@ -40,51 +40,73 @@ To change the rendering direction from right to left, you can wrap the [`SfChat`
{% endtabs %}


## RTL supported chat elements
## RTL supported AIAssistView elements

### Placeholder

Right to left (RTL) rendering is supported for the [`placeholderBuilder`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/SfChat/placeholderBuilder.html) in the chat. The widget added in the placeholderBuilder will be rendered from right to left direction. But, the text widget or text entered in the widget will render from left to right direction.
Right to left (RTL) rendering is supported for the [`placeholderBuilder`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/assist_view/SfAIAssistView/placeholderBuilder.html) in the AIAssistView. The widget added in the placeholderBuilder will be rendered from right to left direction. But, the text widget or text entered in the widget will render from left to right direction.

{% tabs %}
{% highlight dart hl_lines="5 9" %}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Directionality(
textDirection: TextDirection.rtl,
child: SfChat(
outgoingUser: '1010',
messages: _messages,
placeholderBuilder: (context) {
return const Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(width: 10),
Icon(
size: 30,
Icons.emoji_people_rounded,
color: Colors.red,
),
SizedBox(width: 5),
Text(
'Start a conversation',
style: TextStyle(
color: Colors.deepPurple,
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
],
),
);
},
),
),
);
}
{% highlight dart hl_lines="5 10" %}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Directionality(
textDirection: TextDirection.rtl,
child: Padding(
padding: const EdgeInsets.all(20.0),
child: SfAIAssistView(
messages: _messages,
placeholderBuilder: (context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
'Ask AI Anything',
style: TextStyle(
color: Colors.deepPurple,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
OutlinedButton(
onPressed: () {},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Text('Music'),
SizedBox(width: 5),
Icon(Icons.music_note)
],
),
),
const SizedBox(width: 5),
OutlinedButton(
onPressed: () {},
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Text('Movies'),
SizedBox(width: 5),
Icon(Icons.movie_creation_rounded)
],
),
),
],
),
],
);
},
),
),
),
);
}

{% endhighlight %}
{% endtabs %}
Expand All @@ -94,27 +116,27 @@ Right to left (RTL) rendering is supported for the [`placeholderBuilder`](https:

### Composer

Right to left (RTL) rendering is supported for the [`composer`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/SfChat/composer.html) in the chat. Composer will be rendered from right to left direction. But, the text entered in the composer will render from the left to right in the composer.
Right to left (RTL) rendering is supported for the [`composer`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/assist_view/SfAIAssistView/composer.html) in the AIAssistView. Composer will be rendered from right to left direction. But, the text entered in the composer will render from the left to right in the composer.

{% tabs %}
{% highlight dart hl_lines="5 9" %}
{% highlight dart hl_lines="5 8" %}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Directionality(
textDirection: TextDirection.rtl,
child: SfChat(
outgoingUser: '1010',
messages: _messages,
composer: const ChatComposer(
@override
Widget build(BuildContext context) {
return Scaffold(
body: Directionality(
textDirection: TextDirection.rtl,
child: SfAIAssistView(
messages: _messages,
composer: const AssistComposer(
decoration: InputDecoration(
hintText: 'Enter Message here',
)),
hintText: 'Ask AI anything',
),
),
),
),
),
);
}
);
}

{% endhighlight %}
{% endtabs %}
Expand All @@ -125,91 +147,97 @@ Right to left (RTL) rendering is supported for the [`composer`](https://pub.dev/

### Action Button

Right to left (RTL) rendering is supported for the [`actionButton`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/SfChat/actionButton.html) in the chat. Action button will be rendered from right to left direction.
Right to left (RTL) rendering is supported for the [`actionButton`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/assist_view/SfAIAssistView/actionButton.html) in the AIAssistView. Action button will be rendered from right to left direction.

{% tabs %}
{% highlight dart hl_lines="5 9" %}
{% highlight dart hl_lines="5 8" %}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Directionality(
textDirection: TextDirection.rtl,
child: SfChat(
outgoingUser: '1010',
messages: _messages,
actionButton: ChatActionButton(
onPressed: (value) {
setState(() {
_messages.add(
ChatMessage(
text: value,
time: DateTime.now(),
author: const ChatAuthor(
id: '1010', name: 'Johnathan wick'),
),
);
});
},
@override
Widget build(BuildContext context) {
return Scaffold(
body: Directionality(
textDirection: TextDirection.rtl,
child: SfAIAssistView(
messages: _messages,
actionButton: AssistActionButton(
onPressed: (String value) {
// Handle the send button click action here.
},
),
),
),
),
);
}
);
}

{% endhighlight %}
{% endtabs %}

![Action Button RTL](images/rtl/action_button_rtl.gif)


### Message Content
### Conversation Area

Right to left (RTL) rendering is supported for [`Messages`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/ChatMessage-class.html) in the chat conversation area. In RTL mode, message content, header and suggestions will render the widget in right to left direction.
Right to left (RTL) rendering is supported for both [`request`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/assist_view/AssistMessage/AssistMessage.request.html) and [`response`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/assist_view/AssistMessage/AssistMessage.response.html) [`Messages`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/assist_view/SfAIAssistView/messages.html) in the AIAssistView conversation area. In RTL mode, request and response message, header and suggestions will render the widget in right to left direction.

{% tabs %}
{% highlight dart hl_lines="5 8" %}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Directionality(
textDirection: TextDirection.rtl,
child: SfChat(
outgoingUser: '1010',
messages: <ChatMessage>[
ChatMessage(
text: 'Hey, Any plans for today?',
time: DateTime.parse('2025-03-21T10:02:00Z'),
author: const ChatAuthor(
id: '1010',
name: 'Johnathan wick',
avatar: AssetImage('assets/images/People_Circle23.png'),
),
),
ChatMessage(
text:
"I'm thinking of watching a web series. Can you suggest some?",
time: DateTime.parse('2025-03-21T10:03:00Z'),
author: const ChatAuthor(
id: '1020',
name: 'John carter',
avatar: AssetImage('assets/images/People_Circle5.png'),
),
suggestions: [
const ChatMessageSuggestion(data: 'Peaky Blinders'),
const ChatMessageSuggestion(data: 'Breaking Bad'),
const ChatMessageSuggestion(data: 'Prison Break'),
const ChatMessageSuggestion(data: 'Blacklist'),
],
),
],
),
),
);
}
{% highlight dart %}

final List<AssistMessage> _messages = <AssistMessage>[];

void _generativeResponse(String data) async {
final String response = await _getAIResponse(data);
setState(() {
_messages.add(
AssistMessage.response(
data: response,
time: DateTime.now(),
suggestions: [
const AssistMessageSuggestion(data: 'Provier'),
const AssistMessageSuggestion(data: 'Riverpoad'),
const AssistMessageSuggestion(data: 'Bloc'),
const AssistMessageSuggestion(data: 'GetX'),
],
),
);
});
}

Future<String> _getAIResponse(String data) async {
String response = '';
// Connect with your preferred AI to generate a response to the request.
return response;
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Directionality(
textDirection: TextDirection.rtl,
child: SfAIAssistView(
messages: _messages,
actionButton: AssistActionButton(
onPressed: (String data) {
if (data.trim().isNotEmpty) {
setState(() {
_messages.add(
AssistMessage.request(
data: data,
time: DateTime.now(),
author: const AssistMessageAuthor(
id: 'User ID', name: 'User name'),
),
);
_generativeResponse(data);
});
}
},
),
),
),
);
}

{% endhighlight %}
{% endtabs %}

![Message Content RTL](images/rtl/message_content_rtl.png)
![Message Content RTL](images/rtl/conversation_area_rtl.gif)
Loading