我正在尝试将FormBuilder
项目用于将事件添加到日历中,我使用了ForBuilderTextfield()
and FormBuilderSwitch()
,但是当我尝试定义FormBuilderDateTimePicker
输入日期时,出现以下错误:
没有为类型“_CreateEventState”定义方法“FormBuilderDateTimePicker”
我的pubsec.yaml
包括这些包:
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.0
firebase_core: ^1.0.0
google_sign_in: ^4.5.9
provider: ^4.3.3
firebase_auth: ^1.0.1
flutter_signin_button: ^1.1.0
google_fonts: ^2.0.0
flutter_bloc: ^3.2.0
flutter_secure_storage: ^3.3.5
googleapis: ^1.0.0
googleapis_auth: ^1.1.0
path_provider: ^2.0.1
file_picker: ^3.0.0
url_launcher: ^6.0.2
intl: any
table_calendar: ^2.3.3
firebase_storage: ^8.0.3
flutter_form_builder: any
dependency_overrides:
intl: ^0.17.0-nullsafety.2
flutter_form_builder: ^6.0.0-nullsafety.1
我的_CreateEventState
班级:
class _CreateEventState extends State<CreateEvent> {
final _formKey = GlobalKey<FormBuilderState>();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Add an Event',
style: GoogleFonts.openSans(
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic,
fontSize: 25,
color: AppColors.royalBlue,
),
),
backgroundColor: Colors.white,
//Change the color of the back button to make it visible to the user.
iconTheme: IconThemeData(
color: AppColors.royalBlue,
),
),
body: ListView(
padding: const EdgeInsets.all(16.0),
children: <Widget>[
FormBuilder(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
//The text above the title field - styling
RichText(
text: TextSpan(
text: 'Event Title',
style: TextStyle(
color: AppColors.blue,
fontFamily: 'Raleway',
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
SizedBox(height: 7.0),
FormBuilderTextField(
name: "EventTitle",
cursorColor: AppColors.lightBlue,
style: TextStyle(
color: AppColors.royalBlue,
fontWeight: FontWeight.bold,
),
decoration: InputDecoration(
contentPadding: EdgeInsets.only(
left: 15,
bottom: 13,
top: 13,
right: 13,
),
hintText: 'eg: HR meeting',
),
),
SizedBox(height: 16.0),
FormBuilderSwitch(
name: "PublicEvent",
title: RichText(
text: TextSpan(
text: 'Public Event',
style: TextStyle(
color: AppColors.blue,
fontFamily: 'Raleway',
fontSize: 16,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic,
),
),
),
initialValue: false,
controlAffinity: ListTileControlAffinity.leading,
decoration: InputDecoration(
border: InputBorder.none,
),
),
SizedBox(height: 7.0),
RichText(
text: TextSpan(
text: 'Event Date',
style: TextStyle(
color: AppColors.blue,
fontFamily: 'Raleway',
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
SizedBox(height: 7.0),
//Add the FormBuilderDateTimePicker here
],
),
),
]
)
);
}```