GgRouter constructor

GgRouter(
  1. Map<String, Widget Function(BuildContext)> children, {
  2. required Key key,
  3. Map<String, String> semanticLabels = const {},
  4. String? defaultRoute,
  5. GgAnimationBuilder? inAnimation,
  6. GgAnimationBuilder? outAnimation,
  7. Duration animationDuration = const Duration(milliseconds: 500),
})

Constructor, which takes a map of child routes. Depending on the currently selected routed one of the child routes is shown.

To animate widgets when switching a route, specify an inAnimation and an outAnimation. The first is applied to the widget appearing on the screen. The second is applied to the one disappearing.

GgRouter({
  '_INDEX_': (context) => Text('The index screen'),
  'green':   (context) => Container(color: Colors.green),
  'yellow':  (context) => Container(color: Colors.red),
  'red':     (context) => Container(color: Colors.red),
})

Implementation

GgRouter(
  this.children, {
  required Key key,
  this.semanticLabels = const {},
  this.defaultRoute,
  this.inAnimation,
  this.outAnimation,
  this.animationDuration = const Duration(milliseconds: 500),
})  : _rootChild = null,
      _rootNode = null,
      super(key: key) {
  _checkChildren();
  _checkAnimations();
  _checkSemanticLabels();
}