Junior
What is the role of the Scaffold widget in a Flutter application?
sobes.tech AI
Answer from AI
The Scaffold widget provides a basic Material Design structure for an app. It includes key UI components such as:
appBar: The top app bar.bottomNavigationBar: The bottom navigation bar.floatingActionButton: The main action button.drawer: The side menu that slides out from the left or right edge.body: The main content area of the screen.snackBar: A popup message about an event.
Example usage:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('My Scaffold App'),
),
body: Center(
child: Text('Hello, Scaffold!'),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
// Action on press
},
child: Icon(Icons.add),
),
),
);
}
}