creating custom witdget

 import 'package:flutter/cupertino.dart';

import 'package:flutter/material.dart';

class RoundedButton extends StatelessWidget {
final String btnName;
final Icon? icon;
final Color? bgColor;
final TextStyle? textStyle;
final VoidCallback? callback;

var callBack;

RoundedButton({
required this.btnName,
this.icon,
this.textStyle,
this.bgColor = Colors.blue,
dynamic callBack, this.callback,
});

@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () {
callback!();
},
child: icon != null
? Row(
children: [icon!,
Container(width: 11,),
Text(btnName, style: textStyle)],
)
: Text(
btnName,
style: textStyle,
),
style: ElevatedButton.styleFrom(
backgroundColor: bgColor,
shadowColor: bgColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(21),

))),
);
}
}

Comments

Popular posts from this blog

swapping the alternate values in given array's element ! 17/11/2022

Learning stage | c++ programs

c++ basic question