MaterialApp in Flutter

MaterialApp in Flutter

MaterialApp:

  • Apply the theme of application.
  • Material is a design system created by Google.
  • Flutter comes bundled with Material Design widgets which provides convenient components to use within the app that will work across Android, iOS, Flutter, and the web. Using MaterialApp() is a common way to build an app, and building without Material Design is not recommended!
  • Does a lot of ‘behind – the – scenes’ setup work for your app.

MaterialApp in Flutter properties :

1) navigatorKey:
2) scaffoldMessengerKey:
3) home: This property takes in widget as the object to show on the default route of the app.
4) routes: This property used to navigation screen.
5) initialRoute: This property takes in a string as the object to give the name of the first route in which the navigator is built.
6) onGenerateRoute: If you push the PassArguments route
7) onGenerateInitialRoutes: This property takes in InitialRouteListFactory typedef as the object to generate initial routes.
8) onUnknownRoute: : The onUnknownRoute takes in RouteFactory typedef as the object to provide a route in case of failure in other method.
9) navigatorObservers: It takes in GlobalKey as the object to generate a key when building a navigator.
10) builder:
11) title: The title property takes in a string as the object to decide the one-line description of the app for the device.
12) onGenerateTitle: This property takes in RouteFactory typedef as the object to generate a title string for the application if provided.
13) color: It controls the primary color used in the application.
14) theme: This property takes in ThemeData class as the object to describe the theme for the MaterialApp.
15) darkTheme: It provided theme data for the dark theme for the application.
16) highContrastTheme:
17) highContrastDarkTheme: It provided the theme data to use for the high contrast theme.
18) themeMode: This property holds ThemeMode enum as the object to decide the theme for the material app.
19) locale: It provides a locale for the MaterialApp.
20) localizationsDelegates: This provides a delegate for the locales.
21) localeListResolutionCallback:
22) localeResolutionCallback:
23) supportedLocales: The supportedLocales property keeps hold of the locals used in the app by taking in Iterable class as the object.
24) debugShowMaterialGrid: This property takes a boolean as the object. If set to true it paints a baseline grid material app.
25) showPerformanceOverlay:
26) checkerboardRasterCacheImages: This property takes in a boolean as the object. If set to true it turns on the checkerboarding of raster cache images.
27) checkerboardOffscreenLayers:
28) showSemanticsDebugger:
29) debugShowCheckedModeBanner: This property takes in a boolean as the object to decide whether to show the debug banner or not.
30) shortcuts:
31) actions: This property takes in Map> as the object. It controls intent keys.
32) restorationScopeId:

33) scrollBehavior:

important property:
theme:

  • This property is used to provide the default theme to the application like the theme-color of the application.
  • For this, we use the inbuilt class/widget named ThemeData(). In Themedata() widget we have to write the different properties related to the theme. Here we have used the primarySwatch which is used to define the default themecolor of the application. To choose the color we have used Colors class from the material library. In ThemeData() we can also define some other properties like TextTheme, Brightness(Can enable dark theme by this), AppBarTheme, and many more.

routes:

  • This is used navigation screen in flutter. Navigation in flutter 2 Type.
    1) named routes: String pass
    initialRoute: ‘/’, routes: {
    // When navigating to the “/” route, build the FirstScreen widget.
    ‘/’: (context) => FirstScreen(),
    // When navigating to the “/second” route, build the SecondScreen widget.
    ‘/second’: (context) => SecondScreen(),
    } Navigator.pushNamed(context, ‘/second’);

2) class name routes: Class name pass
Navigator.pushNamed(context, SecondScreen());

The flutter tutorial  is a website that bring you the latest and amazing resources of code. All the languages codes are included in this website. The languages like flutter, android, java,kotlin etc.with the help of this languages any user can develop the beautiful application

For more information about Flutter. visit www.fluttertutorial.in