native_restart 1.0.0 copy "native_restart: ^1.0.0" to clipboard
native_restart: ^1.0.0 copied to clipboard

A Flutter plugin to restart the Flutter Engine, allowing the Dart VM entry point to be re-executed while the native application continues running.

example/lib/main.dart

import 'dart:async';

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

void main(List<String> args) {
  debugPrint('main($args)');
  runApp(const MyApplication());
}

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

  @override
  State<MyApplication> createState() => _MyApplicationState();
}

class _MyApplicationState extends State<MyApplication> {
  int uptime = 0;
  Timer? timer;

  @override
  void initState() {
    super.initState();
    timer = Timer.periodic(const Duration(seconds: 1), (timer) {
      setState(() => uptime = timer.tick);
    });
  }

  @override
  void dispose() {
    timer?.cancel();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('package:native_restart'),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Text('Uptime: ${uptime}s'),
              const SizedBox(height: 16.0),
              ElevatedButton(
                onPressed: () {
                  restart(
                    args: ['--timestamp', (DateTime.now().toIso8601String())],
                  );
                },
                child: const Text('Restart'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
160
points
13
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to restart the Flutter Engine, allowing the Dart VM entry point to be re-executed while the native application continues running.

Repository (GitHub)
View/report issues

Topics

#restart #flutter-plugin #app-restart

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on native_restart

Packages that implement native_restart