Skip to main content

flutter_ota_system 0.2.0-alpha copy "flutter_ota_system: ^0.2.0-alpha" to clipboard
flutter_ota_system: ^0.2.0-alpha copied to clipboard

PlatformAndroid

Experimental Flutter client for Flutter OTA System, a self-hosted OTA patch platform: signed patches, staged updates and automatic fallback. Android only.

example/lib/main.dart

// Copyright 2026 The Punit Authors
// SPDX-License-Identifier: Apache-2.0

// The official Flutter OTA System demo app.
//
// How it is built:
//  * packages/core      shared, host-owned code (config and theme). Never changed by a patch.
//  * packages/products  a feature package. A patch can replace it with new code.
//  * lib/flutter_ota_features.g.dart  generated by `flutter_ota features generate`. The app
//    reaches every feature through it, never by importing the feature's classes directly.
//
// Without a FLUTTER_OTA_CONFIG dart-define (for example a plain `flutter run`), OTA is off and
// the app simply runs its own code. `flutter_ota release android` adds that define for you.
// The full walkthrough is in docs/demo-walkthrough.md.

import 'package:core/core.dart';
// Deprecated from Flutter 3.47 (replacement: package:material_ui), still the standard library.
// ignore: deprecated_member_use
import 'package:flutter/material.dart';
import 'package:flutter_ota_system/flutter_ota_system.dart';

import 'flutter_ota_features.g.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  // Never throws, makes no network request on the start-up path. It loads the active patch
  // (if any) and checks for updates in the background after the first frame.
  await FlutterOta.initialize();
  runApp(const DemoApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: DemoConfig.appTitle,
      theme: demoTheme(),
      home: const HomePage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text(DemoConfig.appTitle)),
      body: Column(
        children: [
          // The products feature: store code, or the patch's new code when a patch is active.
          Expanded(child: OtaFeatures.products.build(context)),
          const Divider(height: 1),
          const OtaStatusLine(),
        ],
      ),
    );
  }
}

/// One line at the bottom of the screen: is OTA on, and which patch is running.
class OtaStatusLine extends StatelessWidget {
  const OtaStatusLine({super.key});

  @override
  Widget build(BuildContext context) {
    final patch = FlutterOta.activePatchId;
    final text = !FlutterOta.isEnabled
        ? 'OTA: off (${FlutterOta.disabledReason ?? 'not configured'})'
        : 'OTA: on  |  active patch: ${patch ?? 'none (store code)'}';
    return SafeArea(
      top: false,
      child: Padding(
        padding: const EdgeInsets.all(12),
        child: Text(text, style: Theme.of(context).textTheme.bodySmall),
      ),
    );
  }
}
2
likes
160
points
87
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

Experimental Flutter client for Flutter OTA System, a self-hosted OTA patch platform: signed patches, staged updates and automatic fallback. Android only.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#ota #code-push #over-the-air #self-hosted #patching

License

Apache-2.0 (license)

Dependencies

crypto, flutter, http, path_provider, pointycastle

More

Packages that depend on flutter_ota_system

Packages that implement flutter_ota_system