In this tutorial, we're going to add AppBar with your flutter application.where app bar contains menu icons, title, action buttons, change the background color of AppBar.
Checkout Flutter Tutorials for more articles on flutter
Let's start by creating new project or you can also choose exiting project
flutter create appbar
cd appbar
once we created a new project, we can start working with lib/main.dart
file
Flutter AppBar Example
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget{
Widget build(BuildContext context) {
return MaterialApp(home: Scaffold(
appBar: AppBar(
title: Text("CODESUNDAR"),
leading: Icon(Icons.menu),
backgroundColor: Colors.redAccent,
actions: <Widget>[
IconButton(icon: Icon(Icons.videocam), onPressed: () => { }),
IconButton(icon: Icon(Icons.account_circle), onPressed: () => { })
]
)
));
}
}
Explanation: We have created a stateless widget (because, we're not going to handle any data at this moment).
Final output for flutter AppBar
Hope this tutorial helps you.