<h1 dir="auto">Context and Rationale</h1>
<p dir="auto">At the moment, <code class="notranslate">flutter create --template=plugin</code> (<a href="https://flutter.io/docs/development/packages-and-plugins/developing-packages#step-1-create-the-package-1" rel="nofollow">ref</a>) defaults to Objective C and Java. It is my suggestion that the we switch the default to Swift and Kotlin respectively instead.</p>
<p dir="auto">Kotlin is first-class language supported by Android, and officially preferred by Android rather than Java (<a href="https://developer.android.com/kotlin/" rel="nofollow">ref</a>) even if Kotlin adds a little bit overhead (<a href="https://developer.android.com/kotlin/faq" rel="nofollow">ref</a>)</p>
<p dir="auto">When it comes to Swift, the case is even stronger. While Kotlin is officially endorsed and preferred by Android team, it's still developed by another entity, JetBrain. Meanwhile, Swift is developed by Apple specifically for iOS, macOS and tvOS development. In the first quarter of 2018 Swift surpassed Objective-C in measured popularity (<a href="https://redmonk.com/sogrady/2018/03/07/language-rankings-1-18/" rel="nofollow">ref</a>). The runtime overhead will no longer be an issue for Swift 5, according to wwdc 2018</p>
<blockquote>
<p dir="auto">And we also have another release coming up for you in the language, Swift 5. The focus of Swift 5 is greater adoption by delivering Swift as part of the OS. Apps will no longer need to include the Swift runtime when delivering on our newer OS releases, resulting in smaller downloads and faster launches. We're very excited about this, too, and we have made great progress toward this goal. And you'll see it in a release coming early next year.</p>
</blockquote>
<h1 dir="auto">Proposed actions</h1>
<ul dir="auto">
<li>Change <a href="https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/commands/create.dart">https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/commands/create.dart</a> to switch the default language to Swift and Kotlin.
<ul dir="auto">
<li>Change <a href="https://github.com/flutter/flutter-intellij">https://github.com/flutter/flutter-intellij</a> accordingly <a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/358585/50044829-24a2a000-00bc-11e9-9495-bfe80f3637e2.png"><img width="665" alt="screen shot 2018-12-15 at 10 51 52 pm" src="https://user-images.githubusercontent.com/358585/50044829-24a2a000-00bc-11e9-9495-bfe80f3637e2.png" style="max-width: 100%;"></a></li>
</ul>
</li>
<li>Convert all "first-party" plugins <a href="https://github.com/flutter/plugins">https://github.com/flutter/plugins</a> to Swift and Kotlin.
<ul dir="auto">
<li>Write platform unit test in Swift (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="229396990" data-permission-text="Title is private" data-url="https://github.com/flutter/flutter/issues/10141" data-hovercard-type="issue" data-hovercard-url="/flutter/flutter/issues/10141/hovercard" href="https://github.com/flutter/flutter/issues/10141">#10141</a>) and Kotlin (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="229395387" data-permission-text="Title is private" data-url="https://github.com/flutter/flutter/issues/10140" data-hovercard-type="issue" data-hovercard-url="/flutter/flutter/issues/10140/hovercard" href="https://github.com/flutter/flutter/issues/10140">#10140</a>)</li>
</ul>
</li>
</ul>
<p dir="auto">UI nodes require a unique key for arrays of homogeneous children. They key is nominally Object but internally it seems to be converted to String. This causes the surprising behavior that custom objects are rejected as keys:</p>
<p dir="auto">[0612/154234:ERROR:dart_error.cc(20)] Unhandled exception:<br>
Uncaught Error: If multiple non-interchangeable nodes of the same type exist as children<br>
of another node, they must have unique keys.<br>
Duplicate: </p>
<p dir="auto">The current workaround is to add a custom .toString() method to any custom class used as key</p>
<p dir="auto">For example</p>
<p dir="auto">class Cell {<br>
final int posX;<br>
final int posY;<br>
Cell(this.posX, this.posY);<br>
String toString() =&gt; 'Cell($posX, $posY)';<br>
}</p>
<p dir="auto">without the toString() method, it cannot be used as a key.</p>