fast_immutable_collections icon indicating copy to clipboard operation
fast_immutable_collections copied to clipboard

Own iterable Class with FromIterableIListMixin not iterable in Web

Open Surio89 opened this issue 4 years ago • 3 comments
trafficstars

Hi,

i created my own iterable class:

import 'package:fast_immutable_collections/fast_immutable_collections.dart';


class MyIter with FromIterableIListMixin<String> implements Iterable<String>{

  MyIter([Iterable<String> strings]) : _strings = IList(strings);

  final IList<String> _strings;

  @override
  IList<String> get iter => _strings;
}

if i use this class inside a for loop e.g.:

for (final String letter in _myIter){ string += letter; }

this iterable works well on android emulator but if i use chrome it throws:

"TypeError: this[_myIter] is not iterable"

only if i write: for (final String letter in _myIter.iter){ string += letter; }

it works. Did i do something wrong or is this a bug?

Surio89 avatar May 20 '21 17:05 Surio89

Strange. I'm not sure what's the culprit from a first look. It might not be anybody's fault though, because transpilation to JS assumes many unexpected limitations. Are you using Flutter or transpiling directly to JS from Dart?

psygo avatar May 21 '21 00:05 psygo

Im using Flutter 2.2.0

Surio89 avatar May 21 '21 07:05 Surio89

Your MyIterclass explicitly implements Iterable, and it says it is not an iterable. It seems like a bug in Dart.

Could you please open a bug report in https://github.com/dart-lang/sdk/issues, post your code there, and link to this page?

Since it seems you have a reproducible code snippet, they can fix it.

marcglasberg avatar May 29 '21 22:05 marcglasberg