Skip to content

Commit

Permalink
bfix: fix cannot add to an unmodifiable list bug
Browse files Browse the repository at this point in the history
Signed-off-by: Aman <[email protected]>
  • Loading branch information
aman-singh7 committed Oct 6, 2022
1 parent e963a09 commit edb6605
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/domain/models/contest_filter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 9 additions & 9 deletions lib/presentation/update_profile/bloc/update_profile_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ class UpdateProfileBloc extends Bloc<UpdateProfileEvent, UpdateProfileState> {
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';
}
}
}

Expand Down Expand Up @@ -209,19 +209,19 @@ class UpdateProfileBloc extends Bloc<UpdateProfileEvent, UpdateProfileState> {
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;
Expand Down
1 change: 1 addition & 0 deletions lib/presentation/update_profile/update_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit edb6605

Please sign in to comment.