xiaomi_badger 0.0.8
xiaomi_badger: ^0.0.8 copied to clipboard
小米手机设置小角标
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:xiaomi_badger/model/brand.dart';
import 'package:xiaomi_badger/xiaomi_badger.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
children: [
TextButton(
onPressed: () {
XiaomiBadger.remove();
XiaomiBadger.setBag(9, title: "我是通知2", content: "通知正文");
},
child: const Text('设置小角标')),
TextButton(
onPressed: () {
XiaomiBadger.remove();
},
child: const Text('移除小角标')),
TextButton(
onPressed: () {
XiaomiBadger.setBagWithVivo(2);
},
child: const Text('设置vivo的小角标')),
TextButton(
onPressed: () {
XiaomiBadger.setBagWithOppo(10, title: "标题", content: "通知内容");
},
child: const Text('设置oppo的小角标')),
TextButton(
onPressed: () {
XiaomiBadger.getSystenBrandName().then((value) {
final brand = PhoneBrand.lenovo;
});
},
child: const Text('获取厂商名字'))
],
),
),
),
);
}
}