自动更新功能windows和安卓(待完善)

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

void main() async {
  /*
  WidgetsFlutterBinding.ensureInitialized();
  String feedURL = 'https://weimaoer.github.io/updata.xml';
  await autoUpdater.setFeedURL(feedURL);
  await autoUpdater.checkForUpdates();
  await autoUpdater.setScheduledCheckInterval(3600);
  */

  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Flutter Demo',
      home: SplashScreen(),
    );
  }
}

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

  @override
  // ignore: library_private_types_in_public_api
  _SplashScreenState createState() => _SplashScreenState();
}

class _SplashScreenState extends State<SplashScreen> {
  @override
  Widget build(BuildContext context) {
    return FutureBuilder(
      future: _navigateToHome(),
      builder: (context, snapshot) {
        if (snapshot.connectionState == ConnectionState.done) {
          return Container(); // 闪屏完成后,返回一个空容器
        } else {
          return Scaffold(
            body: Image.asset('assets/images/splash360.png'),
          );
        }
      },
    );
  }

  Future<void> _navigateToHome() async {
    await Future.delayed(const Duration(seconds: 2)); // 假设的初始化时间
    // ignore: use_build_context_synchronously
    Navigator.of(context).pushReplacement(
        MaterialPageRoute(builder: (context) => const HomePage()));
  }
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: const Center(
        child: Text('地图自己当前位置'),
      ),
      bottomNavigationBar: BottomNavigationBar(
        items: const [
          BottomNavigationBarItem(icon: Icon(Icons.category), label: '收货'),
          BottomNavigationBarItem(icon: Icon(Icons.email), label: '记录'),
          //BottomNavigationBarItem(icon: Icon(Icons.label), label: '位置'),
          BottomNavigationBarItem(icon: Icon(Icons.settings), label: '自己'),
        ],
      ),
    );
  }
}

  Flutter之自动更新(自带源码 包看包会)_flutter 自动更新-CSDN博客

Flutter使用auto_updater实现windows/mac桌面应用版本升级更新功能_flutter 桌面应用的版本更新-CSDN博客

posted @ 2024-06-17 16:34  飞雪飘鸿  阅读(2)  评论(0编辑  收藏  举报
https://damo.alibaba.com/ https://tianchi.aliyun.com/course?spm=5176.21206777.J_3941670930.5.87dc17c9BZNvLL