update_manager_ohos 0.0.1 copy "update_manager_ohos: ^0.0.1" to clipboard
update_manager_ohos: ^0.0.1 copied to clipboard

Provide version check and upgrade functionality for Flutter on HarmonyOS.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:update_manager_ohos/update_manager_ohos.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  Future<void> checkUpdate() async {
    final hasUpdate = await UpdateManagerOhos.instance.checkUpdate();
    debugPrint('hasUpdate: $hasUpdate');

    /// 如果有可用的更新,弹出升级弹窗
    if (hasUpdate) {
      final didShowDialog = await UpdateManagerOhos.instance.showUpdateDialog();
      debugPrint('didShowDialog: $didShowDialog');
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: ElevatedButton(
            onPressed: checkUpdate,
            child: const Text('Check Update'),
          ),
        ),
      ),
    );
  }
}
0
likes
140
points
22
downloads

Publisher

verified publisherharmonycandies.com

Weekly Downloads

Provide version check and upgrade functionality for Flutter on HarmonyOS.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on update_manager_ohos