Skip to content

Commit 60da91f

Browse files
committed
fix analyzer issues
1 parent 5068219 commit 60da91f

12 files changed

+29
-180
lines changed

sample_app/lib/screens/user_feed/feed/user_feed_item.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import '../../../widgets/action_button.dart';
99
import '../../../widgets/attachment_gallery/attachment_metadata.dart';
1010
import '../../../widgets/attachments/attachments.dart';
1111
import '../../../widgets/user_avatar.dart';
12-
import '../polls/show_poll/poll_message.dart';
1312
import '../polls/show_poll/show_poll_widget.dart';
1413

1514
class UserFeedItem extends StatelessWidget {

sample_app/lib/screens/user_feed/polls/create_poll/poll_option_reorderable_list_view.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ class _PollOptionReorderableListViewState
205205
}
206206

207207
void _disposeOptions() {
208-
_focusNodes.values.forEach((it) => it.dispose());
208+
for (final it in _focusNodes.values) {
209+
it.dispose();
210+
}
209211
_focusNodes.clear();
210212
_options.clear();
211213
}
@@ -462,15 +464,15 @@ class SeparatedReorderableListView extends ReorderableListView {
462464

463465
// Ideally should never happen as separators are wrapped in the
464466
// IgnorePointer widget. This is just a safety check.
465-
if (oldIndex % 2 == 1) return;
467+
if (oldIndex.isOdd) return;
466468

467469
// The item moved behind the top/bottom separator we should not
468470
// reorder it.
469471
if ((oldIndex - newIndex).abs() == 1) return;
470472

471473
// Calculate the updated indexes
472474
final updatedOldIndex = oldIndex ~/ 2;
473-
final updatedNewIndex = oldIndex > newIndex && newIndex % 2 == 1
475+
final updatedNewIndex = oldIndex > newIndex && newIndex.isOdd
474476
? (newIndex + 1) ~/ 2
475477
: newIndex ~/ 2;
476478

sample_app/lib/screens/user_feed/polls/create_poll/stream_poll_controller.dart

Lines changed: 0 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -208,141 +208,3 @@ sealed class PollValidationError with _$PollValidationError {
208208
required Range<int> range,
209209
}) = _PollValidationErrorMaxVotesAllowed;
210210
}
211-
212-
// coverage:ignore-start
213-
214-
/// @nodoc
215-
extension PollValidationErrorPatternMatching on PollValidationError {
216-
/// @nodoc
217-
@optionalTypeArgs
218-
TResult when<TResult extends Object?>({
219-
required TResult Function(List<PollOptionInputState> options)
220-
duplicateOptions,
221-
required TResult Function(String name, Range<int> range) nameRange,
222-
required TResult Function(
223-
List<PollOptionInputState> options, Range<int> range)
224-
optionsRange,
225-
required TResult Function(int maxVotesAllowed, Range<int> range)
226-
maxVotesAllowed,
227-
}) {
228-
final error = this;
229-
return switch (error) {
230-
_PollValidationErrorDuplicateOptions() => duplicateOptions(error.options),
231-
_PollValidationErrorNameRange() => nameRange(error.name, error.range),
232-
_PollValidationErrorOptionsRange() =>
233-
optionsRange(error.options, error.range),
234-
_PollValidationErrorMaxVotesAllowed() =>
235-
maxVotesAllowed(error.maxVotesAllowed, error.range),
236-
};
237-
}
238-
239-
/// @nodoc
240-
@optionalTypeArgs
241-
TResult? whenOrNull<TResult extends Object?>({
242-
TResult? Function(List<PollOptionInputState> options)? duplicateOptions,
243-
TResult? Function(String name, Range<int> range)? nameRange,
244-
TResult? Function(List<PollOptionInputState> options, Range<int> range)?
245-
optionsRange,
246-
TResult? Function(int maxVotesAllowed, Range<int> range)? maxVotesAllowed,
247-
}) {
248-
final error = this;
249-
return switch (error) {
250-
_PollValidationErrorDuplicateOptions() =>
251-
duplicateOptions?.call(error.options),
252-
_PollValidationErrorNameRange() =>
253-
nameRange?.call(error.name, error.range),
254-
_PollValidationErrorOptionsRange() =>
255-
optionsRange?.call(error.options, error.range),
256-
_PollValidationErrorMaxVotesAllowed() =>
257-
maxVotesAllowed?.call(error.maxVotesAllowed, error.range),
258-
};
259-
}
260-
261-
/// @nodoc
262-
@optionalTypeArgs
263-
TResult maybeWhen<TResult extends Object?>({
264-
TResult Function(List<PollOptionInputState> options)? duplicateOptions,
265-
TResult Function(String name, Range<int> range)? nameRange,
266-
TResult Function(List<PollOptionInputState> options, Range<int> range)?
267-
optionsRange,
268-
TResult Function(int maxVotesAllowed, Range<int> range)? maxVotesAllowed,
269-
required TResult orElse(),
270-
}) {
271-
final error = this;
272-
final result = switch (error) {
273-
_PollValidationErrorDuplicateOptions() =>
274-
duplicateOptions?.call(error.options),
275-
_PollValidationErrorNameRange() =>
276-
nameRange?.call(error.name, error.range),
277-
_PollValidationErrorOptionsRange() =>
278-
optionsRange?.call(error.options, error.range),
279-
_PollValidationErrorMaxVotesAllowed() =>
280-
maxVotesAllowed?.call(error.maxVotesAllowed, error.range),
281-
};
282-
283-
return result ?? orElse();
284-
}
285-
286-
/// @nodoc
287-
@optionalTypeArgs
288-
TResult map<TResult extends Object?>({
289-
required TResult Function(_PollValidationErrorDuplicateOptions value)
290-
duplicateOptions,
291-
required TResult Function(_PollValidationErrorNameRange value) nameRange,
292-
required TResult Function(_PollValidationErrorOptionsRange value)
293-
optionsRange,
294-
required TResult Function(_PollValidationErrorMaxVotesAllowed value)
295-
maxVotesAllowed,
296-
}) {
297-
final error = this;
298-
return switch (error) {
299-
_PollValidationErrorDuplicateOptions() => duplicateOptions(error),
300-
_PollValidationErrorNameRange() => nameRange(error),
301-
_PollValidationErrorOptionsRange() => optionsRange(error),
302-
_PollValidationErrorMaxVotesAllowed() => maxVotesAllowed(error),
303-
};
304-
}
305-
306-
/// @nodoc
307-
@optionalTypeArgs
308-
TResult? mapOrNull<TResult extends Object?>({
309-
TResult? Function(_PollValidationErrorDuplicateOptions value)?
310-
duplicateOptions,
311-
TResult? Function(_PollValidationErrorNameRange value)? nameRange,
312-
TResult? Function(_PollValidationErrorOptionsRange value)? optionsRange,
313-
TResult? Function(_PollValidationErrorMaxVotesAllowed value)?
314-
maxVotesAllowed,
315-
}) {
316-
final error = this;
317-
return switch (error) {
318-
_PollValidationErrorDuplicateOptions() => duplicateOptions?.call(error),
319-
_PollValidationErrorNameRange() => nameRange?.call(error),
320-
_PollValidationErrorOptionsRange() => optionsRange?.call(error),
321-
_PollValidationErrorMaxVotesAllowed() => maxVotesAllowed?.call(error),
322-
};
323-
}
324-
325-
/// @nodoc
326-
@optionalTypeArgs
327-
TResult maybeMap<TResult extends Object?>({
328-
TResult Function(_PollValidationErrorDuplicateOptions value)?
329-
duplicateOptions,
330-
TResult Function(_PollValidationErrorNameRange value)? nameRange,
331-
TResult Function(_PollValidationErrorOptionsRange value)? optionsRange,
332-
TResult Function(_PollValidationErrorMaxVotesAllowed value)?
333-
maxVotesAllowed,
334-
required TResult orElse(),
335-
}) {
336-
final error = this;
337-
final result = switch (error) {
338-
_PollValidationErrorDuplicateOptions() => duplicateOptions?.call(error),
339-
_PollValidationErrorNameRange() => nameRange?.call(error),
340-
_PollValidationErrorOptionsRange() => optionsRange?.call(error),
341-
_PollValidationErrorMaxVotesAllowed() => maxVotesAllowed?.call(error),
342-
};
343-
344-
return result ?? orElse();
345-
}
346-
}
347-
348-
// coverage:ignore-end

sample_app/lib/screens/user_feed/polls/create_poll/stream_poll_creator_widget.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ class StreamPollCreatorWidget extends StatelessWidget {
7070
initialOptions: [
7171
for (final option in poll.options)
7272
PollOptionItem(
73-
key: option.key,
74-
originalId: option.originalId,
75-
text: option.text),
73+
key: option.key,
74+
originalId: option.originalId,
75+
text: option.text,
76+
),
7677
],
7778
onOptionsChanged: (options) => controller.options = [
7879
for (final option in options)

sample_app/lib/screens/user_feed/polls/show_poll/poll_footer.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@ import 'package:stream_feeds/stream_feeds.dart';
33

44
import '../../../../theme/extensions/theme_extensions.dart';
55

6-
/// {@template pollFooter}
7-
/// A widget used as the footer of a poll.
8-
///
9-
/// Used in [StreamPollInteractor] to display various actions the user can take
10-
/// on the poll.
11-
/// {@endtemplate}
126
class PollFooter extends StatelessWidget {
13-
/// {@macro pollFooter}
147
const PollFooter({
158
super.key,
169
required this.poll,

sample_app/lib/screens/user_feed/polls/show_poll/poll_header.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ import 'package:stream_feeds/stream_feeds.dart';
33

44
import '../../../../theme/extensions/theme_extensions.dart';
55

6-
/// {@template pollHeader}
7-
/// A widget used as the header of a poll.
8-
///
9-
/// Used in [StreamPollInteractor] to display the poll question and voting mode.
10-
/// {@endtemplate}
116
class PollHeader extends StatelessWidget {
12-
/// {@macro pollHeader}
137
const PollHeader({
148
super.key,
159
required this.poll,

sample_app/lib/screens/user_feed/polls/show_poll/poll_message.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ class PollMessage extends StatelessWidget {
7575
visibleOptionCount: _maxVisibleOptionCount,
7676
onEndVote: onEndVote,
7777
onCastVote: (option) => activity.castPollVote(
78-
CastPollVoteRequest(vote: VoteData(optionId: option.id))),
78+
CastPollVoteRequest(vote: VoteData(optionId: option.id)),
79+
),
7980
onRemoveVote: (vote) => activity.deletePollVote(voteId: vote.id),
8081
onAddComment: onAddComment,
8182
onSuggestOption: onSuggestOption,

sample_app/lib/screens/user_feed/polls/show_poll/poll_options_list_view.dart

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@ import '../../../../theme/extensions/theme_extensions.dart';
66
import '../../../../widgets/user_avatar.dart';
77
import 'poll_header.dart';
88

9-
/// {@template pollOptionsListView}
10-
/// A widget that displays the list of poll options.
11-
///
12-
/// Used in [StreamPollInteractor] to display the poll options to interact with.
13-
/// {@endtemplate}
149
class PollOptionsListView extends StatelessWidget {
15-
/// {@macro pollOptionsListView}
1610
const PollOptionsListView({
1711
super.key,
1812
required this.poll,
@@ -215,7 +209,7 @@ class PollOptionItem extends StatelessWidget {
215209
),
216210
],
217211
),
218-
)
212+
),
219213
],
220214
),
221215
),

sample_app/lib/screens/user_feed/polls/show_poll/stream_poll_comments_dialog.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:flutter/foundation.dart';
21
import 'package:flutter/material.dart';
32
import 'package:stream_feeds/stream_feeds.dart';
43

@@ -32,9 +31,11 @@ Future<T?> showStreamPollCommentsDialog<T extends Object?>({
3231
);
3332

3433
if (commentText == null) return;
35-
activity.castPollVote(
36-
CastPollVoteRequest(vote: VoteData(answerText: commentText)),
37-
);
34+
activity
35+
.castPollVote(
36+
CastPollVoteRequest(vote: VoteData(answerText: commentText)),
37+
)
38+
.ignore();
3839
}
3940

4041
return StreamPollCommentsDialog(
@@ -103,10 +104,12 @@ class StreamPollCommentsDialog extends StatelessWidget {
103104
foregroundColor: colorTheme.accentPrimary,
104105
disabledForegroundColor: colorTheme.disabled,
105106
),
106-
child: Text(switch (poll.ownAnswers.isEmpty) {
107-
true => 'Add a comment',
108-
false => 'Update your comment',
109-
}),
107+
child: Text(
108+
switch (poll.ownAnswers.isEmpty) {
109+
true => 'Add a comment',
110+
false => 'Update your comment',
111+
},
112+
),
110113
),
111114
),
112115
),

sample_app/lib/screens/user_feed/polls/show_poll/stream_poll_options_dialog.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ Future<T?> showStreamPollOptionsDialog<T extends Object?>({
2222
builder: (_) {
2323
void onCastVote(PollOptionData option) {
2424
activity.castPollVote(
25-
CastPollVoteRequest(vote: VoteData(optionId: option.id)));
25+
CastPollVoteRequest(vote: VoteData(optionId: option.id)),
26+
);
2627
}
2728

2829
void onRemoveVote(PollVoteData vote) {

0 commit comments

Comments
 (0)