11. 플러터 화면 이동
2022. 7. 7. 19:22ㆍ플러터(Flutter)
import 'package:flutter/material.dart';
class FirstPage extends StatelessWidget {
const FirstPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('FirstPage'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) {
return SecondPage();
}));
},
child: Text('Go to Second Page'),
),
),
);
}
}
class SecondPage extends StatelessWidget {
const SecondPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('SecondPage'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: Text('Go to First Page'),
),
),
);
}
}
* GitHub
https://github.com/MoonG7/studyflutter/blob/main/lib/navigatorTest.dart
'플러터(Flutter)' 카테고리의 다른 글
network image rounded corner 적용(코너 라운드) (0) | 2022.07.17 |
---|---|
12. Future, Async, await (0) | 2022.07.08 |
10. 플러터 토스트창 테스트 (0) | 2022.07.07 |
9. 플러터 이미지 넣기 (0) | 2022.07.07 |
8. 플러터 텍스트 스타일 (0) | 2022.07.07 |