ominibyte / flutter_device_type Goto Github PK
View Code? Open in Web Editor NEWDetermine the type of handheld device on Flutter. Like if the device is a Tablet or is iPhoneX.
License: MIT License
Determine the type of handheld device on Flutter. Like if the device is a Tablet or is iPhoneX.
License: MIT License
What about tests for iPhone XS, iPhone XS Max, iPhone XR?
Currently, isIphoneX will return false for XS, XS Max and XR.
This package thinks the Samsung A71 and other long android devices are tablets:
Samsung A71 Spec:
1080 x 2400 pixels
6.7 inches
Result from Device.get()
:
Device
hasNotch:true
isAndroid:true
isIos:false
isIphoneX:false
isPhone:false
isTablet:true
Result from
Device.devicePixelRatio
2.325000047683716
Device.size
Size (Size(1080.0, 2400.0))
Device.height
2400.0
Device.width
1080.0
I wonder if it is todo with this code in flutter_device_type.dart
L64:
// Recalculate for Android Tablet using device inches
if (isAndroid) {
final adjustedWidth = _calWidth() / devicePixelRatio;
final adjustedHeight = _calHeight() / devicePixelRatio;
final diagonalSizeInches = (Math.sqrt(
Math.pow(adjustedWidth, 2) + Math.pow(adjustedHeight, 2))) /
_ppi;
//print("Dialog size inches is $diagonalSizeInches");
if (diagonalSizeInches >= 7) { // <- It must think it is over 7 inches
isTablet = true;
isPhone = false;
} else {
isTablet = false;
isPhone = true;
}
}
A simulator based on Nexus 7, one of the built-in tablets, is being reported as a phone. The issue appears to be that the Nexus 7 screen calculation is 6.94 diagonal, just below your threshold for a tablet.
The library has getters for isPhone and isTablet, but there's no way to check against other versions of Android.
Hello, are there any plans for supporting null safety? Seems easy as it is only one file.
Please let me know if you need help migrating, I can create a PR.
This library returns
deviceIsTablet=false
on a bunch of tablets. This error does not occur every time, but it does happen again and again.
It also rarely happens in debug mode but mostly in release mode.
Tested devices: iPad mini, iPad Air 2, Galaxy Tab S6, Galaxy Tab A2
If I try to use Device.get().isPhone on Flutter Web, it crashes because of dart:io usage when detecting Platform.isiOS.
Can you fix this? You can take foundation.darts defaultTargetPlatform which is working on Flutter Web.
It detects Samsung Galaxy A20 as a tablet for instance.
I would suggest hasNotch
or something like that so you don't have to make new methods for the same type of check
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.