-
Notifications
You must be signed in to change notification settings - Fork 90
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
copyWith throws TypeError when built for web #39
Comments
Hello. Oh man this looks hard haha.. the dynamic unset approach is the only way to make |
Is something like the copy_with_extension not an option? |
did not know about this package, let me test it :) |
For the import 'package:freezed_annotation/freezed_annotation.dart';
import 'epoch_date_time_converter.dart';
import 'link_preview.dart';
part 'message.freezed.dart';
part 'message.g.dart';
@Freezed(unionKey: 'type', fallbackUnion: 'unsupported')
sealed class Message with _$Message {
const factory Message.text({
required String id,
required String senderId,
@EpochDateTimeConverter() required DateTime timestamp,
Map<String, dynamic>? metadata,
required String text,
LinkPreview? linkPreview,
}) = TextMessage;
const factory Message.image({
required String id,
required String senderId,
@EpochDateTimeConverter() required DateTime timestamp,
Map<String, dynamic>? metadata,
required String source,
String? thumbhash,
String? blurhash,
double? width,
double? height,
}) = ImageMessage;
const factory Message.unsupported({
required String id,
required String senderId,
@EpochDateTimeConverter() required DateTime timestamp,
Map<String, dynamic>? metadata,
}) = UnsupportedMessage;
factory Message.fromJson(Map<String, dynamic> json) =>
_$MessageFromJson(json);
} |
Hi, thanks for your awesome library! I just encountered a bug that was extremely difficult to trace and I don't know what happens here exactly...
I'm using Message.copyWith in the process of creating my messages to diplay them in a chat UI. On Flutter Web, the following code throws a TypeError:
I fixed it by passing metadata as parameter to copyWith:
TypeError: Instance of '_Type': type '_Type' is not a subtype of type 'Map<String, dynamic>?'
Could it be something to do with
dynamic metadata = _Unset
in the copyWith implementation? Maybe minifying to JS optimizes the _Unset type away?The text was updated successfully, but these errors were encountered: