Advertisement
Sanlover

Untitled

Jan 31st, 2021
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() {
  4. runApp(MaterialApp(
  5. debugShowCheckedModeBanner: false,
  6. title: 'Navigation Basics',
  7. home: FirstRoute(),
  8. ));
  9. }
  10.  
  11. class FirstRoute extends StatelessWidget {
  12. @override
  13. Widget build(BuildContext context) {
  14. return Scaffold(
  15. appBar: AppBar(
  16. title: Center( child: Text('Первая страница')),
  17. ),
  18. body: Center(
  19. child: ElevatedButton(
  20. child: Text('Open route'),
  21. onPressed: () {
  22. Navigator.push(
  23. context,
  24. MaterialPageRoute(builder: (context) => SecondRoute()),
  25. );
  26. },
  27. ),
  28. ),
  29. );
  30. }
  31. }
  32.  
  33. class SecondRoute extends StatelessWidget {
  34. @override
  35. Widget build(BuildContext context) {
  36. return Scaffold(
  37. appBar: AppBar(
  38. title: Text("Second Route"),
  39. ),
  40. body: Center(
  41. child: ElevatedButton(
  42. onPressed: () {
  43. Navigator.pop(context);
  44. },
  45. child: Text('Go back!'),
  46. ),
  47. ),
  48. );
  49. }
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement