Explanation on flutter nameRoute

Viewed 57

Hello please can someone explain this to me. I got it in a tutorial but the explanation is not clear. my question is why passing 1 in to a path[1] array its kinna confusing. I understand this: final path = settings.name.split('/'); but the final title got me lost and this books.firstWhere((it) is it a keyword in flutter please someone help me understand.

 ///Generate parameterized route --> e.g: detail/some book title
  generateRoute(RouteSettings settings) {
    final path = settings.name.split('/');
    final title = path[1];

    Book book = books.firstWhere((it) => it.title == title);
    return MaterialPageRoute(
      settings: settings,
      builder: (context) => Detail(book),
    );
  }
}
0 Answers
Related