Using plugins and channels from background isolates

Plugins and channels can be used by any Isolate, but that Isolate has to be
a root Isolate (the one created by Flutter) or registered as a background
Isolate for a root Isolate.

The following example shows how to register a background Isolate in order to
use a plugin from a background Isolate.

import

'package:flutter/services.dart'

import

'package:shared_preferences/shared_preferences.dart'

void

_isolateMain

RootIsolateToken

rootIsolateToken

async

BackgroundIsolateBinaryMessenger

ensureInitialized

rootIsolateToken

);

SharedPreferences

sharedPreferences

await

SharedPreferences

getInstance