We removed everything from the default flutter class, and created a custom one. But we kept the default file material.dart.
Scaffold class could be understood like as a skeleton for building simple apps quickly. It comes with some default objects and classes which you can use them easily.
We used the Scaffold class, since it provides body section
First example
import 'package:flutter/material.dart';
void main(){
runnApp(MaterialApp(home:Scaffold(
body:Center(
child:Text("I love Flutter"),
)
)));
}
You also have to know that, Scaffold is used with MaterialApp, and it provides different functionalities like AppBar for your app bar, BottomNavigationBar for app bottom navigation.
Within the Scaffold tag we used body tag to put things in the body section.
Flutter Scaffold provides ready made API and widgets to use for your app. In general Scaffold takes the whole screen.
Scaffold gives us the ability to create an app which runs every smoothlessly. This widget covers the following building blocks of an app
- AppBar
- Body
- Drawer for side menu
- Floating Action Bar
- Bottom Navigation Bar
- Persistent Footer Buttons
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(home:Scaffold(
appBar: AppBar(
title:Text("App Bar"),
),
body:Center(
child:Text("I love Flutter"),
)
)));
}
In the above code, we added AppBar, which helps us build a bar on the top of the screen. It’s this simple with Scaffold since, it comes out of the box.