actions property
final
Widgets to display after the title widget.
Typically these widgets are IconButtons representing common operations. For less common operations, consider using a PopupMenuButton as the last action.
This sample shows adding an action to an AppBar that opens a shopping cart.
Scaffold(
appBar: AppBar(
title: Text('Hello World'),
actions: <Widget>[
IconButton(
icon: Icon(Icons.shopping_cart),
tooltip: 'Open shopping cart',
onPressed: () {
// ...
},
),
],
),
)
To create a sample project with this code snippet, run:
flutter create --sample=material.AppBar.actions mysample
flutter create --sample=material.AppBar.actions mysample
// This sample shows adding an action to an [AppBar] that opens a shopping cart.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Code Sample for material.AppBar.actions',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyStatelessWidget(),
);
}
}
class MyStatelessWidget extends StatelessWidget {
MyStatelessWidget({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Hello World'),
actions: <Widget>[
IconButton(
icon: Icon(Icons.shopping_cart),
tooltip: 'Open shopping cart',
onPressed: () {
// ...
},
),
],
),
);
}
}
Implementation
final List<Widget> actions