Gallery/lib/utils/tile_size.dart
2022-09-29 21:01:28 +02:00

25 lines
576 B
Dart

import 'dart:io';
import 'package:flutter/widgets.dart';
enum DeviceType { phone, tablet }
DeviceType getDeviceType() {
final data = MediaQueryData.fromWindow(WidgetsBinding.instance.window);
return data.size.shortestSide < 550 ? DeviceType.phone : DeviceType.tablet;
}
int calcTileMaxWidth() {
if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) {
return 300;
} else if (Platform.isAndroid || Platform.isIOS) {
if (getDeviceType() == DeviceType.tablet) {
return 150;
} else {
return 100;
}
} else {
return 250;
}
}