tp_upgrade_lib 3.3.9 copy "tp_upgrade_lib: ^3.3.9" to clipboard
tp_upgrade_lib: ^3.3.9 copied to clipboard

flutter project android update.

example/lib/main.dart

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

void main() async{
  WidgetsFlutterBinding.ensureInitialized();
  await UpdateUtils.initializeFlutterDownloader();
  runApp( MyApp());
}

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  //此为临时下载路径,测试的时候替换掉自己的下载路径
  final String downurl='https://cos.pgyer.com/33b51a0122150aa3e140cdfa2e0fee62.apk?sign=6984b8b00fd84a6abcbb0fa0f47731b2&t=1673253684&response-content-disposition=attachment%3Bfilename%3D292f91aef1f1489b910103529b28ae96.apk';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          MaterialButton(onPressed: ()=>onDownTap(context),child: Text('点击更新'),color: Colors.blue,)
        ],
      ),
    );
  }

  onDownTap(BuildContext context) {
    UpdateUtils.popDialog(
        true,
        '0.0.2',
        '0.0.2',
        '更新啦',
        'buildName',
        '1024',
        downurl,
        'com.tp.tp_upgrade_lib_example',
        context);
  }
}