glidex icon indicating copy to clipboard operation
glidex copied to clipboard

Allow UriImageSource.Uri to be null

Open Dreamescaper opened this issue 3 years ago • 3 comments

Native Xamarin.Forms allows UriImageSource.Uri to be null - it behaves same as when ImageSource is null. With Glidex.Forms, however, it fails in GlideExtensions.LoadViaGlide method.

Dreamescaper avatar May 25 '21 08:05 Dreamescaper

Can you share an example code snippet that fails?

Maybe you could add a page to this app? https://github.com/jonathanpeppers/glidex/tree/master/glidex.forms.sample/Forms

Thanks!

jonathanpeppers avatar May 25 '21 13:05 jonathanpeppers

Native Xamarin.Forms allows UriImageSource.Uri to be null - it behaves same as when ImageSource is null. With Glidex.Forms, however, it fails in GlideExtensions.LoadViaGlide method.

Hi Dreamescaper. I just replaced the code in GlideExtensions.cs file:

				case UriImageSource uriSource:
					{
						if(uriSource is null || uriSource.Uri is null || string.IsNullOrEmpty(uriSource.Uri.OriginalString))
						{
							Clear (request, imageView);
							return;
						}

						builder = HandleUriImageSource (request, uriSource);
					}						
					break;

No more Null Reference Exception. Regards

visualbruno avatar Dec 24 '21 10:12 visualbruno

@visualbruno if you fixed something, would you consider sending a pull request explaining the fix? Thanks!

jonathanpeppers avatar Dec 29 '21 22:12 jonathanpeppers