RivaanRanawat / instagram-flutter-clone

Responsive Instagram Clone developed with Flutter & Firebase
https://youtu.be/BBccK1zTgxw
858 stars 474 forks source link

SignUpScreen #10

Closed bedfir closed 1 year ago

bedfir commented 2 years ago

Hi everyone, the _image is null, so the signUpUser cannot be triggered if the user does not enter an image. this leads to an error by the postfix ! operator. _CastError (Null check operator used on a null value).

String res = await AuthMetods().signUpUser( email: _emailController.text, bio: _bioController.text, password: _passwordController.text, username: _usernameController.text, file: _image!, );

If we follow the logic of the application the user will have a default image.

how can we manage this with Firebase ? if the user doesn't enter an image ?

Bidibul33 commented 2 years ago

Hello, did you find the solution?

RivaanRanawat commented 2 years ago

In signUpUser function in AuthMethods class, replace the current parameter with this required Uint8List? file. Then add the following code in the same function:

if (file != null) {
      photoUrl = await StorageMethods().uploadImageToStorage('profilePics', file, false);
} else {
     photoUrl = 'https://i.stack.imgur.com/l60Hf.png';
}

Let me know if you face any issue/want an explanation of this.