Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing covariant in the == override #1

Merged
merged 1 commit into from
May 4, 2023

Conversation

bartdelange
Copy link
Owner

@bartdelange bartdelange commented May 4, 2023

Using covariant in this way disallows us to switch between image providers. This is because DecorationImage and the like use an equals check on their image provider.

As shown in error below, which was thrown when switching between an asset image and the firebase image:

======== Exception caught by widgets library ======================================================= The following _TypeError was thrown building Builder(dirty, dependencies: [Directionality, MediaQuery, _LocalizationsScope-[GlobalKey#61773]]): type 'AssetImage' is not a subtype of type 'FirebaseImageProvider' of 'other'

The relevant error-causing widget was:
Ink Ink:file:///anon/lib/components/widget.dart:100:28
When the exception was thrown, this was the stack:
0 FirebaseImageProvider.== (package:firebase_cached_image/src/firebase_image_provider.dart)
1 DecorationImage.== (package:flutter/src/painting/decoration_image.dart:196:24)
2 BoxDecoration.== (package:flutter/src/painting/box_decoration.dart:329:24)
3 InkDecoration.decoration= (package:flutter/src/material/ink_decoration.dart:355:15)
4 _InkState._build (package:flutter/src/material/ink_decoration.dart:292:13)
5 Builder.build (package:flutter/src/widgets/basic.dart:7448:48)
6 StatelessElement.build (package:flutter/src/widgets/framework.dart:5038:49)
7 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4968:15)

Using covariant in this way disallows us to switch between image providers.
This is because DecorationImage and the like use an equals check on their image provider.

As shown in error below, which was thrown when switching between an asset image and the firebase image: 

======== Exception caught by widgets library =======================================================
The following _TypeError was thrown building Builder(dirty, dependencies: [Directionality, MediaQuery, _LocalizationsScope-[GlobalKey#61773]]):
type 'AssetImage' is not a subtype of type 'FirebaseImageProvider' of 'other'

The relevant error-causing widget was: 
  Ink Ink:file:///anon/lib/components/widget.dart:100:28
When the exception was thrown, this was the stack: 
#0      FirebaseImageProvider.== (package:firebase_cached_image/src/firebase_image_provider.dart)
#1      DecorationImage.== (package:flutter/src/painting/decoration_image.dart:196:24)
imsamgarg#2      BoxDecoration.== (package:flutter/src/painting/box_decoration.dart:329:24)
imsamgarg#3      InkDecoration.decoration= (package:flutter/src/material/ink_decoration.dart:355:15)
imsamgarg#4      _InkState._build (package:flutter/src/material/ink_decoration.dart:292:13)
imsamgarg#5      Builder.build (package:flutter/src/widgets/basic.dart:7448:48)
imsamgarg#6      StatelessElement.build (package:flutter/src/widgets/framework.dart:5038:49)
imsamgarg#7      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4968:15)
@bartdelange bartdelange merged commit 453b902 into master May 4, 2023
@bartdelange bartdelange deleted the fixing-_TypeError-equality-check branch May 4, 2023 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant