Skip to content

Commit

Permalink
chore: Remove unused code and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
PlugFox committed Aug 2, 2024
1 parent e60f817 commit cb2c868
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 27 deletions.
5 changes: 0 additions & 5 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ linter:
avoid_js_rounded_ints: true
avoid_print: true
avoid_renaming_method_parameters: true
avoid_returning_null_for_future: true
avoid_returning_null_for_void: true
avoid_single_cascade_in_expression_statements: true
avoid_slow_async_io: true
Expand All @@ -99,10 +98,8 @@ linter:
close_sinks: true
control_flow_in_finally: true
empty_statements: true
iterable_contains_unrelated_type: true
join_return_with_assignment: true
leading_newlines_in_multiline_strings: true
list_remove_unrelated_type: true
literal_only_boolean_expressions: true
missing_whitespace_between_adjacent_strings: true
no_adjacent_strings_in_list: true
Expand Down Expand Up @@ -148,7 +145,6 @@ linter:
valid_regexps: true
void_checks: true
always_declare_return_types: true
always_require_non_null_named_parameters: true
annotate_overrides: true
avoid_empty_else: true
avoid_init_to_null: true
Expand Down Expand Up @@ -212,7 +208,6 @@ linter:
avoid_classes_with_only_static_members: true
use_setters_to_change_properties: true
avoid_setters_without_getters: true
avoid_returning_null: true
avoid_returning_this: true
type_annotate_public_apis: true
avoid_private_typedef_functions: true
Expand Down
19 changes: 7 additions & 12 deletions lib/src/list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,22 @@ import 'package:meta/meta.dart';
/// efficient [Iterable.length] and [Iterable.elementAt].
/// {@endtemplate}
@immutable
class ImmutableList<E> extends IterableBase<E> {
/// {@macro iterable.immutable_list}
ImmutableList(Iterable<E> source)
: _source = List<E>.of(source, growable: false);
extension type const ImmutableList<E>(List<E> _source)
implements IterableBase<E> {
/// {@macro immutable_list}
factory ImmutableList.from(Iterable<E> source) =>
ImmutableList<E>(List<E>.from(source, growable: false));

/// {@macro iterable.immutable_list}
/// {@macro immutable_list}
/// Empty collection
const ImmutableList.empty() : _source = const Iterable.empty();
const ImmutableList.empty() : _source = const [];

final Iterable<E> _source;

@override
ImmutableList<R> cast<R>() => ImmutableList<R>(_source.cast<R>());

@override
int get length => _source.length;

@override
E get last => _source.last;

@override
Iterator<E> get iterator => _source.iterator;

/// Adds [value] to the end of this list,
Expand Down
8 changes: 4 additions & 4 deletions lib/src/stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import 'package:meta/meta.dart';
/// Stream extension methods.
/// {@endtemplate}
extension BatteriesStreamX<Input> on Stream<Input> {
/// {@macro stream.relieve_stream_transformer}
/// {@macro relieve_stream_transformer}
Stream<Input> relieve([
Duration duration = const Duration(milliseconds: 4),
]) =>
transform<Input>(_RelieveStreamTransformer<Input>(duration));

/// {@macro stream.calm_stream_transformer}
/// {@macro calm_stream_transformer}
Stream<Input> calm(Duration duration) =>
transform<Input>(_CalmStreamTransformer<Input>(duration));

Expand Down Expand Up @@ -64,7 +64,7 @@ extension BatteriesStreamX<Input> on Stream<Input> {
/// {@endtemplate}
@immutable
class _RelieveStreamTransformer<T> extends StreamTransformerBase<T, T> {
/// {@macro stream.relieve_stream_transformer}
/// {@macro relieve_stream_transformer}
const _RelieveStreamTransformer([
this.duration = const Duration(milliseconds: 4),
]);
Expand Down Expand Up @@ -139,7 +139,7 @@ class _RelieveStreamTransformer<T> extends StreamTransformerBase<T, T> {
/// {@endtemplate}
@immutable
class _CalmStreamTransformer<T> extends StreamTransformerBase<T, T> {
/// {@macro stream.calm_stream_transformer}
/// {@macro calm_stream_transformer}
const _CalmStreamTransformer(this.duration);

/// Elapsed time of iterations before releasing next event.
Expand Down
12 changes: 6 additions & 6 deletions test/unit/list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ void main() => group(
() {
test('immutable_list', () {
expect(
() => ImmutableList(Iterable<int>.generate(100)),
() => ImmutableList.from(Iterable<int>.generate(100)),
returnsNormally,
);
expect(
ImmutableList(Iterable<int>.generate(100)),
ImmutableList.from(Iterable<int>.generate(100)),
isA<Iterable<int>>(),
);
expect(
ImmutableList(Iterable<int>.generate(100)),
ImmutableList.from(Iterable<int>.generate(100)),
isA<Iterable<num>>(),
);
expect(
ImmutableList<int>.empty(),
equals(const Iterable<int>.empty()),
);
expect(
ImmutableList(Iterable<int>.generate(100)).cast<num>(),
ImmutableList.from(Iterable<int>.generate(100)).cast<num>(),
isA<Iterable<num>>(),
);
expect(
ImmutableList(Iterable<int>.generate(100)).cast<num>(),
ImmutableList.from(Iterable<int>.generate(100)).cast<num>(),
isNot(isA<Iterable<int>>()),
);
expect(
ImmutableList(Iterable<int>.generate(100)).length,
ImmutableList.from(Iterable<int>.generate(100)).length,
equals(100),
);
expect(
Expand Down

0 comments on commit cb2c868

Please sign in to comment.