1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-10 23:08:59 +00:00

[Gallery] Fix directory structure (#312)

This commit is contained in:
Pierre-Louis
2020-02-05 20:11:54 +01:00
committed by GitHub
parent 082592e9a9
commit cee267cf88
762 changed files with 12 additions and 12 deletions

View File

@@ -0,0 +1,36 @@
// Copyright 2019 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
enum DisplayType {
desktop,
mobile,
}
const _desktopBreakpoint = 700.0;
const _smallDesktopMaxWidth = 1000.0;
/// Returns the [DisplayType] for the current screen. This app only supports
/// mobile and desktop layouts, and as such we only have one breakpoint.
DisplayType displayTypeOf(BuildContext context) {
if (MediaQuery.of(context).size.shortestSide > _desktopBreakpoint) {
return DisplayType.desktop;
} else {
return DisplayType.mobile;
}
}
/// Returns a boolean if we are in a display of [DisplayType.desktop]. Used to
/// build adaptive and responsive layouts.
bool isDisplayDesktop(BuildContext context) {
return displayTypeOf(context) == DisplayType.desktop;
}
/// Returns a boolean if we are in a display of [DisplayType.desktop] but less
/// than 1000 width. Used to build adaptive and responsive layouts.
bool isDisplaySmallDesktop(BuildContext context) {
return isDisplayDesktop(context) &&
MediaQuery.of(context).size.width < _smallDesktopMaxWidth;
}