Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import "package:flutter/material.dart";
import 'package:medium/test.dart';
void main() {
runApp(MaterialApp(home: MyApp(), debugShowCheckedModeBanner: false));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
@override
Widget build(BuildContext context) {
var raisedButton = FloatingActionButton.extended(
icon: Icon(Icons.near_me),
label: Text('Move to second page'),
onPressed: () {
Navigator.push(
context, MaterialPageRoute(builder: (context) => TestPage()));
});
return Scaffold(
body: Container(
color: Colors.white,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"Page 1",
style: TextStyle(
fontSize: 40,
fontWeight: FontWeight.bold,
color: Colors.green),
),
SizedBox(
height: 30,
),
Container(child: raisedButton),
],
),
),
),
);
}
}
import 'package:flutter/material.dart';
class TestPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
"Page 2",
style: TextStyle(
fontSize: 40, fontWeight: FontWeight.bold, color: Colors.green),
),SizedBox(
height: 30,
),
FloatingActionButton.extended(
icon: Icon(Icons.arrow_back),
label: Text('Move to First Page'),
onPressed: () {
Navigator.pop(context);
}),
],
)),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment