错误很简单我不知道如何解决问题请帮忙
import 'package:flutter/material.dart';
class CheetahInput extends StatelessWidget {
final String? labelText;
final VoidCallback? onSaved;
CheetahInput({@required this.labelText, @required this.onSaved});
@override
Widget build(BuildContext context) {
return TextFormField(
decoration: InputDecoration(
fillColor: Colors.white,
filled: true,
labelText: labelText,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
),
floatingLabelBehavior: FloatingLabelBehavior.never,
),
initialValue: '',
validator: (String? value) {
return value!.isEmpty ? '$labelText is required' : null;
},
onSaved: onSaved,
);
}
}
我试图用尖括号指定类型,但没有用 感谢您的帮助。
答案 0 :(得分:2)
替换
final VoidCallback? onSaved;
与
final Function(String)? onSaved;
答案 1 :(得分:0)
替换
final VoidCallback? onSaved;
与
final FormFieldSetter<String>? onSaved;