restart 1.0.0+1 copy "restart: ^1.0.0+1" to clipboard
restart: ^1.0.0+1 copied to clipboard

A Flutter plugin to restart the application. The plugin works by restarting the Flutter Engine, instead of the underlying native application.

example/lib/main.dart

import 'dart:async';

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

void main() {
  debugPrint('main()');
  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:restart'),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Text('Uptime: ${uptime}s'),
              const SizedBox(height: 16.0),
              const ElevatedButton(
                onPressed: restart,
                child: Text('Restart'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
17
likes
160
pub points
89%
popularity

Publisher

verified publisherfarmako.in

A Flutter plugin to restart the application. The plugin works by restarting the Flutter Engine, instead of the underlying native application.

Repository (GitHub)
View/report issues

Topics

#restart

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on restart