Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
flutter_nav_tut
import 'package:flutter/material.dart';
class GetBackStringPage extends StatefulWidget {
@override
_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);
}
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: _requestPop,
child: Scaffold(
appBar: AppBar(
title: Text("GetBackStringPage"),
),
body: Center(
child: Column(
children: <Widget>[
RaisedButton(
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.