Skip to content

Commit edb6605

Browse files
committed
bfix: fix cannot add to an unmodifiable list bug
Signed-off-by: Aman <[email protected]>
1 parent e963a09 commit edb6605

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

lib/domain/models/contest_filter.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
44
part 'contest_filter.freezed.dart';
55
part 'contest_filter.g.dart';
66

7-
@freezed
7+
@Freezed(makeCollectionsUnmodifiable: false)
88
class ContestFilter extends Equatable with _$ContestFilter {
99
const factory ContestFilter({
1010
int? duration,

lib/presentation/update_profile/bloc/update_profile_bloc.dart

+9-9
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,13 @@ class UpdateProfileBloc extends Bloc<UpdateProfileEvent, UpdateProfileState> {
161161
for (final platform in platforms) {
162162
final handle = controllers[platform]!.text.trim();
163163

164-
if (handle.isEmpty) continue;
165-
166164
if (!compareHandles(platform, handle)) {
167165
isChanged |= true;
168-
final res = await UserRepository.verifyHandle(platform, handle);
166+
if (handle.isNotEmpty) {
167+
final res = await UserRepository.verifyHandle(platform, handle);
169168

170-
if (!res) errors[platform] = 'Invalid Handle';
169+
if (!res) errors[platform] = 'Invalid Handle';
170+
}
171171
}
172172
}
173173

@@ -209,19 +209,19 @@ class UpdateProfileBloc extends Bloc<UpdateProfileEvent, UpdateProfileState> {
209209
bool compareHandles(String platform, String value) {
210210
switch (platform) {
211211
case 'codechef':
212-
return value == state.user?.handle?.codechef;
212+
return value.compareTo(state.user?.handle?.codechef ?? '') == 0;
213213

214214
case 'codeforces':
215-
return value == state.user?.handle?.codeforces;
215+
return value.compareTo(state.user?.handle?.codeforces ?? '') == 0;
216216

217217
case 'hackerrank':
218-
return value == state.user?.handle?.hackerrank;
218+
return value.compareTo(state.user?.handle?.hackerrank ?? '') == 0;
219219

220220
case 'spoj':
221-
return value == state.user?.handle?.spoj;
221+
return value.compareTo(state.user?.handle?.spoj ?? '') == 0;
222222

223223
case 'leetcode':
224-
return value == state.user?.handle?.leetcode;
224+
return value.compareTo(state.user?.handle?.leetcode ?? '') == 0;
225225

226226
default:
227227
return false;

lib/presentation/update_profile/update_profile.dart

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class UpdateProfile extends StatelessWidget {
5151
SizedBox(height: 30.r),
5252
PrimaryButton(
5353
label: 'Save Changes',
54+
isLoading: state.isUpdating,
5455
onPressed: () {
5556
if (state.isUpdating) return;
5657
context

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Codephile.
33

44
publish_to: 'none'
55

6-
version: 1.0.0+13
6+
version: 1.0.0+15
77

88
environment:
99
sdk: ">=2.12.0 <3.0.0"

0 commit comments

Comments
 (0)