I make custom textformfield class and used it as a widget. I want to get the textformfields color,fontsize,align etc which I have set.How can i get this all properties which i have set to the textformfield using controller or by anything?
My custom class code:
class CustomTextNIconWidget extends StatefulWidget {
final Color fontColor;
final GestureTapCallback onSingleTapWidget;
final GestureTapCallback onDoubleTapWidget;
final FontWeight fontWeight;
final TextEditingController controller;
final double fontSize;
CustomTextNIconWidget(
{Key key,
@required this.hint,
this.controller,
this.fontSize,
this.fontColor,
this.fontWeight,
this.textAlign,
this.onSingleTapWidget,
this.onDoubleTapWidget})
: super(key: key);
@override
_CustomTextNIconWidgetState createState() => _CustomTextNIconWidgetState();
}
class _CustomTextNIconWidgetState extends State<CustomTextNIconWidget> {
@override
Widget build(BuildContext context) {
return InkWell(
onTap: widget.onSingleTapWidget,
onDoubleTap: widget.onDoubleTapWidget,
child: Container(
child: TextFormField(
controller: widget.controller,
style: TextStyle(
color: widget.fontColor,
fontSize:
widget.fontSize == null ? getFontSize() : widget.fontSize,
fontWeight: widget.fontWeight == null
? getFontWeight()
: widget.fontWeight),
decoration: InputDecoration(
hintText: widget.hint,
hintStyle: TextStyle(color:white)),
),
),
);
}
I have used as:
CustomTextNIconWidget(
controller: myController,
hint: getAddress(),
fontColor: Colors.amber,
fontSize: 18,
fontWeight: FontWeight.bold,
onSingleTapWidget: (){
print("Text color,fontsize:{HowToGetAboveSetProperties}");
},
),