Skip to content

Commit

Permalink
Merge pull request #441 from guyluz11/master
Browse files Browse the repository at this point in the history
Example small code improvements (without logic change)
  • Loading branch information
ekasetiawans authored Jun 18, 2024
2 parents 943e0c6 + 8140a1c commit 5f2c291
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "id.flutter.example"
minSdkVersion 19
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
35 changes: 11 additions & 24 deletions packages/flutter_background_service/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ void onStart(ServiceInstance service) async {
if (Platform.isAndroid) {
final androidInfo = await deviceInfo.androidInfo;
device = androidInfo.model;
}

if (Platform.isIOS) {
} else if (Platform.isIOS) {
final iosInfo = await deviceInfo.iosInfo;
device = iosInfo.model;
}
Expand Down Expand Up @@ -211,44 +209,33 @@ class _MyAppState extends State<MyApp> {
),
ElevatedButton(
child: const Text("Foreground Mode"),
onPressed: () {
FlutterBackgroundService().invoke("setAsForeground");
},
onPressed: () =>
FlutterBackgroundService().invoke("setAsForeground"),
),
ElevatedButton(
child: const Text("Background Mode"),
onPressed: () {
FlutterBackgroundService().invoke("setAsBackground");
},
onPressed: () =>
FlutterBackgroundService().invoke("setAsBackground"),
),
ElevatedButton(
child: Text(text),
onPressed: () async {
final service = FlutterBackgroundService();
var isRunning = await service.isRunning();
if (isRunning) {
service.invoke("stopService");
} else {
service.startService();
}
isRunning
? service.invoke("stopService")
: service.startService();

if (!isRunning) {
text = 'Stop Service';
} else {
text = 'Start Service';
}
setState(() {});
setState(() {
text = isRunning ? 'Start Service' : 'Stop Service';
});
},
),
const Expanded(
child: LogView(),
),
],
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: const Icon(Icons.play_arrow),
),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
<orderEntry type="library" name="Flutter Plugins" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
<orderEntry type="library" name="Flutter Plugins" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
<orderEntry type="library" name="Flutter Plugins" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>
</module>

0 comments on commit 5f2c291

Please sign in to comment.