I am trying to upload image into the database. I have used image picker and image cropper dependencies but it still shows error in the code within the ** that it donot recognize such commands. After the image picker it donot suggests pickimage. Kindly help me get through it. class EmployeeRegistrationScreen extends StatefulWidget {
static const id = 'employee_register';
@override
_EmployeeRegistrationScreenState createState() => _EmployeeRegistrationScreenState();
}
class _EmployeeRegistrationScreenState extends State<EmployeeRegistrationScreen> {
bool showSpinner = false;
final _auth = FirebaseAuth.instance;
String email;
String password;
String confirmPassword;
bool _passwordVisible = false;
bool _confirmPasswordVisible = false;
String name;
File _imageFile;
/// Cropper plugin
Future<void> _cropImage() async {
File cropped = await ImageCropper.cropImage(
sourcePath: _imageFile.path,
// ratioX: 1.0,
// ratioY: 1.0,
// maxWidth: 512,
// maxHeight: 512,
**toolbarColor: Colors.purple,**
**toolbarWidgetColor: Colors.white,**
**toolbarTitle: 'Crop It'**
);
setState(() {
_imageFile = cropped ?? _imageFile;
});
}
/// Select an image via gallery or camera
Future<void> _pickImage(ImageSource source) async {
**XFile selected = await ImagePicker.pickImage(source: source);**
setState(() {
_imageFile = selected as File;
});
}
/// Remove image
void _clear() {
setState(() => _imageFile = null);
}
@override
void initState() {
_passwordVisible = false;
_confirmPasswordVisible = false;
}
final _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return Form(