<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>dart on smarx.com</title>
    <link>https://smarx.com/tags/dart/</link>
    <description>Recent content on smarx.com</description>
    <language>en-us</language>
    <managingEditor>smarx@smarx.com (Steve Marx)</managingEditor>
    <webMaster>smarx@smarx.com (Steve Marx)</webMaster>
    <lastBuildDate>Mon, 31 Aug 2020 13:03:29 -0400</lastBuildDate>
    
        <atom:link href="https://smarx.com/tags/dart/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Extension Methods in Dart: a Tale of Two Kitties</title>
      <link>https://smarx.com/posts/2020/08/extension-methods-in-dart-a-tale-of-two-kitties/</link>
      <pubDate>Mon, 31 Aug 2020 13:03:29 -0400</pubDate>
      <author>smarx@smarx.com (Steve Marx)</author>
      <guid>https://smarx.com/posts/2020/08/extension-methods-in-dart-a-tale-of-two-kitties/</guid>
      <description>&lt;p&gt;My family is fostering two adorable &lt;a href=&#34;https://www.instagram.com/zack_and_cody_foster_kittens/&#34;&gt;kittens / Instagram influencers&lt;/a&gt; named Zack and Cody. As responsible cat parents, my wife and I enforce strict bedtimes and limit the kittens&amp;rsquo; screen time.&lt;/p&gt;
&lt;p&gt;To that end, I wrote a Flutter app to play every cat&amp;rsquo;s favorite movie, &lt;a href=&#34;https://www.imdb.com/title/tt0065421/&#34;&gt;The AristoCats&lt;/a&gt;, with a sleep timer. Each night, we launch the app for the kittens and start the timer. Ten minutes later, the movie pauses, and the kittens should be asleep. (The next night we pick up where they left off.)&lt;/p&gt;
&lt;h2 id=&#34;a-mystery&#34;&gt;A mystery&lt;/h2&gt;
&lt;p&gt;Initially, this system seemed to be working fine. But after a few nights, we noticed that the kittens seemed exhausted in the morning. They also kept quoting lines from parts of the movie they shouldn&amp;rsquo;t have seen yet&amp;mdash;remember that they only watch ten minutes a night, and we&amp;rsquo;d only had the kittens for a few nights.&lt;/p&gt;
&lt;p&gt;I began to suspect something about the sleep timer wasn&amp;rsquo;t working.&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;h2 id=&#34;debugging&#34;&gt;Debugging&lt;/h2&gt;
&lt;p&gt;I knew that the kittens, particularly Zack, liked to type on my laptop, as evidenced here:&lt;/p&gt;





    




    


&lt;figure class=&#34;flex flex-col items-center&#34;&gt;
    
    &lt;a href=&#34;https://smarx.com/posts/2020/08/extension-methods-in-dart-a-tale-of-two-kitties/zack-featured-cover.jpg&#34; data-lightbox=&#34;658a829746e075d4827934e062be5eda&#34; data-title=&#34;&amp;amp;ldquo;Zack&amp;amp;rdquo; rhymes with &amp;amp;ldquo;hack&amp;amp;rdquo;&#34; &gt;
    
    &lt;img class=&#34;mx-auto&#34; src=&#34;https://smarx.com/posts/2020/08/extension-methods-in-dart-a-tale-of-two-kitties/zack-featured-cover_hu27f7dc34c9db8fd2b063f3fba6be9864_481703_384x0_resize_q75_lanczos.jpg&#34; width=&#34;384&#34; height=&#34;395&#34;&gt;
    
    &lt;/a&gt;
    
    
    &lt;figcaption&gt;
        &lt;p&gt;&amp;ldquo;Zack&amp;rdquo; rhymes with &amp;ldquo;hack&amp;rdquo;&lt;/p&gt;
    &lt;/figcaption&gt;
    
&lt;/figure&gt;

&lt;p&gt;My first thought was that the kittens had modified the app somehow to disable the sleep timer, but the video was always paused at the right timestamp in the morning. I also checked the &lt;code&gt;git&lt;/code&gt; commit history and didn&amp;rsquo;t see any recent changes.&lt;/p&gt;
&lt;p&gt;With no obvious reason for the change in sight, I settled in to read the code carefully, line by line, paying particular attention to the sleep timer code.&lt;/p&gt;
&lt;h2 id=&#34;sabotage&#34;&gt;Sabotage!&lt;/h2&gt;
&lt;p&gt;Going through the code carefully, I noticed something curious:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-dart&#34; data-lang=&#34;dart&#34;&gt;&lt;span class=&#34;nl&#34;&gt;floatingActionButton:&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;FloatingActionButton&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;
  &lt;span class=&#34;nl&#34;&gt;onPressed:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;Timer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Duration&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nl&#34;&gt;minutes:&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;10&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;),&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
      &lt;span class=&#34;n&#34;&gt;_controller&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;paws&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;
    &lt;span class=&#34;p&#34;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Did you catch it? It&amp;rsquo;s subtle, but the line that &lt;em&gt;should&lt;/em&gt; read &lt;code&gt;_controller.pause()&lt;/code&gt; actually says &lt;code&gt;_controller.paws()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It turns out the code &lt;em&gt;had&lt;/em&gt; been modified, but I&amp;rsquo;d underestimated the kittens! They apparently knew how to use &lt;code&gt;git rebase&lt;/code&gt; and &lt;code&gt;git push -f&lt;/code&gt; to rewrite commit history so I wouldn&amp;rsquo;t see their changes.&lt;/p&gt;
&lt;h2 id=&#34;extension-methods&#34;&gt;Extension methods&lt;/h2&gt;
&lt;p&gt;I was making progress, but now I was confused. &lt;a href=&#34;https://pub.dev/documentation/video_player/latest/video_player/VideoPlayerController-class.html&#34;&gt;&lt;code&gt;VideoPlayerController&lt;/code&gt;&lt;/a&gt; has no method called &lt;code&gt;paws()&lt;/code&gt;, so how was this code even compiling?&lt;/p&gt;
&lt;p&gt;It turns out Dart supports something called &amp;ldquo;&lt;a href=&#34;https://en.wikipedia.org/wiki/Extension_method&#34;&gt;extension methods&lt;/a&gt;&amp;rdquo;, which you can find in many other languages, such as C# and Java. Ruby has a particularly interesting mechanism for extension methods, where you can just reopen an existing class. I knew about this because one of our grownup cats, Kit, had written this rather sloppy&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt; extension years earlier:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span class=&#34;nb&#34;&gt;require&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;active_support/core_ext&amp;#39;&lt;/span&gt;

&lt;span class=&#34;k&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;DateTime&lt;/span&gt;
    &lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;self&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nf&#34;&gt;meow&lt;/span&gt;
        &lt;span class=&#34;c1&#34;&gt;# all times should be in Central Africa Time (CAT)&lt;/span&gt;
        &lt;span class=&#34;no&#34;&gt;Time&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;current&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;in_time_zone&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;Africa/Cairo&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
    &lt;span class=&#34;k&#34;&gt;end&lt;/span&gt;
&lt;span class=&#34;k&#34;&gt;end&lt;/span&gt;

&lt;span class=&#34;nb&#34;&gt;puts&lt;/span&gt; &lt;span class=&#34;no&#34;&gt;DateTime&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;meow&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In Python, you can just reassign things directly. Here&amp;rsquo;s a Python example from our other grownup cat, Shadow:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;humanize&lt;/span&gt;

&lt;span class=&#34;n&#34;&gt;orig&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;humanize&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;apnumber&lt;/span&gt;
&lt;span class=&#34;n&#34;&gt;humanize&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;apnumber&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;lambda&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;fur&amp;#39;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;n&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;4&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;else&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;orig&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;

&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;range&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;10&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;
    &lt;span class=&#34;k&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;humanize&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;apnumber&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;))&lt;/span&gt;

&lt;span class=&#34;c1&#34;&gt;# Output:&lt;/span&gt;
&lt;span class=&#34;c1&#34;&gt;#   zero&lt;/span&gt;
&lt;span class=&#34;c1&#34;&gt;#   one&lt;/span&gt;
&lt;span class=&#34;c1&#34;&gt;#   two&lt;/span&gt;
&lt;span class=&#34;c1&#34;&gt;#   three&lt;/span&gt;
&lt;span class=&#34;c1&#34;&gt;#   fur&lt;/span&gt;
&lt;span class=&#34;c1&#34;&gt;#   five&lt;/span&gt;
&lt;span class=&#34;c1&#34;&gt;#   six&lt;/span&gt;
&lt;span class=&#34;c1&#34;&gt;#   seven&lt;/span&gt;
&lt;span class=&#34;c1&#34;&gt;#   eight&lt;/span&gt;
&lt;span class=&#34;c1&#34;&gt;#   nine&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As you can see, this kind of runtime modification makes it hard to know exactly what code is going to run when you call a function. This technique is called &lt;a href=&#34;https://en.wikipedia.org/wiki/Monkey_patch&#34;&gt;&amp;ldquo;monkey patching&amp;rdquo; or &amp;ldquo;duck punching&amp;rdquo;&lt;/a&gt;, unpleasant terms that hopefully dissuade new programmers from abusing this dangerous language feature.&lt;/p&gt;
&lt;h2 id=&#34;so-where-is-_paws_-defined&#34;&gt;So where is &lt;em&gt;paws()&lt;/em&gt; defined?&lt;/h2&gt;
&lt;p&gt;Dart extension methods only work with static types and are resolved at compile time. That means you can&amp;rsquo;t do ugly runtime monkey patching, and a good IDE can tell you exactly where an extension method is implemented:&lt;/p&gt;





    




    


&lt;figure class=&#34;flex flex-col items-center&#34;&gt;
    
    &lt;a href=&#34;https://smarx.com/posts/2020/08/extension-methods-in-dart-a-tale-of-two-kitties/vs-code.png&#34; data-lightbox=&#34;f8fbeece0f85d84c28755243e67905b8&#34; data-title=&#34;Visual Studio Code to the rescue!&#34; &gt;
    
    &lt;img class=&#34;mx-auto&#34; src=&#34;https://smarx.com/posts/2020/08/extension-methods-in-dart-a-tale-of-two-kitties/vs-code_hua47fed6f30c575859fd9251f4c66062f_27593_728x0_resize_lanczos_2.png&#34; width=&#34;728&#34; height=&#34;109&#34;&gt;
    
    &lt;/a&gt;
    
    
    &lt;figcaption&gt;
        &lt;p&gt;Visual Studio Code to the rescue!&lt;/p&gt;
    &lt;/figcaption&gt;
    
&lt;/figure&gt;

&lt;p&gt;This explains how I had initially missed the code. It was in a file the kittens had cleverly called &lt;code&gt;thumbsAndOtherHumanStuff.dart&lt;/code&gt;, which they knew I, as a human, would find perfectly normal.&lt;/p&gt;
&lt;p&gt;Below are the contents of that file:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-dart&#34; data-lang=&#34;dart&#34;&gt;&lt;span class=&#34;k&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;dart:async&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;

&lt;span class=&#34;k&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;package:video_player/video_player.dart&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;

&lt;span class=&#34;n&#34;&gt;extension&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;TheStupidKindOfMouse&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;on&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;VideoPlayerController&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
  &lt;span class=&#34;n&#34;&gt;paws&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;k&#34;&gt;this&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;setLooping&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kc&#34;&gt;true&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;
    &lt;span class=&#34;k&#34;&gt;this&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;setVolume&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;0.1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;// humans have inferior ears
&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;
    &lt;span class=&#34;n&#34;&gt;Timer&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;this&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;value&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;duration&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;*&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
      &lt;span class=&#34;k&#34;&gt;this&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;setVolume&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;
      &lt;span class=&#34;k&#34;&gt;this&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;pause&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;
    &lt;span class=&#34;p&#34;&gt;});&lt;/span&gt;
  &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The kittens were cleverer than I had given them credit for! Instead of pausing the movie, this code loops the video and reduces the volume to 10%. After two full repeats of the video, the volume is restored to 100% and actually paused. This explains why everything looked right in the morning.&lt;/p&gt;
&lt;h2 id=&#34;teaching-those-kittens-a-lesson&#34;&gt;Teaching those kittens a lesson&lt;/h2&gt;
&lt;p&gt;My first thought was to revert the code to the way it was: &lt;code&gt;_controller.pause()&lt;/code&gt;. But the next time the kittens were using my laptop, they would surely just change it to &lt;code&gt;_controller.paws()&lt;/code&gt; again.&lt;/p&gt;
&lt;p&gt;With my newfound knowledge of extension methods, I thought of a subtler technique. What if I added my own extension method? If I rewrote the &lt;code&gt;git&lt;/code&gt; history, the kittens might not notice the change.&lt;/p&gt;
&lt;p&gt;My first attempt was to just add another extension method to &lt;code&gt;thumbsAndOtherHumanStuff.dart&lt;/code&gt;&lt;sup id=&#34;fnref:3&#34;&gt;&lt;a href=&#34;#fn:3&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-dart&#34; data-lang=&#34;dart&#34;&gt;&lt;span class=&#34;n&#34;&gt;extension&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;HeyGoToSleep&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;on&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;VideoPlayerController&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
  &lt;span class=&#34;n&#34;&gt;paws&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;k&#34;&gt;this&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;pause&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;
  &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But the compiler told me right away that this was a problem:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;A member named &amp;#39;paws&amp;#39; is defined in extensions &amp;#39;TheStupidKindOfMouse&amp;#39; and
&amp;#39;HeyGoToSleep&amp;#39; and neither is more specific.

Try using an extension override to specify the extension you want to to be
chosen.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I needed to resolve this conflict in a way that was subtle enough the kittens wouldn&amp;rsquo;t notice. The part of the error message saying &amp;ldquo;neither is more specific&amp;rdquo; was intriguing, but it didn&amp;rsquo;t end up being useful. In the case of inheritance, the &amp;ldquo;more specific&amp;rdquo; extension is the one on the more derived class. But both extensions are on &lt;code&gt;VideoPlayerController&lt;/code&gt;, so this isn&amp;rsquo;t helpful.&lt;/p&gt;
&lt;p&gt;The Dart extension method &lt;a href=&#34;https://dart.dev/guides/language/extension-methods&#34;&gt;documentation&lt;/a&gt; has a section about conflicts that described two ways to resolve them. First, you can wrap the object being extended, e.g. &lt;code&gt;HeyGoToSleep(_controller).paws()&lt;/code&gt;. I thought this would be too much of a giveaway.&lt;/p&gt;
&lt;p&gt;The other option is to make sure only one extension method is visible. I modified the &lt;code&gt;import&lt;/code&gt; line like so, to hide the kittens&amp;rsquo; extension method:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-dart&#34; data-lang=&#34;dart&#34;&gt;&lt;span class=&#34;k&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;thumbsAndOtherHumanStuff.dart&amp;#39;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;hide&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;TheStupidKindOfMouse&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It&amp;rsquo;s easy to skim past &lt;code&gt;import&lt;/code&gt; lines, so I was betting the kittens wouldn&amp;rsquo;t notice the change.&lt;/p&gt;
&lt;h2 id=&#34;success-for-now&#34;&gt;Success&amp;hellip; for now?&lt;/h2&gt;
&lt;p&gt;The kittens now seem better rested, but they&amp;rsquo;re showing increased interest in getting time on my laptop, so I&amp;rsquo;m sure it&amp;rsquo;s only a matter of time before they come up with some other clever hack. I&amp;rsquo;ll be sure to post here if it happens.&lt;/p&gt;
&lt;h2 id=&#34;summary&#34;&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Dart allows you to extend classes with static methods.&lt;/li&gt;
&lt;li&gt;These extension methods are fully resolved at compile time, so they don&amp;rsquo;t have the drawbacks of more dynamic modification in languages like Ruby and Python.&lt;/li&gt;
&lt;li&gt;If there&amp;rsquo;s ambiguity, it&amp;rsquo;s up to the developer to resolve the API conflict explicitly.&lt;/li&gt;
&lt;li&gt;Kittens are cute, but they&amp;rsquo;re also devious and not to be trusted.&lt;/li&gt;
&lt;/ul&gt;
&lt;section class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34; role=&#34;doc-endnote&#34;&gt;
&lt;p&gt;To address all the hate mail, yes, of course we made sure the app was running on a device &lt;strong&gt;outside of the cage&lt;/strong&gt; so the kittens couldn&amp;rsquo;t restart the movie themselves. &lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:2&#34; role=&#34;doc-endnote&#34;&gt;
&lt;p&gt;Sloppy because you&amp;rsquo;d expect &lt;em&gt;DateTime.meow()&lt;/em&gt; to return a &lt;em&gt;DateTime&lt;/em&gt;, but it actually doesn&amp;rsquo;t! Kit&amp;rsquo;s never been a particularly disciplined developer, and it takes a lot of discipline to write good extension methods. &lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:3&#34; role=&#34;doc-endnote&#34;&gt;
&lt;p&gt;I added lots of blank lines so they wouldn&amp;rsquo;t see. Kittens are notoriously bad at scrolling. &lt;a href=&#34;#fnref:3&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</description>
    </item>
    
  </channel>
</rss>
