'm trying to make a simple TextField
with InputDecoration
. and when I'm using decoratoin:InputDecoration()
, It shows a problem . any idea why ??
class InputDecoration extends StatelessWidget {
const InputDecoration({Key? key}) : super(key: key);
@override
Widget build(BuildContext conyext) {
return TextField(
keyboardType: TextInputType.text,
style: TextStyle(
color: Colors.grey.shade800,
fontSize: 16.0,
),
decoration: InputDecoration(
hintText: 'Hint Text',
errorText: 'Error Text',
border: OutlineInputBorder(),
),
);
}
}
the error :
The argument type 'InputDecoration' can't be assigned to the parameter type 'InputDecoration?'.at [190:19]
No branch
95
CodePudding user response:
We already have InputDecoration
, rename your class
class MyInputDecoration extends StatelessWidget {
const MyInputDecoration({Key? key}) : super(key: key);
@override
Widget build(BuildContext conyext) {
return TextField(
keyboardType: TextInputType.text,
style: TextStyle(
color: Colors.grey.shade800,
fontSize: 16.0,
),
decoration: InputDecoration(
hintText: 'Hint Text',
errorText: 'Error Text',
border: OutlineInputBorder(),
),
);
}
}