[Bug]: macOS modelName returns "Unknown Model" for Mac mini (case mismatch in identifier table)

未關閉 適合新手
#4,017 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
1/5
預估耗時
1 小時以內
新手友好度
91/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
flutter, swift
領域
mobile-dev

研究方向

在 DeviceIdentifiers.swift 中,Mac mini 項目使用 "MacMini9,1" 這類識別碼,而 issue 回報 hw.model 傳回 "Macmini9,1"。閱讀查找表,並確認 switch 如何處理這些字串。完成條件是受影響的識別碼與回報中的大小寫一致,且 Mac mini 型號名稱能正確解析。

由索引模型根據 Issue 內容生成。

描述

bug triage
Platform

macOS

Plugin

device_info_plus

Version

13.3.0

Flutter SDK

3.47.5

Steps to reproduce

On a Mac mini (M1, 2020), MacOsDeviceInfo.modelName returns "Unknown Model", even though the device's identifier is in the lookup table.

hw.model reports the identifier as Macmini9,1 (lowercase "m" in "mini"). In DeviceIdentifiers.swift the Mac mini entries are written with an uppercase "M":

case "MacMini6,1", "MacMini6,2": return "Mac mini (2012)"
case "MacMini7,1": return "Mac mini (2014)"
case "MacMini8,1": return "Mac mini (2018)"
case "MacMini9,1": return "Mac mini (2020)"

Swift switch compares strings case-sensitively, so "Macmini9,1" doesn't match "MacMini9,1" and the lookup falls through to default: return "Unknown Model".

Steps to reproduce

Run any app that uses DeviceInfoPlugin().macOsInfo on a Mac mini with an identifier of Macmini6,x to Macmini9,1.
Read model and modelName.

Actual

model: Macmini9,1
modelName: Unknown Model

Expected

model: Macmini9,1
modelName: Mac mini (2020)

Suggested fix

Change the five MacMini identifiers in DeviceIdentifiers.swift to Macmini, matching the value hw.model returns:

case "Macmini6,1", "Macmini6,2": return "Mac mini (2012)"
case "Macmini7,1": return "Mac mini (2014)"
case "Macmini8,1": return "Mac mini (2018)"
case "Macmini9,1": return "Mac mini (2020)"

Newer Mac mini models (Mac14,3, Mac14,12, Mac16,10, Mac16,11) use the MacNN,N format and aren't affected.

Code Sample

Logs
No exception is thrown. Minimal output from `DeviceInfoPlugin().macOsInfo` on a Mac mini (M1, 2020):


model: Macmini9,1
modelName: Unknown Model
arch: arm64
majorVersion: 27
minorVersion: 0
patchVersion: 1
osRelease: Version 27.0.1 (Build 26A434)
Flutter Doctor
[✓] Flutter (Channel stable, 3.47.5, on macOS 27.0.1 26A434 darwin-arm64, locale en-US)
    • Flutter version 3.47.5 on channel stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 6a19cca564 (8 weeks ago), 2026-09-17 14:13:22 -0400
    • Engine revision af7e796e16
    • Dart version 3.13.4
    • DevTools version 2.60.0

[!] Android toolchain - develop for Android devices (Android SDK version 36.1.0)
    • Platform android-37.0, build-tools 36.1.0
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
    ! Some Android licenses not accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 27.2)
    • Build 27B52
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web

[✓] Connected device (3 available)
    • Pixel 8 (mobile)  • <redacted> • android-arm64  • Android 17 (API 37)
    • macOS (desktop)   • macos      • darwin-arm64   • macOS 27.0.1 26A434 darwin-arm64
    • Chrome (web)      • chrome     • web-javascript • Google Chrome 157.0.8103.78

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
Checklist before submitting a bug
  • I searched issues in this repository and couldn't find such bug/problem
  • I Google'd a solution and I couldn't find it
  • I searched on StackOverflow for a solution and I couldn't find it
  • I read the README.md file of the plugin
  • I'm using the latest version of the plugin
  • All dependencies are up to date with flutter pub upgrade
  • I did a flutter clean
  • I tried running the example project
主要語言
Dart
星號
1.9k
分支
1.3k
PR 合併指標
30 天內沒有已合併 PR

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

fluttercommunity/plus_plugins 的其他 Issue

查看 fluttercommunity/plus_plugins 的全部 Issue

相似的 Issue

更多 Dart Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。