Gallery/lib/utils/tile_size.dart

25 lines
576 B
Dart
Raw Normal View History

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;
}
}