Google News
logo
Flutter - Interview Questions
What is a Flutter scaffold and how is it used?
In Flutter, a `Scaffold` is a basic visual structure for a screen or page in an application. It provides a framework for implementing the basic visual elements of an app, such as the app bar, drawer, bottom navigation bar, and floating action button.

The `Scaffold` widget is typically used as the top-level widget of a screen in a Flutter app. You can create a `Scaffold` widget by instantiating the `Scaffold` class, which is provided by the Flutter framework. Here's an example of how you might create a `Scaffold` widget:
import 'package:flutter/material.dart';

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('My App'),
      ),
      body: Center(
        child: Text('Hello, world!'),
      ),
    );
  }
}​
In this example, we create a basic `Scaffold` widget that contains an app bar with a title and a body that consists of a `Text` widget that displays the text "Hello, world!" in the center of the screen.

The `Scaffold` widget provides a number of additional properties that you can use to customize the appearance and behavior of the app bar, drawer, bottom navigation bar, and floating action button, as well as other elements of the screen. These properties include `drawer`, `bottomNavigationBar`, `floatingActionButton`, `floatingActionButtonLocation`, and many more.
Advertisement