mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2024-12-27 00:29:32 -05:00
bc41ea6d82
268b86d131
tries to access Platform._operatingSystem as part of checking whether
it is running on Windows, Linux, or macOS, and this information is not
available on the web. This MR makes it possible to reach the
VeilidChat "Create a new account" screen when running in Chrome
(although the user apparently can't proceed further because of an
"already borrowed" panic). Without this MR, there is an uncaught error
even before getting to that account screen.
35 lines
873 B
Dart
35 lines
873 B
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
bool get isAndroid => !kIsWeb && Platform.isAndroid;
|
|
bool get isiOS => !kIsWeb && Platform.isIOS;
|
|
bool get isWeb => kIsWeb;
|
|
bool get isDesktop =>
|
|
!isWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS);
|
|
|
|
const kMobileWidthCutoff = 479.0;
|
|
|
|
bool isMobileWidth(BuildContext context) =>
|
|
MediaQuery.of(context).size.width < kMobileWidthCutoff;
|
|
|
|
bool responsiveVisibility({
|
|
required BuildContext context,
|
|
bool phone = true,
|
|
bool tablet = true,
|
|
bool tabletLandscape = true,
|
|
bool desktop = true,
|
|
}) {
|
|
final width = MediaQuery.of(context).size.width;
|
|
if (width < kMobileWidthCutoff) {
|
|
return phone;
|
|
} else if (width < 767) {
|
|
return tablet;
|
|
} else if (width < 991) {
|
|
return tabletLandscape;
|
|
} else {
|
|
return desktop;
|
|
}
|
|
}
|