ota_update 0.1.2 ota_update: ^0.1.2 copied to clipboard
A Flutter plugin providing ota updates for Android and iOS, with download progress (Android only)
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:ota_update/ota_update.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
OtaEvent currentEvent;
@override
void initState() {
super.initState();
tryOtaUpdate();
}
Future<void> tryOtaUpdate() async {
try {
//LINK CONTAINS APK OF FLUTTER HELLO WORLD FROM FLUTTER SDK EXAMPLES
OtaUpdate().execute('https://test1.4q.sk/flutter_hello_world.apk').listen(
(OtaEvent event) {
setState(() => currentEvent = event);
},
);
} catch (e) {
print('Failed to make OTA update. Details: $e');
}
}
@override
Widget build(BuildContext context) {
if (currentEvent == null) {
return Container();
}
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('OTA status: ${currentEvent.status} : ${currentEvent.value} \n'),
),
),
);
}
}