<p dir="auto">I have an enhancement request to shared_preferences plugin. On occasion the native side of a Flutter app (e.g. Java side on Android) needs to access shared preferences set in Flutter, or maybe set them for Flutter side as well. It is necessary for example when communicating with other native apps on a platform.</p>
<p dir="auto">Currently what I have to do in Java to accomplish this is:</p>
<div class="highlight highlight-source-dart notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="SharedPreferences prefs = getSharedPreferences(&quot;FlutterSharedPreferences&quot;, MODE_PRIVATE);"><pre class="notranslate"><span class="pl-c1">SharedPreferences</span> prefs <span class="pl-k">=</span> <span class="pl-en">getSharedPreferences</span>(<span class="pl-s">"FlutterSharedPreferences"</span>, <span class="pl-c1">MODE_PRIVATE</span>);</pre></div>
<p dir="auto">and later when I want to read e.g. "myValue" key, I have to add "flutter." prefix:</p>
<div class="highlight highlight-source-dart notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="String value = prefs.getString(&quot;flutter.&quot;+key, null);"><pre class="notranslate"><span class="pl-c1">String</span> value <span class="pl-k">=</span> prefs.<span class="pl-en">getString</span>(<span class="pl-s">"flutter."</span><span class="pl-k">+</span>key, <span class="pl-c1">null</span>);</pre></div>
<p dir="auto">This does not feel right though, spying on package private values and using them elsewhere. A better way should be provided by the SharedPreferencesPlugin instead.</p>
<p dir="auto">Attempting to use a plugin in the context of a background isolate spawned by another plugin will cause failures when making calls over method channels. On Android, the <code class="notranslate">PluginRegistrant</code> interface is used to allow for plugins to register the application's plugins with a <code class="notranslate">FlutterNativeView</code> but no equivalent is available on iOS.</p>