How to make the examples work

Actually you can run book’s projects without it’s recreating on the up-to-date version of Flutter 3.13.6.

Here is a complete list of fixes you need to make after opening a clean starter project in the code editor (tested on Windows 11 22H2 and VS Code 1.83.1):

  1. As suggested in this post add explicit FavQsApi and RoutemasterDelegate types to the main file:
lib\main.dart

line 79
late final _favQsApi = FavQsApi(
→ (change to)
late final FavQsApi _favQsApi = FavQsApi(

line 91
late final _routerDelegate = RoutemasterDelegate(
→
late final RoutemasterDelegate _routerDelegate = RoutemasterDelegate(
  1. Update the intl package version for two local packages:
packages\component_library\pubspec.yaml
packages\features\profile_menu\pubspec.yaml

intl: ^0.17.0
→ 
intl: ^0.18.1
  1. Bump infinite_scroll_pagination package version since it uses outdate sliver_tools package:
packages\features\quote_list\pubspec.yaml

infinite_scroll_pagination: ^4.0.0-dev.1
→
infinite_scroll_pagination: ^4.0.0
  1. Update gradle and google-services versions to build the project correctly:
android\build.gradle

classpath 'com.android.tools.build:gradle:4.1.0'
→
classpath 'com.android.tools.build:gradle:7.4.1'

classpath 'com.google.gms:google-services:4.3.10'
→
classpath 'com.google.gms:google-services:4.3.14'
  1. Raise compileSdkVersion to current value:
android\app\build.gradle

line 31
compileSdkVersion 31
→
compileSdkVersion 33
  1. All dependencies in monitoring package need to be updated—replace whole dependencies section with the following (leave dev_dependencies as is):
packages\monitoring\pubspec.yaml

dependencies:
  …
→
dependencies:
  flutter:
    sdk: flutter
  firebase_core: ^2.17.0
  firebase_crashlytics: ^3.3.7
  firebase_dynamic_links: ^5.3.7
  firebase_analytics: ^10.5.1
  firebase_remote_config: ^4.2.7
  1. As discussed here rename (with F2 button) SearchBar class with something different to avoid a name collision:
packages\component_library\lib\src\search_bar.dart

line 4
SearchBar
→
AppSearchBar
  1. Finally you can get packages:
    make get

On Windows you may need to use Git Bash terminal instead of default PowerShell to run this command successfully—here are the details.

That’s all! Now you can build and run projects without problems (after fixing all the suggested in the book’s chapter issues of course if you have opened a starter project).

2 Likes