Horje
how to restart flutter app programmatically Code Example
how to restart flutter app programmatically
import 'package:flutter/material.dart';

void main() {
  runApp(
    RestartWidget(
      child: MaterialApp(),
    ),
  );
}

class RestartWidget extends StatefulWidget {
  RestartWidget({this.child});

  final Widget child;

  static void restartApp(BuildContext context) {
    context.findAncestorStateOfType<_RestartWidgetState>().restartApp();
  }

  @override
  _RestartWidgetState createState() => _RestartWidgetState();
}

class _RestartWidgetState extends State<RestartWidget> {
  Key key = UniqueKey();

  void restartApp() {
    setState(() {
      key = UniqueKey();
    });
  }

  @override
  Widget build(BuildContext context) {
    return KeyedSubtree(
      key: key,
      child: widget.child,
    );
  }
}

--------------------------------------------
In this example you can reset your app from everywhere using RestartWidget.restartApp(context).




Csharp

Related
nodemon not installing Code Example nodemon not installing Code Example
c# get char from string Code Example c# get char from string Code Example
The server requested authentication method unknown to the client Code Example The server requested authentication method unknown to the client Code Example
asp.net get query string parameter Code Example asp.net get query string parameter Code Example
get execution directory c# Code Example get execution directory c# Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
12