Today we are going to create a circle icon using flutter.
For this example we will crate a state less widget in flutter.
import 'package:flutter/material.dart'; class CircleIcon extends StatelessWidget { finalIconDataicon; finaldoubleiconSize; finalVoidCallbackonPressed; constCircleIcon({ Key? key, requiredthis.icon, this.iconSize = 25.0, requiredthis.onPressed, }) : super(key: key); @override Widgetbuild(BuildContextcontext) { return Container( margin: constEdgeInsets.all(8.0), decoration: BoxDecoration( color: Colors.grey[200], shape: BoxShape.circle ), child: IconButton( onPressed: onPressed, icon: Icon(icon), color: Colors.black, iconSize: iconSize, ), ); //container } }
Here in this widget iconSize is optional and icon and event is required. We can use this widget like below
import ‘../widgets/circle_icon.dart’;
CircleIcon( icon: Icons.person_outline, onPressed: () { }, ),