Badges :
Badges are the visible indicators they’re proven on the display screen stating the variety of unread notifications, objects added to cart and so forth primarily based on the app requirement.
On this tutorial we’ll see the detailed clarification on this matter and in addition undergo for the animations utilized in displaying the rely on to display screen.
Within the beneath tutorial you could find sensible instance of a badge implementation.
Â
essential.dart :
Detailed code for badges implementation.
Specify a badge in your challenge on this approach
badges.Badge(
)
Specify the badge content material
badgeContent: Textual content(“$rely”),
Animate utilizing
badgeAnimation: badges.BadgeAnimation.scale(),
s
import ‘bundle:flutter/materials.dart’;
import ‘bundle:badges/badges.dart’ as badges;
void essential(){
runApp(MyApp());
}
var rely = 0;
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : tremendous(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget construct(BuildContext context) {
return MaterialApp(
dwelling: Scaffold(
appBar: AppBar(
title: const Textual content(“badges”),
),
physique: Middle(
baby: Column(
mainAxisAlignment: MainAxisAlignment.middle,
youngsters: [
TextButton(onPressed: (){
setState(() {
count++;
});
}, child: const Text(“increment”)),
badges.Badge(
badgeAnimation: badges.BadgeAnimation.scale(),
badgeContent: Text(“$count”),
child: const Icon(Icons.shopping_cart,
size: 50,)
)
],
),
),
),
);
}
}
Â
Â