main.dart
import 'package:flutter/material.dart';
void main() => runApp(const FlutterExample());
class FlutterExample extends StatelessWidget {
const FlutterExample({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Example',
theme: ThemeData(primarySwatch: Colors.blue),
home: const StateExample()
);
}
}
class StateExample extends StatefulWidget {
const StateExample({Key? key}) : super(key: key);
@override
_StateExampleState createState() => _StateExampleState();
}
class _StateExampleState extends State<StateExample> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
appBar: AppBar(
title: const Text("Flutter - ActionChip Example")
),
body: bodyContent()
);
}
bodyContent(){
return Center(
child: ActionChip(
avatar: CircleAvatar(
backgroundColor: Colors.pink[100],
child: const Icon(
Icons.delete,
color: Colors.red,
),
),
label: const Text("Delete Now"),
onPressed: (){
SnackBar snackBar = const SnackBar(
content: Text("You requested to delete"
));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
},
),
);
}
}
More flutter tutorials
- flutter – PageView builder
- flutter – AlertDialog example
- flutter – AlertDialog scrollable
- flutter – AlertDialog shape
- flutter – Animated align
- flutter – Align example
- flutter – ActionChip size
- flutter – Chip example
- flutter – Container circle border
- flutter – Container gradient border
- flutter – Transparent status bar
- flutter – How to show hide status bar
- flutter – AppBar center title
- flutter – How to change AppBar color
- flutter – MaterialApp theme