Scaffold Widget Code
Complete Code For Scaffold Widget Code In Flutter
main.dart
import 'package:flutter/material.dart'; void main() => runApp(new MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData.light().copyWith(primaryColor: Colors.deepOrange), home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget { final String title; MyHomePage({this.title}); @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); @override Widget build(BuildContext context) { return Scaffold( key: _scaffoldKey, appBar: AppBar( backgroundColor: Colors.red, title: Text("Scaffold Widget")), drawer: Drawer(), bottomNavigationBar: BottomAppBar( color: Colors.red, child: Container(height: 50.0), ), floatingActionButton: FloatingActionButton( onPressed: () { _scaffoldKey.currentState.showSnackBar(SnackBar( content: Text("Snakbar displayed"), action: SnackBarAction( label: "Go Back", onPressed: () { if (Navigator.of(context).canPop()) { Navigator.of(context).pop(); } }, ), )); }, child: Icon(Icons.favorite,color: Colors.white,), ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, backgroundColor: Colors.red, ); } }