Skip to content

Commit

Permalink
fixing analysis errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanpodila committed May 17, 2024
1 parent dcde5fa commit 765f2b3
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 127 deletions.
8 changes: 4 additions & 4 deletions mobx/test/autorun_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ void main() {
});

test('can be disposed inside the tracking function', () {
final dispose = autorun((_) {
_.dispose();
final dispose = autorun((rxn) {
rxn.dispose();
});

expect(dispose.reaction.isDisposed, isTrue);
Expand All @@ -153,10 +153,10 @@ void main() {
ReactionDisposer dispose;

fakeAsync((async) {
dispose = autorun((_) {
dispose = autorun((rxn) {
final value = x.value + 1;
if (value > 10) {
_.dispose();
rxn.dispose();
}
}, delay: 1000);

Expand Down
222 changes: 111 additions & 111 deletions mobx/test/observable_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -620,36 +620,36 @@ void main() {

group('fires reportObserved() for read-methods', () {
<String, Function(ObservableList<int>)>{
'isEmpty': (_) => _.isEmpty,
'isNotEmpty': (_) => _.isNotEmpty,
'iterator': (_) => _.iterator,
'single': (_) => _ignoreException(() => _.single),
'first': (_) => _ignoreException(() => _.first),
'last': (_) => _ignoreException(() => _.last),
'toSet': (_) => _.toSet(),
'toList': (_) => _.toList(),
'join': (_) => _.join(),
'fold': (_) => _.fold(0, (sum, item) => sum),
'sublist': (_) => _.sublist(0),
'elementAt': (_) => _ignoreException(() => _.elementAt(0)),
'singleWhere': (_) => _ignoreException(
() => _.singleWhere((_) => _ == 20, orElse: () => 0)),
'lastIndexOf': (_) => _.lastIndexOf(20),
'indexOf': (_) => _.indexOf(20),
'getRange': (_) => _.getRange(0, 0),
'isEmpty': (list) => list.isEmpty,
'isNotEmpty': (list) => list.isNotEmpty,
'iterator': (list) => list.iterator,
'single': (list) => _ignoreException(() => list.single),
'first': (list) => _ignoreException(() => list.first),
'last': (list) => _ignoreException(() => list.last),
'toSet': (list) => list.toSet(),
'toList': (list) => list.toList(),
'join': (list) => list.join(),
'fold': (list) => list.fold(0, (sum, item) => sum),
'sublist': (list) => list.sublist(0),
'elementAt': (list) => _ignoreException(() => list.elementAt(0)),
'singleWhere': (list) => _ignoreException(
() => list.singleWhere((x) => x == 20, orElse: () => 0)),
'lastIndexOf': (list) => list.lastIndexOf(20),
'indexOf': (list) => list.indexOf(20),
'getRange': (list) => list.getRange(0, 0),

// ignore: avoid_function_literals_in_foreach_calls
'forEach': (_) => _.forEach((a) {}),

'contains': (_) => _.contains(null),
'indexWhere': (_) => _.indexWhere((_) => true),
'lastWhere': (_) => _.lastWhere((_) => true, orElse: () => 0),
'lastIndexWhere': (_) => _.lastIndexWhere((_) => true),
'firstWhere': (_) => _.firstWhere((_) => true, orElse: () => 0),
'every': (_) => _.every((_) => true),
'any': (_) => _.any((_) => true),
'[]': (_) => _[0],
'+': (_) => _ + [100],
'forEach': (list) => list.forEach((a) {}),

'contains': (list) => list.contains(null),
'indexWhere': (list) => list.indexWhere((_) => true),
'lastWhere': (list) => list.lastWhere((_) => true, orElse: () => 0),
'lastIndexWhere': (list) => list.lastIndexWhere((_) => true),
'firstWhere': (list) => list.firstWhere((_) => true, orElse: () => 0),
'every': (list) => list.every((_) => true),
'any': (list) => list.any((_) => true),
'[]': (list) => list[0],
'+': (list) => list + [100],
}.forEach(_templateReadTest);

test('bypass observable system', () {
Expand All @@ -673,166 +673,166 @@ void main() {

group('fires reportChanged() for write-methods', () {
<String, bool Function(ObservableList<int>)>{
'length=': (_) {
_.length = 0;
'length=': (x) {
x.length = 0;
return true;
},
'last=': (_) {
_.last = 100;
'last=': (x) {
x.last = 100;
return true;
},
'first=': (_) {
_.first = 100;
'first=': (x) {
x.first = 100;
return true;
},
'insertAll': (_) {
_.insertAll(0, [100]);
'insertAll': (x) {
x.insertAll(0, [100]);
return true;
},
'insert': (_) {
_.insert(0, 100);
'insert': (x) {
x.insert(0, 100);
return true;
},
'sort': (_) {
_.sort((l, r) => r.compareTo(l));
'sort': (x) {
x.sort((l, r) => r.compareTo(l));
return true;
},
'setRange': (_) {
_.setRange(0, 1, [100]);
'setRange': (x) {
x.setRange(0, 1, [100]);
return true;
},
'fillRange': (_) {
_.fillRange(0, 2, 100);
'fillRange': (x) {
x.fillRange(0, 2, 100);
return true;
},
'replaceRange': (_) {
_.replaceRange(0, 1, [100]);
'replaceRange': (x) {
x.replaceRange(0, 1, [100]);
return true;
},
'setAll': (_) {
_.setAll(0, [100]);
'setAll': (x) {
x.setAll(0, [100]);
return true;
},
'[]=': (_) {
_[0] = 100;
'[]=': (x) {
x[0] = 100;
return true;
},
'add': (_) {
_.add(100);
'add': (x) {
x.add(100);
return true;
},
'addAll': (_) {
_.addAll([100]);
'addAll': (x) {
x.addAll([100]);
return true;
},
'clear': (_) {
_.clear();
'clear': (x) {
x.clear();
return true;
},
'removeLast': (_) {
_.removeLast();
'removeLast': (x) {
x.removeLast();
return true;
},
'remove': (_) {
_.remove(0);
'remove': (x) {
x.remove(0);
return true;
},
'removeRange': (_) {
_.removeRange(0, 1);
'removeRange': (x) {
x.removeRange(0, 1);
return true;
},
'removeAt': (_) {
_.removeAt(0);
'removeAt': (x) {
x.removeAt(0);
return true;
},
'removeWhere': (_) {
_.removeWhere((_) => true);
'removeWhere': (x) {
x.removeWhere((x) => true);
return true;
},
'shuffle': (_) {
_.shuffle(Random(0));
'shuffle': (x) {
x.shuffle(Random(0));
return true;
},
'retainWhere': (_) {
_.retainWhere((_) => false);
'retainWhere': (x) {
x.retainWhere((x) => false);
return true;
},
'!length=': (_) {
_.length = 4;
'!length=': (x) {
x.length = 4;
return false;
},
'!last=': (_) {
_.last = 3;
'!last=': (x) {
x.last = 3;
return false;
},
'!first=': (_) {
_.first = 0;
'!first=': (x) {
x.first = 0;
return false;
},
'!insertAll': (_) {
_.insertAll(0, []);
'!insertAll': (x) {
x.insertAll(0, []);
return false;
},
'!sort': (_) {
_.sort();
'!sort': (x) {
x.sort();
return false;
},
'!setRange': (_) {
_.setRange(1, 1, [100]);
'!setRange': (x) {
x.setRange(1, 1, [100]);
return false;
},
'!fillRange': (_) {
_.fillRange(2, 2, 100);
'!fillRange': (x) {
x.fillRange(2, 2, 100);
return false;
},
'!replaceRange': (_) {
_.replaceRange(1, 1, []);
'!replaceRange': (x) {
x.replaceRange(1, 1, []);
return false;
},
'!setAll': (_) {
_.setAll(0, []);
'!setAll': (x) {
x.setAll(0, []);
return false;
},
'![]=': (_) {
_[2] = 2;
'![]=': (x) {
x[2] = 2;
return false;
},
'!addAll': (_) {
_.addAll([]);
'!addAll': (x) {
x.addAll([]);
return false;
},
'!remove': (_) {
_.remove(-1);
'!remove': (x) {
x.remove(-1);
return false;
},
'!removeRange': (_) {
_.removeRange(1, 1);
'!removeRange': (x) {
x.removeRange(1, 1);
return false;
},
'!removeWhere': (_) {
_.removeWhere((_) => false);
'!removeWhere': (x) {
x.removeWhere((x) => false);
return false;
},
'!retainWhere': (_) {
_.retainWhere((_) => true);
'!retainWhere': (x) {
x.retainWhere((x) => true);
return false;
},
}.forEach(_templateWriteTest);
});

group('fires reportObserved() lazily on iterator returning methods', () {
<String, Iterable Function(ObservableList<int>)>{
'map': (_) => _.map((v) => v + 3),
'expand': (_) => _.expand((v) => [3, 2]),
'where': (_) => _.where((v) => v < 30),
'whereType': (_) => _.whereType<int>(),
'skip': (_) => _.skip(0),
'skipWhile': (_) => _.skipWhile((v) => v > 100),
'followedBy': (_) => _.followedBy([30]),
'take': (_) => _.take(1),
'takeWhile': (_) => _.takeWhile((_) => true),
'cast': (_) => _.cast<num>(),
'reversed': (_) => _.reversed
'map': (list) => list.map((v) => v + 3),
'expand': (list) => list.expand((v) => [3, 2]),
'where': (list) => list.where((v) => v < 30),
'whereType': (list) => list.whereType<int>(),
'skip': (list) => list.skip(0),
'skipWhile': (list) => list.skipWhile((v) => v > 100),
'followedBy': (list) => list.followedBy([30]),
'take': (list) => list.take(1),
'takeWhile': (list) => list.takeWhile((_) => true),
'cast': (list) => list.cast<num>(),
'reversed': (list) => list.reversed
}.forEach(_templateIterableReadTest);
});

Expand Down
4 changes: 2 additions & 2 deletions mobx/test/when_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ void main() {

test('exceptions inside asyncWhen are caught and reaction is disposed', () {
late Reaction rxn;
asyncWhen((_) {
rxn = _;
asyncWhen((rx) {
rxn = rx;
throw Exception('FAIL');
}, name: 'Async-when')
.catchError((_) {
Expand Down
4 changes: 2 additions & 2 deletions mobx_examples/lib/form/form_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ class FormExample extends StatefulWidget {
const FormExample({Key? key}) : super(key: key);

@override
_FormExampleState createState() => _FormExampleState();
FormExampleState createState() => FormExampleState();
}

class _FormExampleState extends State<FormExample> {
class FormExampleState extends State<FormExample> {
final FormStore store = FormStore();

@override
Expand Down
8 changes: 4 additions & 4 deletions mobx_examples/lib/multi_counter/multi_counter_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'package:mobx/mobx.dart';

part 'multi_counter_store.g.dart';

class SingleCounter = _SingleCounter with _$SingleCounter;
class SingleCounter = InternalSingleCounter with _$SingleCounter;

abstract class _SingleCounter with Store {
abstract class InternalSingleCounter with Store {
@observable
int value = 0;

Expand All @@ -24,9 +24,9 @@ abstract class _SingleCounter with Store {
}
}

class MultiCounterStore = _MultiCounterStore with _$MultiCounterStore;
class MultiCounterStore = InternalMultiCounterStore with _$MultiCounterStore;

abstract class _MultiCounterStore with Store {
abstract class InternalMultiCounterStore with Store {
final ObservableList<SingleCounter> counters =
ObservableList<SingleCounter>.of([]);

Expand Down
Loading

0 comments on commit 765f2b3

Please sign in to comment.