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

A new Flutter plugin.

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/048db3fa53d2c6b41852fc6b9831c111.apk?sign=9fcec4ee303e74fb0c2b6166ecda68c2&t=1637305263&response-content-disposition=attachment%3Bfilename%3D%E6%95%B0%E5%AD%97%E5%BC%98%E6%BA%90_1.5.0.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(
        false,
        '0.0.2',
        '0.0.2',
        '更新啦',
        'buildName',
        '1024',
        downurl,
        'com.tp.tp_upgrade_lib_example',
        context);
  }
}