mirror of https://github.com/flutter/pinball.git
parent
4579ee4ef2
commit
49255d4964
@ -0,0 +1,39 @@
|
||||
# Miscellaneous
|
||||
*.class
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
|
||||
# IntelliJ related
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# VSCode related
|
||||
.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
**/doc/api/
|
||||
**/ios/Flutter/.last_build_id
|
||||
.dart_tool/
|
||||
.flutter-plugins
|
||||
.flutter-plugins-dependencies
|
||||
.packages
|
||||
.pub-cache/
|
||||
.pub/
|
||||
/build/
|
||||
|
||||
# Web related
|
||||
lib/generated_plugin_registrant.dart
|
||||
|
||||
# Symbolication related
|
||||
app.*.symbols
|
||||
|
||||
# Obfuscation related
|
||||
app.*.map.json
|
@ -0,0 +1,11 @@
|
||||
# platform_helper
|
||||
|
||||
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]
|
||||
[![License: MIT][license_badge]][license_link]
|
||||
|
||||
A Very Good Project created by Very Good CLI.
|
||||
|
||||
[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg
|
||||
[license_link]: https://opensource.org/licenses/MIT
|
||||
[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg
|
||||
[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis
|
@ -0,0 +1 @@
|
||||
include: package:very_good_analysis/analysis_options.2.4.0.yaml
|
@ -0,0 +1,3 @@
|
||||
library platform_helper;
|
||||
|
||||
export 'src/platform_helper.dart';
|
@ -0,0 +1,12 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
/// {@template platform_helper}
|
||||
/// Returns whether the current platform is running on a mobile device.
|
||||
/// {@endtemplate}
|
||||
class PlatformHelper {
|
||||
/// {@macro platform_helper}
|
||||
bool get isMobile {
|
||||
return defaultTargetPlatform == TargetPlatform.iOS ||
|
||||
defaultTargetPlatform == TargetPlatform.android;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
name: platform_helper
|
||||
description: A Very Good Project created by Very Good CLI.
|
||||
version: 1.0.0+1
|
||||
publish_to: none
|
||||
|
||||
environment:
|
||||
sdk: ">=2.16.0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
very_good_analysis: ^2.4.0
|
@ -0,0 +1,39 @@
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:platform_helper/platform_helper.dart';
|
||||
|
||||
void main() {
|
||||
group('PlatformHelper', () {
|
||||
test('can be instantiated', () {
|
||||
expect(PlatformHelper(), isNotNull);
|
||||
});
|
||||
|
||||
group('isMobile', () {
|
||||
tearDown(() async {
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
|
||||
test('returns true when defaultTargetPlatform is iOS', () async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
||||
expect(PlatformHelper().isMobile, isTrue);
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
|
||||
test('returns true when defaultTargetPlatform is android', () async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.android;
|
||||
expect(PlatformHelper().isMobile, isTrue);
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
|
||||
test(
|
||||
'returns false when defaultTargetPlatform is niether iOS nor android',
|
||||
() async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.macOS;
|
||||
expect(PlatformHelper().isMobile, isFalse);
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in new issue