Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the difference between WidgetsApp class, MaterialApp class and Directionality class

Can anyone please tell me what are the differences between WidgetsApp class, MaterialApp class and Directionality class?. Can I say WidgetsApp is inherited from Directionality? because both of them I can use them for layout non material apps.

like image 777
Alooosh Alsoumahi Avatar asked Jul 17 '19 23:07

Alooosh Alsoumahi


2 Answers

MaterialApp builds upon a WidgetsApp by adding material-design specific functionality.

As stated in the official Flutter documentation:

MaterialApp:

A convenience widget that wraps a number of widgets that are commonly required for material design applications.

It builds upon a WidgetsApp by adding material-design specific functionality, such as AnimatedTheme and GridPaper.

WidgetsApp:

A convenience class that wraps a number of widgets that are commonly required for an application.

One of the primary roles that WidgetsApp provides is binding the system back button to popping the Navigator or quitting the application.

like image 107
Lior Avatar answered Nov 15 '22 05:11

Lior


WidgetsApp class is actually the base class for MaterialApp class and the CupertionApp class. Whereas Directionality is actually a class which provides the default direction for the text in sub-tree in the app. MaterialApp contains WidgetsApp class and Directionality class (so there is always a default direction for Text widget ), and custom transitions, and many other modifications/additions as per material specification in your app (Which is probably the error which brought you to asking this question). Hope this helps.

like image 36
Dapu Avatar answered Nov 15 '22 06:11

Dapu