Does flutter have some code or additional package to get MAC address of the device?
You can Easily get Mac Address in flutter Using the get_mac Package. It supports IOS and Android. Import in Your Dart File Where you want to get Mac Address.
then Refer to this Example-:
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get_mac/get_mac.dart';
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
String _platformID = 'Unknown';
@override
void initState() {
super.initState();
initPlatformState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
"images/logo.png",
height: 250.0,
width: 250.0,
),
Text(_platformID)
],
),
),
);
}
Future<void> initPlatformState() async {
String platformVersion;
try {
platformVersion = await GetMac.macAddress;
} on PlatformException {
platformVersion = 'Failed to get Device MAC Address.';
}
print("MAC-: " + platformVersion);
if (!mounted) return;
setState(() {
_platformID = platformVersion;
});
}
}
i used this package wifi_info_plugin and can get macadrress
Flutter can only do as much as what the underlying OS can, since iOS 7 and Android 6, you will always get the same response 02:00:00:00:00:00
, this has been made by Apple and Google for privacy concerns.
Quote Apple
In iOS 7 and later, if you ask for the MAC address of an iOS device, the system returns the value 02:00:00:00:00:00. If you need to identify the device, use the identifierForVendor property of UIDevice instead. (Apps that need an identifier for their own advertising purposes should consider using the advertisingIdentifier property of ASIdentifierManager instead.)
Quote Google
To provide users with greater data protection, starting in this release, Android removes programmatic access to the device’s local hardware identifier for apps using the Wi-Fi and Bluetooth APIs. The WifiInfo.getMacAddress() and the BluetoothAdapter.getAddress() methods now return a constant value of 02:00:00:00:00:00.
Long story short, no MAC address available.