You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import'package:flutter/material.dart';
import'dart:async';
import'package:flutter/services.dart';
import'package:platform_device_id/platform_device_id.dart';
voidmain() {
runApp(MyApp());
}
classMyAppextendsStatefulWidget {
@override_MyAppStatecreateState() =>_MyAppState();
}
class_MyAppStateextendsState<MyApp> {
String _deviceId ='Unknown';
@overridevoidinitState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.Future<void> initPlatformState() async {
String deviceId;
// Platform messages may fail, so we use a try/catch PlatformException.try {
deviceId =awaitPlatformDeviceId.getDeviceId;
} onPlatformException {
deviceId ='Failed to get deviceId.';
}
// If the widget was removed from the tree while the asynchronous platform// message was in flight, we want to discard the reply rather than calling// setState to update our non-existent appearance.if (!mounted) return;
setState(() {
_deviceId = deviceId;
print("deviceId->$_deviceId");
});
}
@overrideWidgetbuild(BuildContext context) {
returnMaterialApp(
home:Scaffold(
appBar:AppBar(
title:constText('Plugin example app'),
),
body:Center(
child:Text('Device ID : $_deviceId'),
),
),
);
}
}
please I am a beginner I don't understand how to use this plugin. can you please put me through
The text was updated successfully, but these errors were encountered: