What is the difference between the GetMaterialApp of GetX and the MaterialApp of Flutter?
I come from C++ where we inherit from a parent and then extend on it, but here according to the documentation:
Note: this does not modify the MaterialApp of the Flutter, GetMaterialApp is not a modified MaterialApp, it is just a pre-configured Widget, which has the default MaterialApp as a child. You can configure this manually, but it is definitely not necessary. GetMaterialApp will create routes, inject them, inject translations, and inject everything you need for route navigation. If you use Get only for state management or dependency management, it is not necessary to use GetMaterialApp. GetMaterialApp is necessary for routes, snack bars, internationalization, bottom sheets, dialogs, and high-level APIs related to routes and the absence of context.
This seems as if GetMaterialApp internally calls functions of MaterialApp and provides the user's syntactic sugar to avoid the difficult syntax of MaterialApp(?)
Is my understanding correct?
But then this quote doesn't seem to be talking about inheritance(?).
this does not modify the MaterialApp of the Flutter, GetMaterialApp is not a modified MaterialApp, it is just a pre-configured Widget, which has the default MaterialApp as a child.
The GetMaterialApp
in the Getx package can be understood as this:
MaterialApp + Getx properties = GetMaterialApp
If you go through the source code of GetMaterialApp
, what you will find is just a class with properties the same as MaterialApp's
, and those properties are just linked to the original MaterialApp
, plus the custom-made properties that belong only to Getx
, so the result ( GetMaterialApp
) is literally MaterialApp
plus Getx
properties ( which by the way like the pages, initialBinding... ).
and this sentence :
this does not modify the MaterialApp of the Flutter,
GetMaterialApp
is not a modifiedMaterialApp
, it is just a pre-configured Widget, which has the default MaterialApp as a child.
Is true, it literally inherits the MaterialApp
So the properties written in GetMaterialApp
get the same functions, and abilities..., from the original MaterialApp
in addition to custom-built properties.
Hope this gives you a better approach to it.
You can take a look over the source code, and you will get a better understanding of what actually the Getx
does under the hood.