actions
MaterialApp({ title,theme, home: Scaffold({ appBar: AppBar({ title, backgroundColor, brightness. automaticallyImplyLeading, leading, actions, bottom,...}), body,}), })
açıklama
appBar sağında tıklanabilir widgetler grubu oluşturur. IconButtons, PopupMenuButton gibi…
konum
MaterialApp({ title,theme, home: Scaffold({ appBar: AppBar({ title, backgroundColor, brightness. automaticallyImplyLeading, leading, actions, bottom,...}), body,}), })
parametreler
appBar: AppBar({
title: Text()
backgroundColor: Colors.red // appbar arkaplan rengini değiştitr
brightness: Brightness.dark // appbar karanlık mı parlak mı olacak.
automaticallyImplyLeading: true , // leading in otomatik oluşturulmasını konrol eder. false ise oluşturulmaz varsayaılanı true dir.
leading: Builder(builder: (BuildContext context) {
return IconButton(
icon: const Icon(Icons.menu),
onPressed: () { Scaffold.of(context).openDrawer(); },
tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip,
);
},
),
//leading ataması yapılmamıssa flutter otomatik olarak oluşturur ve draver ile sekronize açalışır. safya gecisinde ise geri dugmesi olarak yerini alır.
//false verilirse appar içinde geri widget gizlenir.
//manuel ataması widget oluşturucu olan Builder(builder: ) ile yapılır. sayfadaki draver ile senkronize çalışması için sayafa context ine ihtiyac duyar.
actions: [ IconButton( icon: Icon(Icons.playlist_play), tooltip: 'Buton tipi', onPressed: _fonksiyonadi, ),
IconButton( icon: Icon(Icons.playlist_add), tooltip: 'Buton tipi', onPressed: _fonksiyonadi, ),
IconButton( icon: Icon(Icons.playlist_add_check), tooltip: 'Buton tipi', onPressed: _fonksiyonadi, ),
],
// appBar sağında tıklanabilir widgetler grubu oluşturur. IconButtons, PopupMenuButton gibi...
bottom: TabBar(
controller: TabController({ initialIndex: 0, @required int length, @required TickerProvider vsync }) yada
DefaultTabController({ @required length, initialIndex: 0, @required Widget child})
tabs: [
Tab(icon: Icon(Icons.directions_car)),
Tab(icon: Icon(Icons.directions_transit)),
Tab(icon: Icon(Icons.directions_bike)),
],
),
})
örnek uygulama

import 'package:flutter/material.dart';
class AppBarSample extends StatefulWidget {
@override
_AppBarSampleState createState() => _AppBarSampleState();
}
class _AppBarSampleState extends State<AppBarSample>
with SingleTickerProviderStateMixin {
TabController _tabController;
@override
void initState() {
super.initState();
_tabController = TabController(vsync: this, length: choices.length);
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
void _nextPage(int delta) {
final int newIndex = _tabController.index + delta;
if (newIndex < 0 || newIndex >= _tabController.length) return;
_tabController.animateTo(newIndex);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Android Monks'),
leading: IconButton(
tooltip: 'Previous choice',
icon: const Icon(Icons.arrow_back),
onPressed: () {
_nextPage(-1);
},
),
actions: [
IconButton(
icon: const Icon(Icons.arrow_forward),
tooltip: 'Next choice',
onPressed: () {
_nextPage(1);
},
),
],
bottom: PreferredSize(
preferredSize: const Size.fromHeight(48.0),
child: Theme(
data: Theme.of(context).copyWith(accentColor: Colors.white),
child: Container(
height: 48.0,
alignment: Alignment.center,
child: TabPageSelector(controller: _tabController),
),
),
),
),
body: TabBarView(
controller: _tabController,
children: choices.map((Choice choice) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: ChoiceCard(choice: choice),
);
}).toList(),
),
),
);
}
}
class Choice {
const Choice({this.title, this.icon});
final String title;
final IconData icon;
}
const List choices = const [
const Choice(title: 'CAR', icon: Icons.directions_car),
const Choice(title: 'BICYCLE', icon: Icons.directions_bike),
const Choice(title: 'BOAT', icon: Icons.directions_boat),
const Choice(title: 'BUS', icon: Icons.directions_bus),
const Choice(title: 'TRAIN', icon: Icons.directions_railway),
const Choice(title: 'WALK', icon: Icons.directions_walk),
];
class ChoiceCard extends StatelessWidget {
const ChoiceCard({Key key, this.choice}) : super(key: key);
final Choice choice;
@override
Widget build(BuildContext context) {
final TextStyle textStyle = Theme.of(context).textTheme.display1;
return Card(
color: Colors.white,
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(choice.icon, size: 128.0, color: textStyle.color),
Text(choice.title, style: textStyle),
],
),
),
);
}
}
void main() {
runApp(AppBarSample());
}