Skip to content

Commit a3d78fe

Browse files
committed
Update example for flutter 3.0
1 parent 9db76ec commit a3d78fe

File tree

6 files changed

+45
-22
lines changed

6 files changed

+45
-22
lines changed

example/android/app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ android {
2929
compileSdkVersion flutter.compileSdkVersion
3030

3131
compileOptions {
32-
sourceCompatibility JavaVersion.VERSION_1_8
33-
targetCompatibility JavaVersion.VERSION_1_8
32+
sourceCompatibility JavaVersion.VERSION_11
33+
targetCompatibility JavaVersion.VERSION_11
3434
}
3535

3636
kotlinOptions {
37-
jvmTarget = '1.8'
37+
jvmTarget = '11'
3838
}
3939

4040
sourceSets {
@@ -44,7 +44,7 @@ android {
4444
defaultConfig {
4545
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
4646
applicationId "com.prongbang.screen_protector_example"
47-
minSdkVersion flutter.minSdkVersion
47+
minSdkVersion 21
4848
targetSdkVersion flutter.targetSdkVersion
4949
versionCode flutterVersionCode.toInteger()
5050
versionName flutterVersionName

example/android/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
buildscript {
2-
ext.kotlin_version = '1.3.50'
2+
ext.kotlin_version = '1.6.21'
33
repositories {
44
google()
55
mavenCentral()
6+
maven { url 'https://jitpack.io' }
67
}
78

89
dependencies {
9-
classpath 'com.android.tools.build:gradle:4.1.0'
10+
classpath 'com.android.tools.build:gradle:4.1.3'
1011
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1112
}
1213
}
@@ -15,6 +16,7 @@ allprojects {
1516
repositories {
1617
google()
1718
mavenCentral()
19+
maven { url 'https://jitpack.io' }
1820
}
1921
}
2022

example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ SPEC CHECKSUMS:
2626

2727
PODFILE CHECKSUM: 7368163408c647b7eb699d0d788ba6718e18fb8d
2828

29-
COCOAPODS: 1.11.2
29+
COCOAPODS: 1.11.3

example/ios/Runner/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,7 @@
4343
</array>
4444
<key>UIViewControllerBasedStatusBarAppearance</key>
4545
<true/>
46+
<key>CADisableMinimumFrameDurationOnPhone</key>
47+
<true/>
4648
</dict>
4749
</plist>

example/lib/prevent_screenshot_page.dart

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:screen_protector/lifecycle/lifecycle_state.dart';
23
import 'package:screen_protector/screen_protector.dart';
34

45
class PreventScreenshotPage extends StatefulWidget {
@@ -8,7 +9,8 @@ class PreventScreenshotPage extends StatefulWidget {
89
_PreventScreenshotPageState createState() => _PreventScreenshotPageState();
910
}
1011

11-
class _PreventScreenshotPageState extends State<PreventScreenshotPage> {
12+
class _PreventScreenshotPageState
13+
extends LifecycleState<PreventScreenshotPage> {
1214
@override
1315
void initState() {
1416
// For iOS only.
@@ -25,6 +27,18 @@ class _PreventScreenshotPageState extends State<PreventScreenshotPage> {
2527
super.dispose();
2628
}
2729

30+
@override
31+
void onPaused() {
32+
_protectScreenOn();
33+
super.onPaused();
34+
}
35+
36+
@override
37+
void onResumed() {
38+
_protectScreenOff();
39+
super.onResumed();
40+
}
41+
2842
@override
2943
Widget build(BuildContext context) {
3044
return Scaffold(
@@ -44,6 +58,11 @@ class _PreventScreenshotPageState extends State<PreventScreenshotPage> {
4458
void _preventScreenshotOff() async =>
4559
await ScreenProtector.preventScreenshotOff();
4660

61+
void _protectScreenOn() async => await ScreenProtector.protectDataLeakageOn();
62+
63+
void _protectScreenOff() async =>
64+
await ScreenProtector.protectDataLeakageOff();
65+
4766
void _addListenerPreventScreenshot() async {
4867
ScreenProtector.addListener(() {
4968
// Screenshot

example/pubspec.lock

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ packages:
4242
name: collection
4343
url: "https://pub.dartlang.org"
4444
source: hosted
45-
version: "1.15.0"
45+
version: "1.16.0"
4646
cupertino_icons:
4747
dependency: "direct main"
4848
description:
@@ -56,7 +56,7 @@ packages:
5656
name: fake_async
5757
url: "https://pub.dartlang.org"
5858
source: hosted
59-
version: "1.2.0"
59+
version: "1.3.0"
6060
flutter:
6161
dependency: "direct main"
6262
description: flutter
@@ -88,6 +88,13 @@ packages:
8888
url: "https://pub.dartlang.org"
8989
source: hosted
9090
version: "0.12.11"
91+
material_color_utilities:
92+
dependency: transitive
93+
description:
94+
name: material_color_utilities
95+
url: "https://pub.dartlang.org"
96+
source: hosted
97+
version: "0.1.4"
9198
meta:
9299
dependency: transitive
93100
description:
@@ -101,7 +108,7 @@ packages:
101108
name: path
102109
url: "https://pub.dartlang.org"
103110
source: hosted
104-
version: "1.8.0"
111+
version: "1.8.1"
105112
screen_protector:
106113
dependency: "direct main"
107114
description:
@@ -120,7 +127,7 @@ packages:
120127
name: source_span
121128
url: "https://pub.dartlang.org"
122129
source: hosted
123-
version: "1.8.1"
130+
version: "1.8.2"
124131
stack_trace:
125132
dependency: transitive
126133
description:
@@ -155,21 +162,14 @@ packages:
155162
name: test_api
156163
url: "https://pub.dartlang.org"
157164
source: hosted
158-
version: "0.4.3"
159-
typed_data:
160-
dependency: transitive
161-
description:
162-
name: typed_data
163-
url: "https://pub.dartlang.org"
164-
source: hosted
165-
version: "1.3.0"
165+
version: "0.4.9"
166166
vector_math:
167167
dependency: transitive
168168
description:
169169
name: vector_math
170170
url: "https://pub.dartlang.org"
171171
source: hosted
172-
version: "2.1.1"
172+
version: "2.1.2"
173173
sdks:
174-
dart: ">=2.15.1 <3.0.0"
174+
dart: ">=2.17.0-0 <3.0.0"
175175
flutter: ">=2.5.0"

0 commit comments

Comments
 (0)