DEV Community

Satya Routray
Satya Routray

Posted on

Answer: How To Override the “Back” button in Flutter? [duplicate]

You can use WillPopScope to achieve this.

Example:

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

class HomePage extends StatefulWidget {
  HomePage({Key key, this.title}) :super(key: key);

  final String title;

  @override
  State<StatefulWidget> createState() => new _HomePageState();
}

class _HomePageState extends State<HomePage> {

  Future<bool> _onWillPop() async {
    return (await showDialog(
      context: context,
      builder: (context) => new

Top comments (0)