What is MaterialApp class in Flutter

Posted by

MaterialApp Class: In a flutter, MaterialApp is a preconfigured class or widget. It is probably a flutter app’s primary or central component. A wrapper for other Material Widgets is offered by the MaterialApp widget. We have access to every other widget and component that the Flutter SDK offers. The types of widgets that may be accessible using the MaterialApp class are Text, DropdownButton, AppBar, Scaffold, ListView, Stateless, Stateful, IconButton, TextField, Padding, ThemeData, and some others. The MaterialApp class is used to access a large number of additional widgets. We may create a visually appealing application that adheres to Material Design principles by using this widget.

Constructor of MaterialApp class

Properties of MaterialApp widget:

  • action: Map> is the object that this property accepts. It manages the intent keys.
  • backButtonDispatcher: It made decisions on the use of the back button.
  • The object for the checkerboardRasterCacheImage property is a boolean. When set to true, raster cache image checkerboarding is enabled.
  • colour: It regulates the application’s main colour.
  • darkTheme: It supplied theme information for the application’s dark theme.
  • debugShowCheckedModeBanner: This property determines whether or not to display the debug banner by accepting a boolean as its argument.
  • debugShowMaterialGird: The object for this attribute is a boolean. It paints a baseline grid material app if set to true.
  • highContrastDarkTheme: The theme data for the high contrast theme was supplied by it.
  • house: This asset requires
  • initialRoute: The name of the first route the navigator is constructed on is provided by this property, which accepts a string as its input.
  • locale: It gives the MaterialApp a locale. localisationsDelegate: This gives the locales a delegate.
  • navigatorObserver: When creating a navigation, it receives GlobalKey as the object to produce a key for.
  • navigatorObserver: List is the object that this property contains when creating a list of observers for the navigator.
  • onGenerateInitialRoutes: The object to be generated by this property is InitialRouteListFactory typedef.
  • onGeneratRoute: This method accepts a RouteFactory as its input. When the app is directed to a designated path, it is utilised.
  • onUnknownRoute: In the event that another method fails, the onUnknownRoute method uses the RouteFactory typedef as its input to generate a route.
  • routeInformationParse: The object to the routeing information from the routeInformationProvider into a generic data type is held by this property, which is called RouteInformationParser.
  • routeInformationProvider: The object entered into this property is the RouteInformationProvider class. It is in charge of giving out routeing details.
  • routeDelegate: To configure a specific widget, this property accepts an object called RouterDelegate.
  • routes: The LogicalKeySet class is the object that the routes property uses to control the app’s top-level routeing.
  • shortcuts: The LogicalKeySet class is the object that this property uses to determine the keyboard shortcut for the application.
  • showPerformanceOverlay: To switch performance on or off, the showPerformanceOverlay object accepts a boolean value.
  • showSemantisDebugger: The parameter for this attribute is a boolean. It displays some easily accessible information when set to true.
  • supportedLocales: Taking an Iterable class as its object, the supportedLocales property holds onto the locals utilised in the application.
  • theme: The object used to describe the MaterialApp’s theme is the ThemeData class, which is sent into this field.
  • themeMode: This property contains the ThemeMode enum, which is used to select the Material App’s theme.
  • title: To determine the one-line description of the application for the device, the title property accepts a string as its input.

Simple Material App Example:

Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x