2021年4月9日星期五

The method 'FormBuilderDateTimePicker' isn't defined for the type '_CreateEventState'

I am trying to use FormBuilder for my project for adding an event to a calendar, I used ForBuilderTextfield() and FormBuilderSwitch(), however when I try to define FormBuilderDateTimePicker for entering a date I get the following error:

The method 'FormBuilderDateTimePicker' isn't defined for the type '_CreateEventState'

My pubsec.yaml includes these packages:

`environment: sdk: ">=2.7.0 <3.0.0"

dependencies: flutter: sdk: flutter

The following adds the Cupertino Icons font to your application.

Use with the CupertinoIcons class for iOS style icons.

cupertino_icons: ^1.0.0

To use the firebase core API and enable connection to multiple firebase applications

firebase_core: ^1.0.0

For a secure authentication system for signing in with a Google Account

google_sign_in: ^4.5.9

For the state management; a wrapper around InheritedWidget to make it easier to use

provider: ^4.3.3

Enables authentication

firebase_auth: ^1.0.1

Allows access to the pre-configured buttons for all the third party auth providers

flutter_signin_button: ^1.1.0

Allows usage of 977 Google fonts

google_fonts: ^2.0.0

Flutter Widget that make it easy to implement the bloc design pattern

flutter_bloc: ^3.2.0

Stores data in a secure storage

flutter_secure_storage: ^3.3.5

Auto-generated client libraries for accessing Google APIs

googleapis: ^1.0.0

Obtain Access credentials for Google services using OAuth 2.0

googleapis_auth: ^1.1.0

Flutter plugin for getting commonly used locations on host platform file systems

path_provider: ^2.0.1

Allows you to use a native file explorer to pick single or multiple absolute file paths

file_picker: ^3.0.0

A Flutter plugin for launching a URL in the browser (to get permission from the user to use the Google API)

url_launcher: ^6.0.2

For date formatting

intl: any

Highly customizable, feature packed calendar widget

table_calendar: ^2.3.3

Flutter plugin fore firebase cloud storage

firebase_storage: ^8.0.3

Helps in creation of data collection forms in Flutter

flutter_form_builder: any

A Flutter plugin to use the Cloud Firestore API.

#cloud_firestore: ^1.0.3

dependency_overrides: intl: ^0.17.0-nullsafety.2 flutter_form_builder: ^6.0.0-nullsafety.1`

My _CreateEventState class:

`class _CreateEventState extends State<CreateEvent> {  

//Add a global key of type FormBuilderState final _formKey = GlobalKey();

@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: [ Text( 'Add a new event to the events list & notify attendees of the event.', style: TextStyle( color: AppColors.navyBlue, fontFamily: 'Raleway', fontSize: 16, fontWeight: FontWeight.bold, fontStyle: FontStyle.italic, ), ), SizedBox(height: 7), Text( 'You can modify or delete your event after creating it at anytime.', style: TextStyle( color: AppColors.lightBlack, fontFamily: 'Raleway', fontSize: 15, fontStyle: FontStyle.italic, ), ), SizedBox(height: 16.0), 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), //Add a Title text field FormBuilderTextField( name: "EventTitle", cursorColor: AppColors.lightBlue, style: TextStyle( color: AppColors.royalBlue, fontWeight: FontWeight.bold, ), decoration: InputDecoration( //When the field is disabled - the user cannot type disabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(5.0)), borderSide: BorderSide(color: AppColors.blue, width: 10), ), //When the field is enabled - the user can type enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(5.0)), borderSide: BorderSide(color: AppColors.blue, width: 1), ), //When the field is chosen to type on focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(5.0)), borderSide: BorderSide(color: AppColors.blue, width: 2), ), border: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(5.0)), ), //Padding on the button contentPadding: EdgeInsets.only( left: 15, bottom: 13, top: 13, right: 13, ), //The text viewed to the user before entering the title hintText: 'eg: HR meeting', hintStyle: TextStyle( color: AppColors.blue.withOpacity(0.6), fontSize: 15, fontStyle: FontStyle.italic, fontWeight: FontWeight.bold, ), ), ), SizedBox(height: 16.0), //The text above the description field - styling RichText( text: TextSpan( text: 'Event Description', style: TextStyle( color: AppColors.blue, fontFamily: 'Raleway', fontSize: 18, fontWeight: FontWeight.bold, ), ), ), SizedBox(height: 7.0), //Add a Description text field FormBuilderTextField( name: "EventDesc", //Add maximum and minimum lines for the user. maxLines: 4, minLines: 1, cursorColor: AppColors.lightBlue, style: TextStyle( color: AppColors.royalBlue, fontWeight: FontWeight.bold, ), decoration: InputDecoration( //When the field is disabled - the user cannot type disabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(5.0)), borderSide: BorderSide(color: AppColors.blue, width: 10), ), //When the field is enabled - the user can type enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(5.0)), borderSide: BorderSide(color: AppColors.blue, width: 1), ), //When the field is chosen to type on focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(5.0)), borderSide: BorderSide(color: AppColors.blue, width: 2), ), border: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(5.0)), ), //Padding on the button contentPadding: EdgeInsets.only( left: 15, bottom: 13, top: 13, right: 13, ), //The text viewed to the user before entering the title hintText: 'eg: Discuss the recruitment methods of ..', hintStyle: TextStyle( color: AppColors.blue.withOpacity(0.6), fontSize: 15, fontStyle: FontStyle.italic, fontWeight: FontWeight.bold, ), //Add a prefix icon to show how the details look prefixIcon: Icon( Icons.short_text, //Change the color so it matches the color of text entered. color: AppColors.blue.withOpacity(0.6), ), ), ), SizedBox(height: 7.0), //Add a switch for the user to choose whether to make the event public or private FormBuilderSwitch( name: "PublicEvent", //Add as a title a RichText to then style it title: RichText( text: TextSpan( text: 'Public Event', style: TextStyle( color: AppColors.blue, fontFamily: 'Raleway', fontSize: 16, fontWeight: FontWeight.bold, fontStyle: FontStyle.italic, ), ), ), initialValue: false, //The event initially is set to private controlAffinity: ListTileControlAffinity.leading, decoration: InputDecoration( border: InputBorder.none, ), ), SizedBox(height: 7.0), //The text above the date field - styling RichText( text: TextSpan( text: 'Event Date', style: TextStyle( color: AppColors.blue, fontFamily: 'Raleway', fontSize: 18, fontWeight: FontWeight.bold, ), ), ), SizedBox(height: 7.0),

        ],      ),    ),    ]  )  

); }`

https://stackoverflow.com/questions/67030178/the-method-formbuilderdatetimepicker-isnt-defined-for-the-type-createevents April 10, 2021 at 10:05AM

没有评论:

发表评论