@@ -35,7 +35,7 @@ extension IterableX<E> on Iterable<E> {
3535 /// ```
3636 E ? elementAtOrNull (int index) {
3737 if (index < 0 ) return null ;
38- int count = 0 ;
38+ var count = 0 ;
3939 for (final element in this ) {
4040 if (index == count++ ) return element;
4141 }
@@ -65,7 +65,7 @@ extension IterableX<E> on Iterable<E> {
6565 /// ```
6666 E elementAtOrElse (int index, E Function (int index) defaultValue) {
6767 if (index < 0 ) return defaultValue (index);
68- int count = 0 ;
68+ var count = 0 ;
6969 for (final element in this ) {
7070 if (index == count++ ) return element;
7171 }
@@ -148,8 +148,8 @@ extension IterableX<E> on Iterable<E> {
148148 /// If [end] is omitted, it is being set to `lastIndex` .
149149 List <E > slice (int start, [int end = - 1 ]) {
150150 final list = this is List ? this as List <E > : toList ();
151- int _start = start;
152- int _end = end;
151+ var _start = start;
152+ var _end = end;
153153
154154 if (_start < 0 ) {
155155 _start = _start + list.length;
@@ -166,7 +166,7 @@ extension IterableX<E> on Iterable<E> {
166166 /// Performs the given [action] on each element, providing sequential index
167167 /// with the element.
168168 void forEachIndexed (void Function (E element, int index) action) {
169- int index = 0 ;
169+ var index = 0 ;
170170 for (final element in this ) {
171171 action (element, index++ );
172172 }
@@ -284,7 +284,7 @@ extension IterableX<E> on Iterable<E> {
284284 String truncated = '...' ,
285285 }) {
286286 final buffer = StringBuffer ();
287- int count = 0 ;
287+ var count = 0 ;
288288 for (final element in this ) {
289289 if (limit != null && count >= limit) {
290290 buffer.write (truncated);
@@ -311,7 +311,7 @@ extension IterableX<E> on Iterable<E> {
311311 /// Returns the sum of all values produced by [selector] function applied to
312312 /// each element in the collection.
313313 double sumBy (num Function (E element) selector) {
314- double sum = 0.0 ;
314+ var sum = 0.0 ;
315315 for (final current in this ) {
316316 sum += selector (current);
317317 }
@@ -321,7 +321,7 @@ extension IterableX<E> on Iterable<E> {
321321 /// Returns the average of values returned by [selector] for all elements in
322322 /// the collection.
323323 double averageBy (num Function (E element) selector) {
324- int count = 0 ;
324+ var count = 0 ;
325325 num sum = 0 ;
326326
327327 for (final current in this ) {
@@ -367,7 +367,7 @@ extension IterableX<E> on Iterable<E> {
367367 if (! it.moveNext ()) {
368368 return null ;
369369 }
370- E currentMin = it.current;
370+ var currentMin = it.current;
371371
372372 while (it.moveNext ()) {
373373 if ((it.current as Comparable ).compareTo (currentMin) == order) {
@@ -384,8 +384,8 @@ extension IterableX<E> on Iterable<E> {
384384 return null ;
385385 }
386386
387- E currentMin = it.current;
388- Comparable currentMinValue = selector (it.current);
387+ var currentMin = it.current;
388+ var currentMinValue = selector (it.current);
389389 while (it.moveNext ()) {
390390 final comp = selector (it.current);
391391 if (comp.compareTo (currentMinValue) == order) {
@@ -402,7 +402,7 @@ extension IterableX<E> on Iterable<E> {
402402 if (! it.moveNext ()) {
403403 return null ;
404404 }
405- E currentMin = it.current;
405+ var currentMin = it.current;
406406
407407 while (it.moveNext ()) {
408408 if (comparator (it.current, currentMin) == order) {
@@ -417,7 +417,7 @@ extension IterableX<E> on Iterable<E> {
417417 ///
418418 /// If no [predicate] is given, this equals to [length] .
419419 int count ([bool Function (E element)? predicate]) {
420- int count = 0 ;
420+ var count = 0 ;
421421 if (predicate == null ) {
422422 return length;
423423 } else {
@@ -543,7 +543,7 @@ extension IterableX<E> on Iterable<E> {
543543 /// Returns all elements that satisfy the given [predicate] .
544544 Iterable <E > whereIndexed (
545545 bool Function (E element, int index) predicate) sync * {
546- int index = 0 ;
546+ var index = 0 ;
547547 for (final element in this ) {
548548 if (predicate (element, index++ )) {
549549 yield element;
@@ -565,7 +565,7 @@ extension IterableX<E> on Iterable<E> {
565565 /// [destination] .
566566 void whereIndexedTo (
567567 List <E > destination, bool Function (E element, int index) predicate) {
568- int index = 0 ;
568+ var index = 0 ;
569569 for (final element in this ) {
570570 if (predicate (element, index++ )) {
571571 destination.add (element);
@@ -585,7 +585,7 @@ extension IterableX<E> on Iterable<E> {
585585 /// Returns all elements not matching the given [predicate] .
586586 Iterable <E > whereNotIndexed (
587587 bool Function (E element, int index) predicate) sync * {
588- int index = 0 ;
588+ var index = 0 ;
589589 for (final element in this ) {
590590 if (! predicate (element, index++ )) {
591591 yield element;
@@ -607,7 +607,7 @@ extension IterableX<E> on Iterable<E> {
607607 /// [destination] .
608608 void whereNotToIndexed (
609609 List <E > destination, bool Function (E element, int index) predicate) {
610- int index = 0 ;
610+ var index = 0 ;
611611 for (final element in this ) {
612612 if (! predicate (element, index++ )) {
613613 destination.add (element);
@@ -634,7 +634,7 @@ extension IterableX<E> on Iterable<E> {
634634 /// given [transform] function to each element and its index in the original
635635 /// collection.
636636 Iterable <R > mapIndexed <R >(R Function (int index, E ) transform) sync * {
637- int index = 0 ;
637+ var index = 0 ;
638638 for (final element in this ) {
639639 yield transform (index++ , element);
640640 }
@@ -644,7 +644,7 @@ extension IterableX<E> on Iterable<E> {
644644 /// applying the given [transform] function to each element and its index
645645 /// in the original collection.
646646 Iterable <R > mapIndexedNotNull <R >(R ? Function (int index, E ) transform) sync * {
647- int index = 0 ;
647+ var index = 0 ;
648648 for (final element in this ) {
649649 final result = transform (index++ , element);
650650 if (result != null ) {
@@ -703,7 +703,7 @@ extension IterableX<E> on Iterable<E> {
703703 throw ArgumentError ('Requested chunk size $size is less than one.' );
704704 }
705705
706- List < E > currentChunk = [];
706+ var currentChunk = < E > [];
707707 for (final current in this ) {
708708 currentChunk.add (current);
709709 if (currentChunk.length >= size) {
@@ -731,8 +731,8 @@ extension IterableX<E> on Iterable<E> {
731731 /// See also:
732732 /// - [splitWhen] , which works similarly but with a reverted [predicate] .
733733 Iterable <List <E >> chunkWhile (bool Function (E , E ) predicate) sync * {
734- List < E > currentChunk = [];
735- bool hasPrevious = false ;
734+ var currentChunk = < E > [];
735+ var hasPrevious = false ;
736736 late E previous;
737737
738738 for (final element in this ) {
@@ -784,8 +784,8 @@ extension IterableX<E> on Iterable<E> {
784784 }) sync * {
785785 final gap = step - size;
786786 if (gap >= 0 ) {
787- List < E > buffer = [];
788- int skip = 0 ;
787+ var buffer = < E > [];
788+ var skip = 0 ;
789789 for (final element in this ) {
790790 if (skip > 0 ) {
791791 skip -= 1 ;
@@ -794,7 +794,7 @@ extension IterableX<E> on Iterable<E> {
794794 buffer.add (element);
795795 if (buffer.length == size) {
796796 yield buffer;
797- buffer = [];
797+ buffer = < E > [];
798798 skip = gap;
799799 }
800800 }
@@ -842,7 +842,7 @@ extension IterableX<E> on Iterable<E> {
842842 ///
843843 /// If [n] is omitted, the Iterable cycles forever.
844844 Iterable <E > cycle ([int ? n]) sync * {
845- Iterator < E > it = iterator;
845+ var it = iterator;
846846 if (! it.moveNext ()) {
847847 return ;
848848 }
@@ -855,7 +855,7 @@ extension IterableX<E> on Iterable<E> {
855855 it = iterator;
856856 }
857857 } else {
858- int count = 0 ;
858+ var count = 0 ;
859859 yield it.current;
860860 while (count++ < n) {
861861 while (it.moveNext ()) {
0 commit comments