flutter_app_badger_tizen 0.1.0 flutter_app_badger_tizen: ^0.1.0 copied to clipboard
Tizen implementation of the flutter_app_badger plugin
import 'package:flutter/material.dart';
import 'package:flutter_app_badger/flutter_app_badger.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _appBadgeSupported = 'Unknown';
@override
initState() {
super.initState();
initPlatformState();
}
initPlatformState() async {
String appBadgeSupported;
try {
bool res = await FlutterAppBadger.isAppBadgeSupported();
if (res) {
appBadgeSupported = 'Supported';
} else {
appBadgeSupported = 'Not supported';
}
} on Exception {
appBadgeSupported = 'Failed to get badge support.';
}
setState(() {
_appBadgeSupported = appBadgeSupported;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: SizedBox.expand(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text('Badge supported: $_appBadgeSupported\n'),
ElevatedButton(
child: const Text('Add badge'),
onPressed: () {
_addBadge();
},
),
ElevatedButton(
child: const Text('Remove badge'),
onPressed: () {
_removeBadge();
}),
],
),
),
),
);
}
void _addBadge() {
FlutterAppBadger.updateBadgeCount(1);
}
void _removeBadge() {
FlutterAppBadger.removeBadge();
}
}