Ricky Reza Muhammad
Ricky Reza Muhammad

Reputation: 373

How to use Upgrader Plugin on flutter?

I need to use upgrader plugin for myapps, because i need to use the auto update on ios too. But the problem is i don't know how to use it. And my apps looks like this. enter image description here

and here is my code

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:mobile7/class/login.dart';
import 'package:upgrader/upgrader.dart';

class CheckUpdate extends StatefulWidget {
static const String id = 'login_screen';
@override
_CheckUpdateState createState() => _CheckUpdateState();
}

 class _CheckUpdateState extends State<CheckUpdate> {
  final Login login = Login();
 bool isLoading = true;

 @override
 Widget build(BuildContext context) {
 return SafeArea(
   child: Scaffold(
      appBar: AppBar(
        title: Text('Upgrade Example'),
      ),
      body: _checkPlatform()),
  );
 }
 }

  Widget _checkPlatform() {
  Widget upgraderAlert;
  if (Platform.isAndroid) {
    upgraderAlert = UpgradeAlert(
     dialogStyle: UpgradeDialogStyle.cupertino,
     child: Center(child: Text('Checking...')),
   );
  } else if (Platform.isAndroid) {
   upgraderAlert = UpgradeAlert(
     dialogStyle: UpgradeDialogStyle.cupertino,
     child: Center(child: Text('Checking...')),
    );
   }

   return upgraderAlert;
   }

i read the documentation and it's says that i just need to wrap it up in that UpgraderAlert but it's didn't do anything help me solve this

here is upgrader plugin https://pub.dev/packages/upgrader

Upvotes: 5

Views: 12392

Answers (1)

Larry Aasen
Larry Aasen

Reputation: 515

To use upgrader on Android, you must setup an Appcast file and provide the configuration. Here is an example Appcast file you need to place on a server somewhere, such as GitHub. The Appcast file contains the details about the latest version of the app:

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
    <channel>
        <title>Debt Now App - Appcast</title>
        <item>
            <title>Version 1.15.0</title>
            <description>desc</description>
            <pubDate>Sun, 30 Dec 2018 12:00:00 +0000</pubDate>
            <enclosure url="https://play.google.com/store/apps/details?id=com.moonwink.treasury" sparkle:version="1.15.0" sparkle:os="android" />
        </item>
    </channel>
</rss>

Here is a build method that will use the Appcast file on Android, and provide the AppcastConfiguration. This configuration will not apply to iOS, but iOS will continue to work.

  @override
  Widget build(BuildContext context) {
    final appcastURL =
        'https://raw.githubusercontent.com/larryaasen/upgrader/master/test/testappcast.xml';
    final cfg = AppcastConfiguration(url: appcastURL, supportedOS: ['android']);

    return MaterialApp(
      title: 'Upgrader Example',
      home: Scaffold(
          appBar: AppBar(
            title: Text('Upgrader Example'),
          ),
          body: UpgradeAlert(
            appcastConfig: cfg,
            child: Center(child: Text('Checking...')),
          )),
    );
  }

Upvotes: 10

Related Questions