Submitted by rifki_cs29 in flutter

Terkadang kita perlu navigasi dari logika bisnis Anda di mana context tidak tersedia. Berikut solusinya (Navigation tanpa Context) :

final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
 
class Navigation {
  static intentWithData(String routeName, Object arguments) {
    navigatorKey.currentState.pushNamed(routeName, arguments: arguments);
  }
 
  static back() => navigatorKey.currentState.pop();
}

Berikut penggunaannya misal ~~~html
var article = data.articles[0]; Navigation.intentWithData(route, article);

6

Comments

You must log in or register to comment.

There's nothing here…