appbar flutterr code example
Example 1: flutter appbar widget
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('AppBar Title', textAlign: TextAlign.center),
),
Example 2: flutter create custom appbar
import 'package:flutter/material.dart';
class CustomAppBar extends StatelessWidget with PreferredSizeWidget {
final String _title;
@override
final Size preferredSize;
CustomAppBar(this._title, { Key key}) : preferredSize = Size.fromHeight(50.0),
super(key: key);
@override
Widget build(BuildContext context) {
return AppBar(
title: Text('$_title'),
centerTitle: true,
backgroundColor: Colors.black54,
);
}
}
import 'package:flutter/material.dart';
import 'package:photo_app/components/appBar.dart';
class Albums extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: CustomAppBar('Your title here'),
);
}
}