Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import 'package:flutter/material.dart';
class GetBackStringPage extends StatefulWidget {
_GetBackStringPageState createState() => _GetBackStringPageState();
class _GetBackStringPageState extends State<GetBackStringPage> {
Future<bool> _requestPop() async {
Navigator.pop(context, "I know you pressed the back button...");
return Future.value(false);
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: _requestPop,
child: Scaffold(
appBar: AppBar(
title: Text("GetBackStringPage"),
body: Center(
child: Column(
children: <Widget>[
child: Text('Back To NewPage with a String'),
color: Theme.of(context).primaryColor,
textColor: Colors.white,
onPressed: () =>
Navigator.pop(context, "Hello from the other page!")),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.