[getx] Route management / Parameter / Page Navigation > Flutter/Dart/Node

본문 바로가기
사이트 내 전체검색

Flutter/Dart/Node

[getx] Route management / Parameter / Page Navigation

페이지 정보

작성자 sbLAB 댓글 0건 조회 3,364회 작성일 22-12-18 22:07

본문




 //[main.dart]
  //MyApp
  class MyApp extends StatelessWidget {
    const MyApp({Key? key}) : super(key: key);

    @override
    Widget build(BuildContext context) {
      return GetMaterialApp(
        home: ListViewPage(),
        initialRoute: "/",
          getPages: [
            GetPage(name: "/", page:() => GetxHomePage()),
            GetPage(name: "/getxfirstnormal", page:() => GetxFirstNomalPage()),
            GetPage(name: "/getxsecondparam", page:() => GetxSecondParamPage()),
//URL parameters 형식으로 전달할 경우
GetPage(name: "/getxsecondparam/:uid", page:() => GetxSecondParamPage()),
          ],
      );
 
 




//[getxhome.dart]
  ...
              ElevatedButton(
                child: Text('페이지 파리미터 전달 라우팅'),
                onPressed: () {
               //getxsecondparam 페이지에 Avatar 문자열(String) 파라미터값 전달
               Get.toNamed("getxsecondparam",arguments:"Avatar");                

               //getxsecondparam 페이지에 2022 숫자형(int) 파라미터값 전달
               Get.toNamed("getxsecondparam",arguments:2022);

               //getxsecondparam 페이지에 {"title":"Avatar", "year":2022} Map형 파라미터값 전달
               Get.toNamed("getxsecondparam",arguments:{"title":"Avatar", "year":2022});

               //data-class model instance 파라미터값 전달
               MovieModel movieModel = MovieModel(title:"Avatar", year:2022);
               Get.toNamed("getxsecondparam",arguments:movieModel);

              //getxsecondparam 페이지에 url 파라미터값(99999) 전달
            Get.toNamed("/getxsecondparam/99999");
              //Get.toNamed("/getxsecondparam/99999?title=avatar&year=2022"); 형태도 가능
                },
              ),
  ...
 



//[getxsecondparam.dart]
  ...
  body: Center(
            child : Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
 Text('GetxSecondParamPage'),
 Text('${Get.arguments}'), //{title:Avater, year:2022}
 Text('${Get.arguments['title']} -- ${Get.arguments['year']}'), //Avatar -- 2022
 Text('${(Get.arguments as MovieModel).title} ** ${(Get.arguments as MovieModel).year}'),//Avatar -- 2022

 //URL parameters 형식으로 전달한 변수를 받을때
 Text('${Get.parameters['uid']}'),
//Get.toNamed("/getxsecondparam/99999?title=avatar&year=2022");
===> Text('${Get.parameters['uid']} - ${Get.parameters['title']} - ${Get.parameters['year']}'),

         ElevatedButton(
                  child: Text('뒤로가기'),
                  onPressed: (){
                  Get.back();
                  },
                ),
              ],
        ),
        ),
  ...
 


[GetX] Route management
  https://dev-yakuza.posstree.com/en/flutter/getx/route/#getoffnamed

 Get.until
  Remove screens until satisfying the condition.
  It’s the same with Navigation.popUntil().
  You can use it like Get.until((route) => Get.currentRoute == '/home').

 Get.off
  Remove the current screen and add a new screen.
  It’s the same with Navigation.pushReplacement().
  You can use it like Get.off(Second()).

 Get.offNamed
  By the Named route, remove the current screen and add a new screen.
  It’s the same with Navigation.pushReplacementNamed().
  You can use it like Get.offNamed('/second').

 Get.offAndToNamed
  By the Named route, add a new screen and then, remove the previous screen.
  It’s the same with Navigation.popAndPushNamed().
  You can use it like Get.offAndToNamed('/second').

  Get.offUntil
  Remove screens until satisfying the condition, and then, add a new screen.
  It’s the same with Navigation.pushAndRemoveUntil().
  You can use it like Get.offUntil(page, (route) => (route as GetPageRoute).routeName == '/home').

  Get.offNamedUntil
  By the Named route, remove screens until satisfying the condition, and then, add a new screen.
  It’s the same with Navigation.pushNamedAndRemoveUntil().
  You can use it like Get.offNamedUntil(page, ModalRoute.withName('/home')).

  Get.removeRoute
  Remove the screen that is satisfied the condition.
  It’s the same with Navigation.removeRoute().
  You can use it like Get.removeRoute(ModalRoute.withName('/home')).

  Get.offAll
  Remove all screens and then, add a new screen.
  It’s the same with Navigation.pushNamedAndRemoveUntil().
  You can use it like Get.offAll(Second()).

  Get.offAllNamed
  By the Named route, remove all screens and then, add a new screen.
  It’s the same with Navigation.pushNamedAndRemoveUntil().
  You can use it like Get.offAllNamed('/second').



https://gist.github.com/eduardoflorence/9ef5035ac7e57eb2f15ceabcae430538 


https://www.fluttercampus.com/guide/121/how-to-add-transition-on-flutter-navigations-easy-way/ 


https://www.youtube.com/watch?v=OXfG-D4PNpQ&list=PLgRxBCVPaZ_3bPtdyE0Tj-w1CFX01bgUE&index=2&ab_channel=%EA%B0%9C%EB%B0%9C%ED%95%98%EB%8A%94%EB%82%A8%EC%9E%90 


댓글목록

등록된 댓글이 없습니다.

회원로그인

접속자집계

오늘
24
어제
417
최대
1,279
전체
220,795

그누보드5
Copyright © sebom.com All rights reserved.