Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include: package:flutter_lints/flutter.yaml

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
61 changes: 33 additions & 28 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0"
version: "2.9.0"
boolean_selector:
dependency: transitive
description:
Expand All @@ -21,28 +21,21 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -56,7 +49,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.1"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -67,34 +60,53 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
fullscreen:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "1.0.3"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.4"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10"
version: "0.12.12"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.8.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.2"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -106,7 +118,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.9.0"
stack_trace:
dependency: transitive
description:
Expand All @@ -127,35 +139,28 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "0.4.12"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.2"
sdks:
dart: ">=2.12.0 <3.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=1.10.0"
51 changes: 8 additions & 43 deletions lib/fullscreen.dart
Original file line number Diff line number Diff line change
@@ -1,53 +1,18 @@
import 'dart:async';
import 'dart:io' show Platform;
import 'package:flutter/services.dart';

class FullScreen {
// meothod channel instal
static const MethodChannel _channel = const MethodChannel('fullscreen');
import 'src/fullscreen_native.dart'
if (dart.library.html) 'src/fullscreen_web.dart';

/// To enable fullscreen mode, pass the fullscreen mode as an argument the the enterFullScreen method of the FullScreen class.
static Future<void> enterFullScreen(FullScreenMode fullScreenMode) async {
if (Platform.isIOS) {
SystemChrome.setEnabledSystemUIOverlays([]);
} else if (Platform.isAndroid) {
try {
if (fullScreenMode == FullScreenMode.EMERSIVE) {
await _channel.invokeMethod('emersive');
} else if (fullScreenMode == FullScreenMode.EMERSIVE_STICKY) {
await _channel.invokeMethod('emersiveSticky');
} else if (fullScreenMode == FullScreenMode.LEANBACK) {
await _channel.invokeMethod('leanBack');
}
} catch (e) {
print(e);
}
}
}
class FullScreen {
static Future<void> enterFullScreen(
[FullScreenMode fullScreenMode = FullScreenMode.EMERSIVE]) =>
FullScreenPlatform.enterFullScreen(fullScreenMode);

/// to get the current status of the SystemUI
static Future<bool?> get isFullScreen async {
bool? status;
try {
status = await _channel.invokeMethod("status");
} catch (e) {
print(e);
}
return status;
}
static Future<bool?> get isFullScreen => FullScreenPlatform.isFullScreen;

/// Exit full screen
static Future<void> exitFullScreen() async {
if (Platform.isIOS) {
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
} else if (Platform.isAndroid) {
try {
await _channel.invokeMethod('exitFullScreen');
} catch (e) {
print(e);
}
}
}
static Future<void> exitFullScreen() => FullScreenPlatform.exitFullScreen();
}

enum FullScreenMode { EMERSIVE, EMERSIVE_STICKY, LEANBACK }
54 changes: 54 additions & 0 deletions lib/src/fullscreen_native.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import 'dart:async';
import 'dart:io' show Platform;
import 'package:flutter/services.dart';
import 'package:fullscreen/fullscreen.dart';

class FullScreenPlatform {
// meothod channel instal
static const MethodChannel _channel = const MethodChannel('fullscreen');

/// To enable fullscreen mode, pass the fullscreen mode as an argument the the enterFullScreen method of the FullScreen class.
static Future<void> enterFullScreen(
[FullScreenMode fullScreenMode = FullScreenMode.EMERSIVE]) async {
if (Platform.isIOS) {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
} else if (Platform.isAndroid) {
try {
if (fullScreenMode == FullScreenMode.EMERSIVE) {
await _channel.invokeMethod('emersive');
} else if (fullScreenMode == FullScreenMode.EMERSIVE_STICKY) {
await _channel.invokeMethod('emersiveSticky');
} else if (fullScreenMode == FullScreenMode.LEANBACK) {
await _channel.invokeMethod('leanBack');
}
} catch (e) {
print(e);
}
}
}

/// to get the current status of the SystemUI
static Future<bool?> get isFullScreen async {
bool? status;
try {
final astatus = await _channel.invokeMethod('status');
print(astatus);
} catch (e) {
print(e);
}
return status;
}

/// Exit full screen
static Future<void> exitFullScreen() async {
if (Platform.isIOS) {
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
} else if (Platform.isAndroid) {
try {
await _channel.invokeMethod('exitFullScreen');
} catch (e) {
print(e);
}
}
}
}
27 changes: 27 additions & 0 deletions lib/src/fullscreen_web.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// In order to *not* need this ignore, consider extracting the "web" version
// of your plugin as a separate package, instead of inlining it in the same
// package as the core of your plugin.
// ignore: avoid_web_libraries_in_flutter
import 'dart:html' show window;

import 'package:fullscreen/fullscreen.dart';

/// A web implementation of the FullscreenPlatform of the Fullscreen plugin.
class FullScreenPlatform {
static Future<void> enterFullScreen(
[FullScreenMode fullScreenMode = FullScreenMode.EMERSIVE]) async {
try {
await window.document.documentElement?.requestFullscreen();
} catch (e) {}
}

/// to get the current status of the SystemUI
static Future<bool?> get isFullScreen async {
return window.document.fullscreenElement != null;
}

/// Exit full screen
static Future<void> exitFullScreen() async {
window.document.exitFullscreen();
}
}
Loading