Skip to content

Commit 39ed97b

Browse files
committed
upd deps, changed dep from battery_info to battery_plus, impl custom battery_info.provider
1 parent 79a7185 commit 39ed97b

24 files changed

+216
-26
lines changed

example/android/app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ android {
1111
ndkVersion = flutter.ndkVersion
1212

1313
compileOptions {
14-
sourceCompatibility = JavaVersion.VERSION_1_8
15-
targetCompatibility = JavaVersion.VERSION_1_8
14+
sourceCompatibility = JavaVersion.VERSION_11
15+
targetCompatibility = JavaVersion.VERSION_11
1616
}
1717

1818
kotlinOptions {
19-
jvmTarget = JavaVersion.VERSION_1_8
19+
jvmTarget = JavaVersion.VERSION_11
2020
}
2121

2222
defaultConfig {

example/android/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
22
android.useAndroidX=true
33
android.enableJetifier=true
4+
android.defaults.buildfeatures.buildconfig=true
5+
android.nonTransitiveRClass=false
6+
android.nonFinalResIds=false

example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip

example/android/settings.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ pluginManagement {
1818

1919
plugins {
2020
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21-
id "com.android.application" version "7.3.0" apply false
22-
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
21+
id "com.android.application" version '8.6.1' apply false
22+
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
2323
}
2424

2525
include ":app"

example/ios/Flutter/Debug.xcconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
12
#include "Generated.xcconfig"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
12
#include "Generated.xcconfig"

example/ios/Podfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Uncomment this line to define a global platform for your project
2+
# platform :ios, '12.0'
3+
4+
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5+
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6+
7+
project 'Runner', {
8+
'Debug' => :debug,
9+
'Profile' => :release,
10+
'Release' => :release,
11+
}
12+
13+
def flutter_root
14+
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15+
unless File.exist?(generated_xcode_build_settings_path)
16+
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
17+
end
18+
19+
File.foreach(generated_xcode_build_settings_path) do |line|
20+
matches = line.match(/FLUTTER_ROOT\=(.*)/)
21+
return matches[1].strip if matches
22+
end
23+
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
24+
end
25+
26+
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
27+
28+
flutter_ios_podfile_setup
29+
30+
target 'Runner' do
31+
use_frameworks!
32+
use_modular_headers!
33+
34+
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
35+
target 'RunnerTests' do
36+
inherit! :search_paths
37+
end
38+
end
39+
40+
post_install do |installer|
41+
installer.pods_project.targets.each do |target|
42+
flutter_additional_ios_build_settings(target)
43+
end
44+
end

example/lib/main.dart

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void main() {
1414
}
1515

1616
class App extends StatelessWidget {
17-
const App({Key? key}) : super(key: key);
17+
const App({super.key});
1818

1919
@override
2020
Widget build(BuildContext context) {
@@ -29,7 +29,7 @@ class App extends StatelessWidget {
2929
}
3030

3131
class HomePage extends StatefulWidget {
32-
const HomePage({Key? key}) : super(key: key);
32+
const HomePage({super.key});
3333

3434
@override
3535
_HomePageState createState() => _HomePageState();
@@ -39,6 +39,7 @@ class _HomePageState extends State<HomePage> {
3939
AnalysisInfoInterface? info;
4040
String? cpuInfo;
4141
String? memInfo;
42+
String? btrInfo;
4243

4344
String getInfoData() {
4445
final raw = info?.toMap() ?? {};
@@ -142,6 +143,24 @@ class _HomePageState extends State<HomePage> {
142143
padding: const EdgeInsets.symmetric(horizontal: 16),
143144
child: SelectableText(memInfo ?? '-'),
144145
),
146+
Padding(
147+
padding: const EdgeInsets.symmetric(horizontal: 16),
148+
child: ElevatedButton(
149+
onPressed: () async {
150+
final temperature = await BatteryInfoProvider().temperature;
151+
final chargeLevel = await BatteryInfoProvider().chargeLevel;
152+
btrInfo = 'Temp: $temperature\n'
153+
'Level: $chargeLevel';
154+
setState(() {});
155+
},
156+
child: const Text('Get Battery Info'),
157+
),
158+
),
159+
const SizedBox(height: 16),
160+
Padding(
161+
padding: const EdgeInsets.symmetric(horizontal: 16),
162+
child: SelectableText(btrInfo ?? '-'),
163+
),
145164
const SizedBox(height: 24),
146165
],
147166
),
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
12
#include "ephemeral/Flutter-Generated.xcconfig"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
12
#include "ephemeral/Flutter-Generated.xcconfig"

0 commit comments

Comments
 (0)