我知道有Platform常量可用于識別flutter編譯運行的物件。
但是有什么方法可以識別用戶是在移動端使用flutter網站的嗎?
希望得到任何幫助,預先感謝。
uj5u.com熱心網友回復:
你可以查看device_info_plus包,特別是WebBrowserInfo類的一些相關資訊。
uj5u.com熱心網友回復:
你可以使用來自package:flutter/foundation.dart的TargetPlatform類,例如:
defaultTargetPlatform == TargetPlatform.iOS
或者
defaultTargetPlatform == TargetPlatform.android
uj5u.com熱心網友回復:
我相信你可以通過檢查平臺和螢屏尺寸來做到這一點。 如果平臺是網路,而螢屏尺寸很小,那肯定是移動瀏覽器。
GetX包也有一個名為isPhone的方法,你也可以使用它。
bool isTablet = context.isTablet;
bool isPhone = context.isPhone;
bool isAndroid = GetPlatform.isAndroid;
bool isIos = GetPlatform.isIOS;
bool isMacOs = GetPlatform.isMacOS;
bool isWindows = GetPlatform.isWindows;
bool isLinux = GetPlatform.isLinux;
bool isFuchsia = GetPlatform.isFuchsia;
bool isMobile = GetPlatform.isMobile;
bool isWeb = GetPlatform.isWeb;
bool isDesktop = GetPlatform.isDesktop;
bool isLandScape = context.isLandscape;
bool isPortrait = context.isPortrait;
double screenHeight = Get.height;
double screenWidth = Get.width;
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/332609.html
標籤:
