Navigation

without named routes

~~Get.to(CounterPage()));~~
Get.to(()=> CounterPage());

Get.back();

Get.off(CounterPage());  // popUntil
Get.off(() => CounterPage());  // popUntil

Get.offAll(CounterPage()); // popAll

공식 페이지에서는 Get.to(Component()) 형식으로 사용하라고 되어 있는데,

실제 사용시 아래와 같이 Get.to(() => Component()) 형식으로 사용하라고 Warning 발생한다.

스크린샷 2023-05-02 오후 12.01.37.png

GetMaterialApp level에서 이름을 지정해 Named로 Routing 할 수 있음

with named routes

Get.toNamed('/counterPage');
Get.toNamed('/counterPage', arguments: 'Get is the best');

Get.offNamed('/counterPage');

Get.offAllNamed("/counterPage");

unknownRoute handling

void main() {
  runApp(
    GetMaterialApp(
			unknownRoute: GetPage(name: '/notfound', page: () => UnknownRoutePage()),
      initialRoute: '/',
      getPages: [
        GetPage(name: '/', page: () => MyHomePage()),
        GetPage(
          name: '/third',
          page: () => Third(),
          transition: Transition.zoom  
        ),
      ],
    )
  );
}

dynamic urls links

Get.offAllNamed('/counterPage?name=Enzo')
print(Get.parameters['name']);  // out: Enzo

------------
Getpage(
	name: '/profile/:user',
	page: () => UserProfile(),
)

Get.toNamed('/profile/34954');
print(Get.parameters['user']); // out: 35954