CINXE.COM

Iterable class - dart:core library - Dart API

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, user-scalable=no"> <meta name="description" content="API docs for the Iterable class from the dart:core library, for the Dart programming language."> <title>Iterable class - dart:core library - Dart API</title> <link rel="canonical" href="https://api.dart.dev/dart-core/Iterable-class.html"> <link rel="preconnect" href="https://fonts.gstatic.com"> <link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,300;0,400;0,500;0,700;1,400&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" rel="stylesheet"> <link rel="stylesheet" href="../static-assets/github.css?v1"> <link rel="stylesheet" href="../static-assets/styles.css?v1"> <link rel="icon" href="../static-assets/favicon.png?v1"> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-VVQ8908SJ5"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-VVQ8908SJ5'); </script> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="preload" href="https://fonts.googleapis.com/css2?family=Google+Sans+Text:wght@400&family=Google+Sans:wght@500&display=swap" as="style"> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Google+Sans+Text:wght@400&family=Google+Sans:wght@500&display=swap"> <link rel="stylesheet" href="https://www.gstatic.com/glue/cookienotificationbar/cookienotificationbar.min.css"> </head> <body data-base-href="../" data-using-base-href="false" class="light-theme"> <div id="overlay-under-drawer"></div> <header id="title"> <span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span> <ol class="breadcrumbs gt-separated dark hidden-xs"> <li><a href="../index.html">Dart</a></li> <li><a href="../dart-core">dart:core</a></li> <li class="self-crumb">Iterable<span class="signature">&lt;<wbr><span class="type-parameter">E</span>&gt;</span> class</li> </ol> <div class="self-name">Iterable</div> <form class="search navbar-right" role="search"> <input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search..."> </form> <div class="toggle" id="theme-button" title="Toggle brightness"> <label for="theme"> <input type="checkbox" id="theme" value="light-theme"> <span id="dark-theme-button" class="material-symbols-outlined"> dark_mode </span> <span id="light-theme-button" class="material-symbols-outlined"> light_mode </span> </label> </div> </header> <main> <div id="dartdoc-main-content" class="main-content" data-above-sidebar="dart-core&#47;dart-core-library-sidebar.html" data-below-sidebar="dart-core&#47;Iterable-class-sidebar.html"> <div> <div id="external-links" class="btn-group"><a title="View source code" class="source-link" href="https://github.com/dart-lang/sdk/blob/a8bfb132c5f7b9555d13ea79eaf0eaa77825824d/sdk/lib/core/iterable.dart#L92"><span class="material-symbols-outlined">description</span></a></div> <h1><span class="kind-class">Iterable&lt;<wbr><span class="type-parameter">E</span>&gt;</span> class <a href="https://dart.dev/language/class-modifiers#abstract" class="feature feature-abstract" title="This type can not be directly constructed.">abstract</a> <a href="https://dart.dev/language/mixins" class="feature feature-mixin" title="This class can be used as a class and a mixin.">mixin</a> </h1></div> <section class="desc markdown"> <p>A collection of values, or "elements", that can be accessed sequentially.</p> <p>The elements of the iterable are accessed by getting an <a href="../dart-core/Iterator-class.html">Iterator</a> using the <a href="../dart-core/Iterable/iterator.html">iterator</a> getter, and using it to step through the values. Stepping with the iterator is done by calling <a href="../dart-core/Iterator/moveNext.html">Iterator.moveNext</a>, and if the call returns <code>true</code>, the iterator has now moved to the next element, which is then available as <a href="../dart-core/Iterator/current.html">Iterator.current</a>. If the call returns <code>false</code>, there are no more elements. The <a href="../dart-core/Iterator/current.html">Iterator.current</a> value must only be used when the most recent call to <a href="../dart-core/Iterator/moveNext.html">Iterator.moveNext</a> has returned <code>true</code>. If it is used before calling <a href="../dart-core/Iterator/moveNext.html">Iterator.moveNext</a> the first time on an iterator, or after a call has returned false or has thrown an error, reading <a href="../dart-core/Iterator/current.html">Iterator.current</a> may throw or may return an arbitrary value.</p> <p>You can create more than one iterator from the same <code>Iterable</code>. Each time <code>iterator</code> is read, it returns a new iterator, and different iterators can be stepped through independently, each giving access to all the elements of the iterable. The iterators of the same iterable <em>should</em> provide the same values in the same order (unless the underlying collection is modified between the iterations, which some collections allow).</p> <p>You can also iterate over the elements of an <code>Iterable</code> using the for-in loop construct, which uses the <code>iterator</code> getter behind the scenes. For example, you can iterate over all of the keys of a <a href="../dart-core/Map-class.html">Map</a>, because <code>Map</code> keys are iterable.</p> <pre class="language-dart"><code class="language-dart">var kidsBooks = {'Matilda': 'Roald Dahl', 'Green Eggs and Ham': 'Dr Seuss', 'Where the Wild Things Are': 'Maurice Sendak'}; for (var book in kidsBooks.keys) { print('$book was written by ${kidsBooks[book]}'); } </code></pre> <p>The <a href="../dart-core/List-class.html">List</a> and <a href="../dart-core/Set-class.html">Set</a> classes are both <code>Iterable</code>, as are most classes in the <code>dart:collection</code> library.</p> <p>Some <a href="../dart-core/Iterable-class.html">Iterable</a> collections can be modified. Adding an element to a <code>List</code> or <code>Set</code> will change which elements it contains, and adding a new key to a <code>Map</code> changes the elements of <a href="../dart-core/Map/keys.html">Map.keys</a>. Iterators created after the change will provide the new elements, and may or may not preserve the order of existing elements (for example, a <a href="../dart-collection/HashSet-class.html">HashSet</a> may completely change its order when a single element is added).</p> <p>Changing a collection <em>while</em> it is being iterated is generally <em>not</em> allowed. Doing so will break the iteration, which is typically signalled by throwing a <a href="../dart-core/ConcurrentModificationError-class.html">ConcurrentModificationError</a> the next time <a href="../dart-core/Iterator/moveNext.html">Iterator.moveNext</a> is called. The current value of <a href="../dart-core/Iterator/current.html">Iterator.current</a> getter should not be affected by the change in the collection, the <code>current</code> value was set by the previous call to <a href="../dart-core/Iterator/moveNext.html">Iterator.moveNext</a>.</p> <p>Some iterables compute their elements dynamically every time they are iterated, like the one returned by <a href="../dart-core/Iterable/Iterable.generate.html">Iterable.generate</a> or the iterable returned by a <code>sync*</code> generator function. If the computation doesn't depend on other objects that may change, then the generated sequence should be the same one every time it's iterated.</p> <p>The members of <code>Iterable</code>, other than <code>iterator</code> itself, work by looking at the elements of the iterable. This can be implemented by running through the <a href="../dart-core/Iterable/iterator.html">iterator</a>, but some classes may have more efficient ways of finding the result (like <a href="../dart-core/Iterable/last.html">last</a> or <a href="../dart-core/Iterable/length.html">length</a> on a <a href="../dart-core/List-class.html">List</a>, or <a href="../dart-core/Iterable/contains.html">contains</a> on a <a href="../dart-core/Set-class.html">Set</a>).</p> <p>The methods that return another <code>Iterable</code> (like <a href="../dart-core/Iterable/map.html">map</a> and <a href="../dart-core/Iterable/where.html">where</a>) are all <em>lazy</em> - they will iterate the original (as necessary) every time the returned iterable is iterated, and not before.</p> <p>Since an iterable may be iterated more than once, it's not recommended to have detectable side-effects in the iterator. For methods like <a href="../dart-core/Iterable/map.html">map</a> and <a href="../dart-core/Iterable/where.html">where</a>, the returned iterable will execute the argument function on every iteration, so those functions should also not have side effects.</p> <p>The <code>Iterable</code> declaration provides a default implementation, which can be extended or mixed in to implement the <code>Iterable</code> interface. It implements every member other than the <a href="../dart-core/Iterable/iterator.html">iterator</a> getter, using the <a href="../dart-core/Iterator-class.html">Iterator</a> provided by <a href="../dart-core/Iterable/iterator.html">iterator</a>. An implementation of the <code>Iterable</code> interface should provide a more efficient implementation of the members of <code>Iterable</code> when it can do so.</p> </section> <section> <dl class="dl-horizontal"> <dt>Implementers</dt> <dd><ul class="comma-separated clazz-relationships"> <li><a href="../dart-collection/DoubleLinkedQueue-class.html">DoubleLinkedQueue</a></li> <li><a href="../dart-collection/LinkedList-class.html">LinkedList</a></li> <li><a href="../dart-core/List-class.html">List</a></li> <li><a href="../dart-collection/ListQueue-class.html">ListQueue</a></li> <li><a href="../dart-collection/Queue-class.html">Queue</a></li> <li><a href="../dart-core/Runes-class.html">Runes</a></li> <li><a href="../dart-core/Set-class.html">Set</a></li> <li><a href="../dart-collection/SplayTreeSet-class.html">SplayTreeSet</a></li> </ul></dd> <dt>Available extensions</dt> <dd><ul class="comma-separated clazz-relationships"> <li><a href="../dart-core/EnumByName.html">EnumByName</a></li> <li><a href="../dart-async/FutureIterable.html">FutureIterable</a></li> <li><a href="../dart-collection/IterableExtensions.html">IterableExtensions</a></li> <li><a href="../dart-collection/NullableIterableExtensions.html">NullableIterableExtensions</a></li> </ul></dd> </dl> </section> <section class="summary offset-anchor" id="constructors"> <h2>Constructors</h2> <dl class="constructor-summary-list"> <dt id="Iterable" class="callable"> <span class="name"><a href="../dart-core/Iterable/Iterable.html">Iterable</a></span><span class="signature">()</span> </dt> <dd> <div class="constructor-modifier features">const</div> </dd> <dt id="Iterable.empty" class="callable"> <span class="name"><a href="../dart-core/Iterable/Iterable.empty.html">Iterable.empty</a></span><span class="signature">()</span> </dt> <dd> Creates an empty iterable. <div class="constructor-modifier features">const</div> <div class="constructor-modifier features">factory</div> </dd> <dt id="Iterable.generate" class="callable"> <span class="name"><a href="../dart-core/Iterable/Iterable.generate.html">Iterable.generate</a></span><span class="signature">(<span class="parameter" id="generate-param-count"><span class="type-annotation"><a href="../dart-core/int-class.html">int</a></span> <span class="parameter-name">count</span>, [</span><span class="parameter" id="generate-param-generator"><span class="type-annotation">E</span> <span class="parameter-name">generator</span>(<span class="parameter" id="generator-param-index"><span class="type-annotation"><a href="../dart-core/int-class.html">int</a></span> <span class="parameter-name">index</span></span>)?</span>])</span> </dt> <dd> Creates an <code>Iterable</code> which generates its elements dynamically. <div class="constructor-modifier features">factory</div> </dd> </dl> </section> <section class="summary offset-anchor" id="instance-properties"> <h2>Properties</h2> <dl class="properties"> <dt id="first" class="property"> <span class="name"><a href="../dart-core/Iterable/first.html">first</a></span> <span class="signature">&#8594; E</span> </dt> <dd> The first element. <div class="features"><span class="feature">no setter</span></div> </dd> <dt id="firstOrNull" class="property"> <span class="name"><a href="../dart-collection/IterableExtensions/firstOrNull.html">firstOrNull</a></span> <span class="signature">&#8594; T?</span> </dt> <dd> <p class="from-extension"> <span>Available on <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span>, provided by the <a href="../dart-collection/IterableExtensions.html">IterableExtensions</a> extension</span> </p> The first element of this iterator, or <code>null</code> if the iterable is empty. <div class="features"><span class="feature">no setter</span></div> </dd> <dt id="hashCode" class="property inherited"> <span class="name"><a href="../dart-core/Object/hashCode.html">hashCode</a></span> <span class="signature">&#8594; <a href="../dart-core/int-class.html">int</a></span> </dt> <dd class="inherited"> The hash code for this object. <div class="features"><span class="feature">no setter</span><span class="feature">inherited</span></div> </dd> <dt id="indexed" class="property"> <span class="name"><a href="../dart-collection/IterableExtensions/indexed.html">indexed</a></span> <span class="signature">&#8594; <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">(<span class="field"><span class="type-annotation"><a href="../dart-core/int-class.html">int</a></span>, </span><span class="field"><span class="type-annotation">T</span></span>)</span>&gt;</span></span> </dt> <dd> <p class="from-extension"> <span>Available on <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span>, provided by the <a href="../dart-collection/IterableExtensions.html">IterableExtensions</a> extension</span> </p> Pairs of elements of the indices and elements of this iterable. <div class="features"><span class="feature">no setter</span></div> </dd> <dt id="isEmpty" class="property"> <span class="name"><a href="../dart-core/Iterable/isEmpty.html">isEmpty</a></span> <span class="signature">&#8594; <a href="../dart-core/bool-class.html">bool</a></span> </dt> <dd> Whether this collection has no elements. <div class="features"><span class="feature">no setter</span></div> </dd> <dt id="isNotEmpty" class="property"> <span class="name"><a href="../dart-core/Iterable/isNotEmpty.html">isNotEmpty</a></span> <span class="signature">&#8594; <a href="../dart-core/bool-class.html">bool</a></span> </dt> <dd> Whether this collection has at least one element. <div class="features"><span class="feature">no setter</span></div> </dd> <dt id="iterator" class="property"> <span class="name"><a href="../dart-core/Iterable/iterator.html">iterator</a></span> <span class="signature">&#8594; <a href="../dart-core/Iterator-class.html">Iterator</a><span class="signature">&lt;<wbr><span class="type-parameter">E</span>&gt;</span></span> </dt> <dd> A new <code>Iterator</code> that allows iterating the elements of this <code>Iterable</code>. <div class="features"><span class="feature">no setter</span></div> </dd> <dt id="last" class="property"> <span class="name"><a href="../dart-core/Iterable/last.html">last</a></span> <span class="signature">&#8594; E</span> </dt> <dd> The last element. <div class="features"><span class="feature">no setter</span></div> </dd> <dt id="lastOrNull" class="property"> <span class="name"><a href="../dart-collection/IterableExtensions/lastOrNull.html">lastOrNull</a></span> <span class="signature">&#8594; T?</span> </dt> <dd> <p class="from-extension"> <span>Available on <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span>, provided by the <a href="../dart-collection/IterableExtensions.html">IterableExtensions</a> extension</span> </p> The last element of this iterable, or <code>null</code> if the iterable is empty. <div class="features"><span class="feature">no setter</span></div> </dd> <dt id="length" class="property"> <span class="name"><a href="../dart-core/Iterable/length.html">length</a></span> <span class="signature">&#8594; <a href="../dart-core/int-class.html">int</a></span> </dt> <dd> The number of elements in this <a href="../dart-core/Iterable-class.html">Iterable</a>. <div class="features"><span class="feature">no setter</span></div> </dd> <dt id="nonNulls" class="property"> <span class="name"><a href="../dart-collection/NullableIterableExtensions/nonNulls.html">nonNulls</a></span> <span class="signature">&#8594; <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span></span> </dt> <dd> <p class="from-extension"> <span>Available on <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">T?</span>&gt;</span>, provided by the <a href="../dart-collection/NullableIterableExtensions.html">NullableIterableExtensions</a> extension</span> </p> The non-<code>null</code> elements of this iterable. <div class="features"><span class="feature">no setter</span></div> </dd> <dt id="runtimeType" class="property inherited"> <span class="name"><a href="../dart-core/Object/runtimeType.html">runtimeType</a></span> <span class="signature">&#8594; <a href="../dart-core/Type-class.html">Type</a></span> </dt> <dd class="inherited"> A representation of the runtime type of the object. <div class="features"><span class="feature">no setter</span><span class="feature">inherited</span></div> </dd> <dt id="single" class="property"> <span class="name"><a href="../dart-core/Iterable/single.html">single</a></span> <span class="signature">&#8594; E</span> </dt> <dd> Checks that this iterable has only one element, and returns that element. <div class="features"><span class="feature">no setter</span></div> </dd> <dt id="singleOrNull" class="property"> <span class="name"><a href="../dart-collection/IterableExtensions/singleOrNull.html">singleOrNull</a></span> <span class="signature">&#8594; T?</span> </dt> <dd> <p class="from-extension"> <span>Available on <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span>, provided by the <a href="../dart-collection/IterableExtensions.html">IterableExtensions</a> extension</span> </p> The single element of this iterator, or <code>null</code>. <div class="features"><span class="feature">no setter</span></div> </dd> <dt id="wait" class="property"> <span class="name"><a href="../dart-async/FutureIterable/wait.html">wait</a></span> <span class="signature">&#8594; <a href="../dart-async/Future-class.html">Future</a><span class="signature">&lt;<wbr><span class="type-parameter"><a href="../dart-core/List-class.html">List</a><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span></span>&gt;</span></span> </dt> <dd> <p class="from-extension"> <span>Available on <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter"><a href="../dart-async/Future-class.html">Future</a><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span></span>&gt;</span>, provided by the <a href="../dart-async/FutureIterable.html">FutureIterable</a> extension</span> </p> Waits for futures in parallel. <div class="features"><span class="feature">no setter</span></div> </dd> </dl> </section> <section class="summary offset-anchor" id="instance-methods"> <h2>Methods</h2> <dl class="callables"> <dt id="any" class="callable"> <span class="name"><a href="../dart-core/Iterable/any.html">any</a></span><span class="signature">(<wbr><span class="parameter" id="any-param-test"><span class="type-annotation"><a href="../dart-core/bool-class.html">bool</a></span> <span class="parameter-name">test</span>(<span class="parameter" id="test-param-element"><span class="type-annotation">E</span> <span class="parameter-name">element</span></span>)</span>) <span class="returntype parameter">&#8594; <a href="../dart-core/bool-class.html">bool</a></span> </span> </dt> <dd> Checks whether any element of this iterable satisfies <code>test</code>. </dd> <dt id="asNameMap" class="callable"> <span class="name"><a href="../dart-core/EnumByName/asNameMap.html">asNameMap</a></span><span class="signature">(<wbr>) <span class="returntype parameter">&#8594; <a href="../dart-core/Map-class.html">Map</a><span class="signature">&lt;<wbr><span class="type-parameter"><a href="../dart-core/String-class.html">String</a></span>, <span class="type-parameter">T</span>&gt;</span></span> </span> </dt> <dd> <p class="from-extension"> <span>Available on <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span>, provided by the <a href="../dart-core/EnumByName.html">EnumByName</a> extension</span> </p> Creates a map from the names of enum values to the values. </dd> <dt id="byName" class="callable"> <span class="name"><a href="../dart-core/EnumByName/byName.html">byName</a></span><span class="signature">(<wbr><span class="parameter" id="byName-param-name"><span class="type-annotation"><a href="../dart-core/String-class.html">String</a></span> <span class="parameter-name">name</span></span>) <span class="returntype parameter">&#8594; T</span> </span> </dt> <dd> <p class="from-extension"> <span>Available on <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span>, provided by the <a href="../dart-core/EnumByName.html">EnumByName</a> extension</span> </p> Finds the enum value in this list with name <code>name</code>. </dd> <dt id="cast" class="callable"> <span class="name"><a href="../dart-core/Iterable/cast.html">cast</a></span><span class="signature">&lt;<wbr><span class="type-parameter">R</span>&gt;</span><span class="signature">(<wbr>) <span class="returntype parameter">&#8594; <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">R</span>&gt;</span></span> </span> </dt> <dd> A view of this iterable as an iterable of <code>R</code> instances. </dd> <dt id="contains" class="callable"> <span class="name"><a href="../dart-core/Iterable/contains.html">contains</a></span><span class="signature">(<wbr><span class="parameter" id="contains-param-element"><span class="type-annotation"><a href="../dart-core/Object-class.html">Object</a>?</span> <span class="parameter-name">element</span></span>) <span class="returntype parameter">&#8594; <a href="../dart-core/bool-class.html">bool</a></span> </span> </dt> <dd> Whether the collection contains an element equal to <code>element</code>. </dd> <dt id="elementAt" class="callable"> <span class="name"><a href="../dart-core/Iterable/elementAt.html">elementAt</a></span><span class="signature">(<wbr><span class="parameter" id="elementAt-param-index"><span class="type-annotation"><a href="../dart-core/int-class.html">int</a></span> <span class="parameter-name">index</span></span>) <span class="returntype parameter">&#8594; E</span> </span> </dt> <dd> Returns the <code>index</code>th element. </dd> <dt id="elementAtOrNull" class="callable"> <span class="name"><a href="../dart-collection/IterableExtensions/elementAtOrNull.html">elementAtOrNull</a></span><span class="signature">(<wbr><span class="parameter" id="elementAtOrNull-param-index"><span class="type-annotation"><a href="../dart-core/int-class.html">int</a></span> <span class="parameter-name">index</span></span>) <span class="returntype parameter">&#8594; T?</span> </span> </dt> <dd> <p class="from-extension"> <span>Available on <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span>, provided by the <a href="../dart-collection/IterableExtensions.html">IterableExtensions</a> extension</span> </p> The element at position <code>index</code> of this iterable, or <code>null</code>. </dd> <dt id="every" class="callable"> <span class="name"><a href="../dart-core/Iterable/every.html">every</a></span><span class="signature">(<wbr><span class="parameter" id="every-param-test"><span class="type-annotation"><a href="../dart-core/bool-class.html">bool</a></span> <span class="parameter-name">test</span>(<span class="parameter" id="test-param-element"><span class="type-annotation">E</span> <span class="parameter-name">element</span></span>)</span>) <span class="returntype parameter">&#8594; <a href="../dart-core/bool-class.html">bool</a></span> </span> </dt> <dd> Checks whether every element of this iterable satisfies <code>test</code>. </dd> <dt id="expand" class="callable"> <span class="name"><a href="../dart-core/Iterable/expand.html">expand</a></span><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span><span class="signature">(<wbr><span class="parameter" id="expand-param-toElements"><span class="type-annotation"><a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span></span> <span class="parameter-name">toElements</span>(<span class="parameter" id="toElements-param-element"><span class="type-annotation">E</span> <span class="parameter-name">element</span></span>)</span>) <span class="returntype parameter">&#8594; <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span></span> </span> </dt> <dd> Expands each element of this <a href="../dart-core/Iterable-class.html">Iterable</a> into zero or more elements. </dd> <dt id="firstWhere" class="callable"> <span class="name"><a href="../dart-core/Iterable/firstWhere.html">firstWhere</a></span><span class="signature">(<wbr><span class="parameter" id="firstWhere-param-test"><span class="type-annotation"><a href="../dart-core/bool-class.html">bool</a></span> <span class="parameter-name">test</span>(<span class="parameter" id="test-param-element"><span class="type-annotation">E</span> <span class="parameter-name">element</span></span>), {</span><span class="parameter" id="firstWhere-param-orElse"><span class="type-annotation">E</span> <span class="parameter-name">orElse</span>()?</span>}) <span class="returntype parameter">&#8594; E</span> </span> </dt> <dd> The first element that satisfies the given predicate <code>test</code>. </dd> <dt id="fold" class="callable"> <span class="name"><a href="../dart-core/Iterable/fold.html">fold</a></span><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span><span class="signature">(<wbr><span class="parameter" id="fold-param-initialValue"><span class="type-annotation">T</span> <span class="parameter-name">initialValue</span>, </span><span class="parameter" id="fold-param-combine"><span class="type-annotation">T</span> <span class="parameter-name">combine</span>(<span class="parameter" id="combine-param-previousValue"><span class="type-annotation">T</span> <span class="parameter-name">previousValue</span>, </span><span class="parameter" id="combine-param-element"><span class="type-annotation">E</span> <span class="parameter-name">element</span></span>)</span>) <span class="returntype parameter">&#8594; T</span> </span> </dt> <dd> Reduces a collection to a single value by iteratively combining each element of the collection with an existing value </dd> <dt id="followedBy" class="callable"> <span class="name"><a href="../dart-core/Iterable/followedBy.html">followedBy</a></span><span class="signature">(<wbr><span class="parameter" id="followedBy-param-other"><span class="type-annotation"><a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">E</span>&gt;</span></span> <span class="parameter-name">other</span></span>) <span class="returntype parameter">&#8594; <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">E</span>&gt;</span></span> </span> </dt> <dd> Creates the lazy concatenation of this iterable and <code>other</code>. </dd> <dt id="forEach" class="callable"> <span class="name"><a href="../dart-core/Iterable/forEach.html">forEach</a></span><span class="signature">(<wbr><span class="parameter" id="forEach-param-action"><span class="type-annotation">void</span> <span class="parameter-name">action</span>(<span class="parameter" id="action-param-element"><span class="type-annotation">E</span> <span class="parameter-name">element</span></span>)</span>) <span class="returntype parameter">&#8594; void</span> </span> </dt> <dd> Invokes <code>action</code> on each element of this iterable in iteration order. </dd> <dt id="join" class="callable"> <span class="name"><a href="../dart-core/Iterable/join.html">join</a></span><span class="signature">(<wbr>[<span class="parameter" id="join-param-separator"><span class="type-annotation"><a href="../dart-core/String-class.html">String</a></span> <span class="parameter-name">separator</span> = <span class="default-value">&quot;&quot;</span></span>]) <span class="returntype parameter">&#8594; <a href="../dart-core/String-class.html">String</a></span> </span> </dt> <dd> Converts each element to a <a href="../dart-core/String-class.html">String</a> and concatenates the strings. </dd> <dt id="lastWhere" class="callable"> <span class="name"><a href="../dart-core/Iterable/lastWhere.html">lastWhere</a></span><span class="signature">(<wbr><span class="parameter" id="lastWhere-param-test"><span class="type-annotation"><a href="../dart-core/bool-class.html">bool</a></span> <span class="parameter-name">test</span>(<span class="parameter" id="test-param-element"><span class="type-annotation">E</span> <span class="parameter-name">element</span></span>), {</span><span class="parameter" id="lastWhere-param-orElse"><span class="type-annotation">E</span> <span class="parameter-name">orElse</span>()?</span>}) <span class="returntype parameter">&#8594; E</span> </span> </dt> <dd> The last element that satisfies the given predicate <code>test</code>. </dd> <dt id="map" class="callable"> <span class="name"><a href="../dart-core/Iterable/map.html">map</a></span><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span><span class="signature">(<wbr><span class="parameter" id="map-param-toElement"><span class="type-annotation">T</span> <span class="parameter-name">toElement</span>(<span class="parameter" id="toElement-param-e"><span class="type-annotation">E</span> <span class="parameter-name">e</span></span>)</span>) <span class="returntype parameter">&#8594; <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span></span> </span> </dt> <dd> The current elements of this iterable modified by <code>toElement</code>. </dd> <dt id="noSuchMethod" class="callable inherited"> <span class="name"><a href="../dart-core/Object/noSuchMethod.html">noSuchMethod</a></span><span class="signature">(<wbr><span class="parameter" id="noSuchMethod-param-invocation"><span class="type-annotation"><a href="../dart-core/Invocation-class.html">Invocation</a></span> <span class="parameter-name">invocation</span></span>) <span class="returntype parameter">&#8594; dynamic</span> </span> </dt> <dd class="inherited"> Invoked when a nonexistent method or property is accessed. <div class="features"><span class="feature">inherited</span></div> </dd> <dt id="reduce" class="callable"> <span class="name"><a href="../dart-core/Iterable/reduce.html">reduce</a></span><span class="signature">(<wbr><span class="parameter" id="reduce-param-combine"><span class="type-annotation">E</span> <span class="parameter-name">combine</span>(<span class="parameter" id="combine-param-value"><span class="type-annotation">E</span> <span class="parameter-name">value</span>, </span><span class="parameter" id="combine-param-element"><span class="type-annotation">E</span> <span class="parameter-name">element</span></span>)</span>) <span class="returntype parameter">&#8594; E</span> </span> </dt> <dd> Reduces a collection to a single value by iteratively combining elements of the collection using the provided function. </dd> <dt id="singleWhere" class="callable"> <span class="name"><a href="../dart-core/Iterable/singleWhere.html">singleWhere</a></span><span class="signature">(<wbr><span class="parameter" id="singleWhere-param-test"><span class="type-annotation"><a href="../dart-core/bool-class.html">bool</a></span> <span class="parameter-name">test</span>(<span class="parameter" id="test-param-element"><span class="type-annotation">E</span> <span class="parameter-name">element</span></span>), {</span><span class="parameter" id="singleWhere-param-orElse"><span class="type-annotation">E</span> <span class="parameter-name">orElse</span>()?</span>}) <span class="returntype parameter">&#8594; E</span> </span> </dt> <dd> The single element that satisfies <code>test</code>. </dd> <dt id="skip" class="callable"> <span class="name"><a href="../dart-core/Iterable/skip.html">skip</a></span><span class="signature">(<wbr><span class="parameter" id="skip-param-count"><span class="type-annotation"><a href="../dart-core/int-class.html">int</a></span> <span class="parameter-name">count</span></span>) <span class="returntype parameter">&#8594; <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">E</span>&gt;</span></span> </span> </dt> <dd> Creates an <a href="../dart-core/Iterable-class.html">Iterable</a> that provides all but the first <code>count</code> elements. </dd> <dt id="skipWhile" class="callable"> <span class="name"><a href="../dart-core/Iterable/skipWhile.html">skipWhile</a></span><span class="signature">(<wbr><span class="parameter" id="skipWhile-param-test"><span class="type-annotation"><a href="../dart-core/bool-class.html">bool</a></span> <span class="parameter-name">test</span>(<span class="parameter" id="test-param-value"><span class="type-annotation">E</span> <span class="parameter-name">value</span></span>)</span>) <span class="returntype parameter">&#8594; <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">E</span>&gt;</span></span> </span> </dt> <dd> Creates an <code>Iterable</code> that skips leading elements while <code>test</code> is satisfied. </dd> <dt id="take" class="callable"> <span class="name"><a href="../dart-core/Iterable/take.html">take</a></span><span class="signature">(<wbr><span class="parameter" id="take-param-count"><span class="type-annotation"><a href="../dart-core/int-class.html">int</a></span> <span class="parameter-name">count</span></span>) <span class="returntype parameter">&#8594; <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">E</span>&gt;</span></span> </span> </dt> <dd> Creates a lazy iterable of the <code>count</code> first elements of this iterable. </dd> <dt id="takeWhile" class="callable"> <span class="name"><a href="../dart-core/Iterable/takeWhile.html">takeWhile</a></span><span class="signature">(<wbr><span class="parameter" id="takeWhile-param-test"><span class="type-annotation"><a href="../dart-core/bool-class.html">bool</a></span> <span class="parameter-name">test</span>(<span class="parameter" id="test-param-value"><span class="type-annotation">E</span> <span class="parameter-name">value</span></span>)</span>) <span class="returntype parameter">&#8594; <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">E</span>&gt;</span></span> </span> </dt> <dd> Creates a lazy iterable of the leading elements satisfying <code>test</code>. </dd> <dt id="toList" class="callable"> <span class="name"><a href="../dart-core/Iterable/toList.html">toList</a></span><span class="signature">(<wbr>{<span class="parameter" id="toList-param-growable"><span class="type-annotation"><a href="../dart-core/bool-class.html">bool</a></span> <span class="parameter-name">growable</span> = <span class="default-value">true</span></span>}) <span class="returntype parameter">&#8594; <a href="../dart-core/List-class.html">List</a><span class="signature">&lt;<wbr><span class="type-parameter">E</span>&gt;</span></span> </span> </dt> <dd> Creates a <a href="../dart-core/List-class.html">List</a> containing the elements of this <a href="../dart-core/Iterable-class.html">Iterable</a>. </dd> <dt id="toSet" class="callable"> <span class="name"><a href="../dart-core/Iterable/toSet.html">toSet</a></span><span class="signature">(<wbr>) <span class="returntype parameter">&#8594; <a href="../dart-core/Set-class.html">Set</a><span class="signature">&lt;<wbr><span class="type-parameter">E</span>&gt;</span></span> </span> </dt> <dd> Creates a <a href="../dart-core/Set-class.html">Set</a> containing the same elements as this iterable. </dd> <dt id="toString" class="callable"> <span class="name"><a href="../dart-core/Iterable/toString.html">toString</a></span><span class="signature">(<wbr>) <span class="returntype parameter">&#8594; <a href="../dart-core/String-class.html">String</a></span> </span> </dt> <dd> Returns a string representation of (some of) the elements of <code>this</code>. <div class="features"><span class="feature">override</span></div> </dd> <dt id="where" class="callable"> <span class="name"><a href="../dart-core/Iterable/where.html">where</a></span><span class="signature">(<wbr><span class="parameter" id="where-param-test"><span class="type-annotation"><a href="../dart-core/bool-class.html">bool</a></span> <span class="parameter-name">test</span>(<span class="parameter" id="test-param-element"><span class="type-annotation">E</span> <span class="parameter-name">element</span></span>)</span>) <span class="returntype parameter">&#8594; <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">E</span>&gt;</span></span> </span> </dt> <dd> Creates a new lazy <a href="../dart-core/Iterable-class.html">Iterable</a> with all elements that satisfy the predicate <code>test</code>. </dd> <dt id="whereType" class="callable"> <span class="name"><a href="../dart-core/Iterable/whereType.html">whereType</a></span><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span><span class="signature">(<wbr>) <span class="returntype parameter">&#8594; <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span></span> </span> </dt> <dd> Creates a new lazy <a href="../dart-core/Iterable-class.html">Iterable</a> with all elements that have type <code>T</code>. </dd> </dl> </section> <section class="summary offset-anchor inherited" id="operators"> <h2>Operators</h2> <dl class="callables"> <dt id="operator ==" class="callable inherited"> <span class="name"><a href="../dart-core/Object/operator_equals.html">operator ==</a></span><span class="signature">(<wbr><span class="parameter" id="==-param-other"><span class="type-annotation"><a href="../dart-core/Object-class.html">Object</a></span> <span class="parameter-name">other</span></span>) <span class="returntype parameter">&#8594; <a href="../dart-core/bool-class.html">bool</a></span> </span> </dt> <dd class="inherited"> The equality operator. <div class="features"><span class="feature">inherited</span></div> </dd> </dl> </section> <section class="summary offset-anchor" id="static-methods"> <h2>Static Methods</h2> <dl class="callables"> <dt id="castFrom" class="callable"> <span class="name"><a href="../dart-core/Iterable/castFrom.html">castFrom</a></span><span class="signature">&lt;<wbr><span class="type-parameter">S</span>, <span class="type-parameter">T</span>&gt;</span><span class="signature">(<wbr><span class="parameter" id="castFrom-param-source"><span class="type-annotation"><a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">S</span>&gt;</span></span> <span class="parameter-name">source</span></span>) <span class="returntype parameter">&#8594; <a href="../dart-core/Iterable-class.html">Iterable</a><span class="signature">&lt;<wbr><span class="type-parameter">T</span>&gt;</span></span> </span> </dt> <dd> Adapts <code>source</code> to be an <code>Iterable&lt;T&gt;</code>. </dd> <dt id="iterableToFullString" class="callable"> <span class="name"><a href="../dart-core/Iterable/iterableToFullString.html">iterableToFullString</a></span><span class="signature">(<wbr><span class="parameter" id="iterableToFullString-param-iterable"><span class="type-annotation"><a href="../dart-core/Iterable-class.html">Iterable</a></span> <span class="parameter-name">iterable</span>, [</span><span class="parameter" id="iterableToFullString-param-leftDelimiter"><span class="type-annotation"><a href="../dart-core/String-class.html">String</a></span> <span class="parameter-name">leftDelimiter</span> = <span class="default-value">&#39;(&#39;</span>, </span><span class="parameter" id="iterableToFullString-param-rightDelimiter"><span class="type-annotation"><a href="../dart-core/String-class.html">String</a></span> <span class="parameter-name">rightDelimiter</span> = <span class="default-value">&#39;)&#39;</span></span>]) <span class="returntype parameter">&#8594; <a href="../dart-core/String-class.html">String</a></span> </span> </dt> <dd> Converts an <code>Iterable</code> to a string. </dd> <dt id="iterableToShortString" class="callable"> <span class="name"><a href="../dart-core/Iterable/iterableToShortString.html">iterableToShortString</a></span><span class="signature">(<wbr><span class="parameter" id="iterableToShortString-param-iterable"><span class="type-annotation"><a href="../dart-core/Iterable-class.html">Iterable</a></span> <span class="parameter-name">iterable</span>, [</span><span class="parameter" id="iterableToShortString-param-leftDelimiter"><span class="type-annotation"><a href="../dart-core/String-class.html">String</a></span> <span class="parameter-name">leftDelimiter</span> = <span class="default-value">&#39;(&#39;</span>, </span><span class="parameter" id="iterableToShortString-param-rightDelimiter"><span class="type-annotation"><a href="../dart-core/String-class.html">String</a></span> <span class="parameter-name">rightDelimiter</span> = <span class="default-value">&#39;)&#39;</span></span>]) <span class="returntype parameter">&#8594; <a href="../dart-core/String-class.html">String</a></span> </span> </dt> <dd> Convert an <code>Iterable</code> to a string like <a href="../dart-core/Iterable/toString.html">Iterable.toString</a>. </dd> </dl> </section> </div> <!-- /.main-content --> <div id="dartdoc-sidebar-left" class="sidebar sidebar-offcanvas-left"> <!-- The search input and breadcrumbs below are only responsively visible at low resolutions. --> <header id="header-search-sidebar" class="hidden-l"> <form class="search-sidebar" role="search"> <input type="text" id="search-sidebar" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search..."> </form> </header> <ol class="breadcrumbs gt-separated dark hidden-l" id="sidebar-nav"> <li><a href="../index.html">Dart</a></li> <li><a href="../dart-core">dart:core</a></li> <li class="self-crumb">Iterable<span class="signature">&lt;<wbr><span class="type-parameter">E</span>&gt;</span> class</li> </ol> <h5>dart:core library</h5> <div id="dartdoc-sidebar-left-content"></div> </div> <div id="dartdoc-sidebar-right" class="sidebar sidebar-offcanvas-right"> </div><!--/.sidebar-offcanvas--> </main> <footer> <span class="no-break"> Dart 3.7.0 </span> <span class="glue-footer"> <span class="no-break"> | <a href="https://dart.dev/terms" title="Terms of use">Terms</a> </span> <span class="no-break"> | <a href="https://policies.google.com/privacy" target="_blank" rel="noopener" title="Privacy policy" class="no-automatic-external">Privacy</a> </span> <span class="no-break"> | <a href="https://dart.dev/security" title="Security philosophy and practices">Security</a> </span> <div class="copyright" style="font-size: 0.9em; color: darkgrey; margin-top: 0.5em;"> Except as otherwise noted, this site is licensed under a <a style="color: darkgrey;" href="https://creativecommons.org/licenses/by/4.0/"> Creative Commons Attribution 4.0 International License</a> and code samples are licensed under the <a style="color: darkgrey;" href="https://opensource.org/licenses/BSD-3-Clause" class="no-automatic-external"> 3-Clause BSD License</a> </div> </span> </footer> <script src="../static-assets/highlight.pack.js?v1"></script> <script src="../static-assets/docs.dart.js"></script> <button aria-hidden="true" class="glue-footer__link glue-cookie-notification-bar-control"> Cookies management controls </button> <script src="https://www.gstatic.com/glue/cookienotificationbar/cookienotificationbar.min.js" data-glue-cookie-notification-bar-category="2B"> </script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10