init method

void init({
  1. required Navigator navigator,
  2. FeedbacksExecutor? feedbacksExecutor,
  3. bool withDebugDashboard = false,
  4. String? rootAppRoute,
  5. List<BuzzRegistry> initialRegistries = const [],
})

Implementation

void init({
  required Navigator navigator,
  FeedbacksExecutor? feedbacksExecutor,
  bool withDebugDashboard = false,
  String? rootAppRoute,
  List<BuzzRegistry> initialRegistries = const [],
}) {
  this.navigator = navigator;
  this.feedbacksExecutor = feedbacksExecutor;

  Buzz.on().listen(
    (event) => buzzLog('event fired:  ${event.runtimeType}'),
  );

  registries.addAll(initialRegistries);

  if (withDebugDashboard) {
    if (rootAppRoute == null) {
      throw ArgumentError(
        'rootAppRoute cannot be null when withDebugDashboard is true',
      );
    }

    registries.add(EventsDashboardBuzzRegistry(mainAppRoute: rootAppRoute));
  }

  registries.add(
    NavigationBuzzRegistry(
      navigator: navigator,
      backDefault: navigator.backDefaultRoute,
    ),
  );
  if (feedbacksExecutor != null) {
    registries.add(
      FeedbacksExecutorBuzzRegistry(feedbacksExecutor: feedbacksExecutor),
    );
  }

  for (var element in registries) {
    buzzLog('register: $element');
    element.register(this);
  }

  initDone = true;
}