Flutter plugin that exposes a single GetMacAddress().getMacAddress() API for retrieving the primary network interface's MAC address on desktop platforms, while providing graceful fallbacks on mobile and web targets.
| Platform | Support | Notes |
|---|---|---|
| Windows | ✅ Real MAC via GetAdaptersInfo |
Requires Visual Studio + CMake 3.14+. v0.0.3 fixes corrupted UTF-8 responses that triggered FormatException reports.1 |
| Linux | ✅ Real MAC via ioctl(SIOCGIFHWADDR) |
Works once the Flutter project is created with --platforms=linux and system packages build-essential cmake pkg-config are installed. Missing CMakeLists.txt errors from issue reporters are resolved after republishing v0.0.3.2 |
| macOS | ✅ Real MAC via IOKit | |
| Android | Attempts real hardware interfaces first, then Wi‑Fi info (requires ACCESS_WIFI_STATE + location permissions), and finally hashes ANDROID_ID into a deterministic pseudo-MAC before falling back to the placeholder.345 |
|
| iOS | Derives a deterministic pseudo-MAC from identifierForVendor; returns the placeholder only when unavailable. |
|
| Web | Generates a random pseudo-MAC once and persists it via localStorage so it stays stable per browser profile.6 |
flutter pub add get_mac_addressUse the API from Dart:
final plugin = GetMacAddress();
final mac = await plugin.getMacAddress() ?? 'Unknown';
if (mac == '02:00:00:00:00:00') {
// Platform privacy restrictions prevented access.
}- Linux:
sudo apt install build-essential cmake pkg-config libgtk-3-dev. - Windows: Install the Desktop workload in Visual Studio 2019+ and enable
flutter config --enable-windows-desktop.
If you still see does not contain a CMakeLists.txt file, wipe linux/flutter/ephemeral (or windows/flutter/ephemeral) so Flutter regenerates its plugin symlinks, or upgrade to v0.0.3 where the files ship with the published package.27
- Android: Declare
ACCESS_WIFI_STATE,ACCESS_NETWORK_STATE,ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION, and on Android 13+NEARBY_WIFI_DEVICES. The plugin uses whatever permissions are granted to attemptNetworkInterface→WifiManager→ hashedANDROID_IDbefore falling back to00:00:00:00:00:00. - iOS: No extra entitlement is required. The plugin hashes
UIDevice.current.identifierForVendorto offer a stable surrogate identifier. - Web: No browser exposes the NIC MAC. We mint a random ID (6 bytes) and cache it inside
localStorageso the result remains stable per profile.
- Android and iOS may still return the placeholder when every fallback source (hardware interface, Wi‑Fi info, vendor/device identifiers) is blocked by system policy or permissions.345
- Flutter web has no API for low-level network identifiers.6
Run the bundled example on a supported desktop target:
cd example
flutter run -d linuxIf you work on Windows, run flutter doctor --android-licenses and flutter config --enable-windows-desktop first, as missing toolchains caused the build failures described in the open issues.7