layout 이용해 코드 중복제거하기
중복되는 코드를 main_layout.dart 파일로 따로 생성해준다
해당 코드 안에서 중복되지 않는 변수들은 아래처럼 정의해준다
class MainLayout extends StatelessWidget {
final String title;
final List<Widget> children;
const MainLayout({required this.title, required this.children, Key? key})
: super(key: key);
Navigator를 이용해 Home Screen에서 Push 버튼을 누르면
RouteOne Screen으로 넘어가고
Pop 버튼을 누르면 다시 Home Screen으로 돌아온다
'CS > Flutter | Dart' 카테고리의 다른 글
push 메소드 - pushReplacement, pushReplacementNamed, pushAndRemoveUntil, pushNamedAndRemoveUntil (0) | 2023.07.26 |
---|---|
Named Route - PushNamed (0) | 2023.07.26 |
Flutter Button 스타일링 - ElevatedButton, OutlinedButton, TextButton (0) | 2023.07.25 |
랜덤 숫자 생성기 (0) | 2023.07.24 |
const constructor (1) | 2023.07.23 |