Using the Scaffold Widget for Material Apps in Flutter

Learn how to use the Scaffold widget in Flutter to provide a default banner, background color, and add drawers, snack bars, and bottom sheets.

When building a Material app in Flutter, you can use the Scaffold widget to provide a default banner, background color, and API for adding drawers, snack bars, and bottom sheets. You can then add a Center widget directly to the body property of the Scaffold widget for the home page.


Usage:

The Scaffold widget is commonly used as a top-level widget in Material apps to provide a consistent UI and functionality across screens. 

It can be customized with various properties to meet the needs of your app.


Code:

class MyApp extends StatelessWidget {
  const MyApp({Key? key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter layout demo',
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Flutter layout demo'),
        ),
        body: const Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}

..


Properties:

  • title: A string that represents the title of the Material app.
  • home: The main content for the home page of the app.
  • Scaffold: A widget that provides a default banner, background color, and API for adding drawers, snack bars, and bottom sheets.
  • appBar: The app bar to display at the top of the Scaffold widget.
  • body: The main content to display in the body of the Scaffold widget.
..
Flutter Basic,

Comments

Popular posts from this blog

Creating Beautiful Card UI in Flutter

Master Web Development with Web School Offline

Jetpack Compose - Card View