Skip to content

Instantly share code, notes, and snippets.

@li9ht
Last active December 1, 2021 02:18
Show Gist options
  • Save li9ht/34eef2971a3dfd53a99819509a762bf4 to your computer and use it in GitHub Desktop.
Save li9ht/34eef2971a3dfd53a99819509a762bf4 to your computer and use it in GitHub Desktop.
class UserView extends StatefulWidget {
const UserView({Key? key}) : super(key: key);
@override
State<UserViewState> createState() => _UserViewState();
}
class _UserViewState extends State<UserViewState> {
var _token = "";
static const channelName = 'com.myflutterapp/data';
final methodChannel = MethodChannel(channelName);
initStuff() async {
_token = await methodChannel.invokeMethod('getUserToken');
setState(() {});
}
@override
void initState() {
super.initState();
initStuff();
print(_token); //
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment