xiaomi_badger 0.1.0 copy "xiaomi_badger: ^0.1.0" to clipboard
xiaomi_badger: ^0.1.0 copied to clipboard

PlatformAndroid
outdated

小米手机设置小角标

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('获取厂商名字'))
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
135
points
35
downloads

Publisher

verified publisheritbug.shop

Weekly Downloads

小米手机设置小角标

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on xiaomi_badger