I have the following codes in my login page:
@override
Widget build(BuildContext context) {
return Scaffold(
body: Directionality(
textDirection: TextDirection.rtl,
child: . . .
.
.
.
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => AlertDialog(
title: const Text('خطا'),
content: Text('جهت تست'),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text("تایید"))
],
),
);
}
When I run the code, everything is in RTL mode but the dialog is in LTR mode. How can I make it RTL?
>Solution :
wrap the widget returned in the showDialog with a Directionality:
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => Directionality(textDirection: /* your text direction*/, child: AlertDialog(
title: const Text('خطا'),
content: Text('جهت تست'),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text("تایید"))
],
),
),);
With changing /* your text direction*/ with your desired direction.