Skip to content

Commit

Permalink
feat: update example code
Browse files Browse the repository at this point in the history
  • Loading branch information
aaassseee committed Dec 21, 2024
1 parent 4bfc81e commit 8a17d82
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 44 deletions.
4 changes: 2 additions & 2 deletions screen_brightness/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 31
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -45,7 +45,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.aaassseee.screen_brightness_example"
minSdkVersion flutter.minSdkVersion
targetSdkVersion 30
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
android:launchMode="singleTop"
android:name=".MainActivity"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:exported="true">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
Expand Down
19 changes: 18 additions & 1 deletion screen_brightness/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,14 @@ class SettingPage extends StatefulWidget {
class _SettingPageState extends State<SettingPage> {
bool isAutoReset = true;
bool isAnimate = true;
bool canChangeSystemBrightness = true;

@override
void initState() {
super.initState();
getIsAutoResetSetting();
getIsAnimateSetting();
getCanChangeSystemBrightness();
}

Future<void> getIsAutoResetSetting() async {
Expand All @@ -358,6 +360,14 @@ class _SettingPageState extends State<SettingPage> {
});
}

Future<void> getCanChangeSystemBrightness() async {
final canChangeSystemBrightness =
await ScreenBrightness.instance.canChangeSystemBrightness;
setState(() {
this.canChangeSystemBrightness = canChangeSystemBrightness;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -385,7 +395,14 @@ class _SettingPageState extends State<SettingPage> {
await getIsAnimateSetting();
},
),
)
),
ListTile(
title: const Text('Can change system brightness'),
trailing: Switch(
value: canChangeSystemBrightness,
onChanged: (value) {},
),
),
],
),
);
Expand Down
45 changes: 20 additions & 25 deletions screen_brightness/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -147,44 +147,39 @@ packages:
source: path
version: "2.0.1"
screen_brightness_android:
dependency: transitive
dependency: "direct overridden"
description:
name: screen_brightness_android
sha256: "74455f9901ab8a1a45c9097b83855dbbb7498110cc2bc249cb5a86570dd1cf7c"
url: "https://pub.dev"
source: hosted
path: "../../screen_brightness_android"
relative: true
source: path
version: "2.0.0"
screen_brightness_ios:
dependency: transitive
dependency: "direct overridden"
description:
name: screen_brightness_ios
sha256: caee02b34e0089b138a7aee35c461bd2d7c78446dd417f07613def192598ca08
url: "https://pub.dev"
source: hosted
path: "../../screen_brightness_ios"
relative: true
source: path
version: "2.0.0"
screen_brightness_macos:
dependency: transitive
dependency: "direct overridden"
description:
name: screen_brightness_macos
sha256: "84fc8ffcbcf19c03d76b7673b0f2c2a2663c09aa2bc37c76ea83ab049294a97a"
url: "https://pub.dev"
source: hosted
path: "../../screen_brightness_macos"
relative: true
source: path
version: "2.0.0"
screen_brightness_platform_interface:
dependency: transitive
dependency: "direct overridden"
description:
name: screen_brightness_platform_interface
sha256: "321e9455b0057e3647fd37700931e063739d94a8aa1b094f98133c01cb56c27b"
url: "https://pub.dev"
source: hosted
path: "../../screen_brightness_platform_interface"
relative: true
source: path
version: "2.0.0"
screen_brightness_windows:
dependency: transitive
dependency: "direct overridden"
description:
name: screen_brightness_windows
sha256: "5edbfb1dcaedf960f6858efac8ca45d6c18faae17df86e2c03137d3a563ea155"
url: "https://pub.dev"
source: hosted
path: "../../screen_brightness_windows"
relative: true
source: path
version: "2.0.1"
sky_engine:
dependency: transitive
Expand Down
22 changes: 11 additions & 11 deletions screen_brightness/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ dev_dependencies:
sdk: flutter
flutter_lints: ">=3.0.0 <4.0.0"

#dependency_overrides:
# screen_brightness_platform_interface:
# path: ../../screen_brightness_platform_interface/
# screen_brightness_android:
# path: ../../screen_brightness_android
# screen_brightness_ios:
# path: ../../screen_brightness_ios
# screen_brightness_macos:
# path: ../../screen_brightness_macos
# screen_brightness_windows:
# path: ../../screen_brightness_windows
dependency_overrides:
screen_brightness_platform_interface:
path: ../../screen_brightness_platform_interface/
screen_brightness_android:
path: ../../screen_brightness_android
screen_brightness_ios:
path: ../../screen_brightness_ios
screen_brightness_macos:
path: ../../screen_brightness_macos
screen_brightness_windows:
path: ../../screen_brightness_windows

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down
2 changes: 1 addition & 1 deletion screen_brightness_android/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class _SettingPageState extends State<SettingPage> {
value: canChangeSystemBrightness,
onChanged: (value) {},
),
)
),
],
),
);
Expand Down
2 changes: 1 addition & 1 deletion screen_brightness_ios/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class _SettingPageState extends State<SettingPage> {
value: canChangeSystemBrightness,
onChanged: (value) {},
),
)
),
],
),
);
Expand Down
2 changes: 1 addition & 1 deletion screen_brightness_macos/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class _SettingPageState extends State<SettingPage> {
value: canChangeSystemBrightness,
onChanged: (value) {},
),
)
),
],
),
);
Expand Down
2 changes: 1 addition & 1 deletion screen_brightness_windows/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class _SettingPageState extends State<SettingPage> {
value: canChangeSystemBrightness,
onChanged: (value) {},
),
)
),
],
),
);
Expand Down

0 comments on commit 8a17d82

Please sign in to comment.