From edb6605ee30b790c497b38c97f28ef7d536682f5 Mon Sep 17 00:00:00 2001 From: Aman Date: Thu, 6 Oct 2022 16:38:15 +0530 Subject: [PATCH] bfix: fix cannot add to an unmodifiable list bug Signed-off-by: Aman --- lib/domain/models/contest_filter.dart | 2 +- .../bloc/update_profile_bloc.dart | 18 +++++++++--------- .../update_profile/update_profile.dart | 1 + pubspec.yaml | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/domain/models/contest_filter.dart b/lib/domain/models/contest_filter.dart index 36372fc7..458345e9 100644 --- a/lib/domain/models/contest_filter.dart +++ b/lib/domain/models/contest_filter.dart @@ -4,7 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; part 'contest_filter.freezed.dart'; part 'contest_filter.g.dart'; -@freezed +@Freezed(makeCollectionsUnmodifiable: false) class ContestFilter extends Equatable with _$ContestFilter { const factory ContestFilter({ int? duration, diff --git a/lib/presentation/update_profile/bloc/update_profile_bloc.dart b/lib/presentation/update_profile/bloc/update_profile_bloc.dart index 6cb514d3..f63e6f2e 100644 --- a/lib/presentation/update_profile/bloc/update_profile_bloc.dart +++ b/lib/presentation/update_profile/bloc/update_profile_bloc.dart @@ -161,13 +161,13 @@ class UpdateProfileBloc extends Bloc { for (final platform in platforms) { final handle = controllers[platform]!.text.trim(); - if (handle.isEmpty) continue; - if (!compareHandles(platform, handle)) { isChanged |= true; - final res = await UserRepository.verifyHandle(platform, handle); + if (handle.isNotEmpty) { + final res = await UserRepository.verifyHandle(platform, handle); - if (!res) errors[platform] = 'Invalid Handle'; + if (!res) errors[platform] = 'Invalid Handle'; + } } } @@ -209,19 +209,19 @@ class UpdateProfileBloc extends Bloc { bool compareHandles(String platform, String value) { switch (platform) { case 'codechef': - return value == state.user?.handle?.codechef; + return value.compareTo(state.user?.handle?.codechef ?? '') == 0; case 'codeforces': - return value == state.user?.handle?.codeforces; + return value.compareTo(state.user?.handle?.codeforces ?? '') == 0; case 'hackerrank': - return value == state.user?.handle?.hackerrank; + return value.compareTo(state.user?.handle?.hackerrank ?? '') == 0; case 'spoj': - return value == state.user?.handle?.spoj; + return value.compareTo(state.user?.handle?.spoj ?? '') == 0; case 'leetcode': - return value == state.user?.handle?.leetcode; + return value.compareTo(state.user?.handle?.leetcode ?? '') == 0; default: return false; diff --git a/lib/presentation/update_profile/update_profile.dart b/lib/presentation/update_profile/update_profile.dart index affdb940..62a2c8f9 100644 --- a/lib/presentation/update_profile/update_profile.dart +++ b/lib/presentation/update_profile/update_profile.dart @@ -51,6 +51,7 @@ class UpdateProfile extends StatelessWidget { SizedBox(height: 30.r), PrimaryButton( label: 'Save Changes', + isLoading: state.isUpdating, onPressed: () { if (state.isUpdating) return; context diff --git a/pubspec.yaml b/pubspec.yaml index d617aef6..cd79a03f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: Codephile. publish_to: 'none' -version: 1.0.0+13 +version: 1.0.0+15 environment: sdk: ">=2.12.0 <3.0.0"