How to Solve No Directionality Widget Found In Flutter??

3 min read
How to Solve No Directionality Widget Found In Flutter
How to Solve No Directionality Widget Found In Flutter

Sometimes when a user creates a layout in flutter sometimes he/she starts getting an error that states about the No Directionality Widget Found in a flutter. So in this article, we will learn about the same.

Are you ready for the same ??

How to Solve No Directionality Widget Found In Flutter??

flutter doesn’t know whether the text is LTR or RTL, so you need to tell the textDirection explicitly like this as shown below:

new Text("Hello", textDirection: TextDirection.ltr)

or you can just wrap the Text with a Directionality Widget as shown below:

new Directionality(
          textDirection: TextDirection.ltr,
          child: new Text('Hello')

and the purpose of that is :

” A widget that determines the ambient directionality of text and text-direction-sensitive render objects ”

And a Text Widget in the scope of a MaterialApp Widget does not need to be given an explicit writing direction. It is because the default localization in the widgets and material libraries is LTR

So if you don’t use MaterialApp you need to wrap your app into some widgets.

import 'dart:ui' as ui;
    new MediaQuery(
        data: new MediaQueryData.fromWindow(ui.window),
        child: new Directionality(
            textDirection: TextDirection.rtl,
            child: new MyHome())))

You get this error if you’re not using MaterialApp Widget or WidgetsApp at the root level of your tree hierarchy.

So the solution looks like this:

void main() {
    MaterialApp(home: MyHome()), // use MaterialApp

class MyHome extends StatelessWidget {
  Widget build(BuildContext context) {
    return Scaffold( // use Scaffold also in order to provide material app widgets
      body: Center(child: Text("Something")),


Thanks for being with us on a Flutter Journey !!! Hope you enjoyed it !!!

So today, We learned how to Solve No Directionality Widget Found In Flutter.

Keep Learning !!! Keep Fluttering !!! Stay Connected !!!

Do let us know if you have any doubts regarding Flutter Development in the comments right below!! we are here to assist you 馃檪

Flutter Agency聽is our portal Platform dedicated to Flutter Technology and聽Flutter Developers. The portal is full of cool resources from Flutter like聽Flutter Widget聽Guide,聽Flutter Projects,聽Code libs聽and etc.

Flutter Agency is one of the most popular online portals dedicated to聽Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge of聽Flutter.

Leave a Reply