Skip to content

Instantly share code, notes, and snippets.

@jonahwilliams
Created July 25, 2022 19:51
Show Gist options
  • Save jonahwilliams/49294243b975d3cae139df4807f484c9 to your computer and use it in GitHub Desktop.
Save jonahwilliams/49294243b975d3cae139df4807f484c9 to your computer and use it in GitHub Desktop.
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() {
debugDefaultTargetPlatformOverride = TargetPlatform.android;
runApp(MaterialApp(
home: ExampleApp(),
routes: {
'foo': (ctx) => Target(),
},
));
}
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: TextButton(
child: Text('Navigate'),
onPressed: () {
Navigator.of(context).pushNamed('foo');
},
)));
}
}
class Target extends StatelessWidget {
const Target({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: TextButton(
child: Text('Back'),
onPressed: () {
Navigator.of(context).pop();
},
)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment