Chapter 10 won't build

ERROR: ../../.pub-cache/hosted/pub.dev/flutter_html-3.0.0/lib/src/tree/styled_element.dart:31:17: Error: Method not found: ‘matches’.
ERROR: return qs.matches(element, selector);
ERROR: ^^^^^^^
ERROR: Target kernel_snapshot_program failed: Exception
Error: Build process failed
App failed to start

This is the message I get when trying to run the chapter 10 project.

Anybody have any ideas where to start with this?

This seems to be a dependency incompatibility between what the books code has and what you have. What does your flutter_html contain? try updating to latest and then do the old:

flutter clean
rm -rf pubspec.lock .dart_tool
flutter pub get
flutter run

@spgms

I tried the flutter clean steps to no avail.

I ran: flutter pub run build_runner build --delete-conflicting-outputs

That seemed to generate some new freeze output files.

I am getting a lot of ‘undefined variables’ messages now.

I have to get up to speed with the freeze package and see what is going on with that.

Thanks for your help.

I’ll work on seeing how this freeze/json code works.

These are the steps I took to repair chap 10 starter app.

  1. flutter create starter
    This will give you a clean project so you can avoid some error messages
    about gradle versions and index.html.
    starter matches the name in the pubspec.yaml. See below.

  2. Copy over /assets and /lib from the original project.
    That is all you need from the old folder. So far at least.

  3. Replace the pubspec.yaml
    flutter_html 3.0.0 has a problem. This is what breaks the build.
    [BUG] Build broken by html 0.15.7: Method not found: 'matches' in styled_element.dartError · Issue #1522 · Sub6Resources/flutter_html · GitHub

Notice in pubspec.yaml it is ‘flutter_html: 3.0.0-beta.2’ , no circumflex.
The circumflex causes flutter to bring in 3.0.0, which has a problem.

Notice also the pubspec.yaml has a lot of upgrades to the latest and greatest
packages. Most these are needed for a good result. Especially the riverpod
and freeze stuff.

vs code does a pretty good job of fetching packages, but don’t be
afraid to do:
flutter clean
rm -rf pubspec.lock .dart_tool
flutter pub get

  1. freeze stuff
    Search for @freeze functions.
    Append abstract to each of these. The latest version apparently needs this.
    vs code highlights a lot of these errors.

Generated freeze files need regeneration.
dart run build_runner clean
dart run build_runner build

  1. vs code fixed a bunch of super.key red flags. Take advantage.

  2. image path curiosities
    Errors will show up at run-time about not locating images.
    Should it be /assets/images… or /images…
    Do the cut and paste fix ups.

  3. Click on main and run the app. It should come up now.


pubspec.yaml

name: starter
description: “A new Flutter project.”

publish_to: ‘none’

version: 1.0.0+1

environment:
sdk: ^3.13.3

dependencies:
flutter:
sdk: flutter
freezed_annotation: ^3.1.0
json_annotation: ^4.12.0
colorize_lumberdash: ^3.0.0
desktop_window: ^0.4.4
flutter_riverpod: ^3.4.3
lumberdash: ^3.0.0
logging: ^1.3.0
cupertino_icons: ^1.0.9
flutter_svg: ^2.3.0
#adaptive_scaffold_plus: ^1.1.1
flutter_adaptive_scaffold: ^0.1.6
auto_size_text: ^3.0.0
cached_network_image: ^4.0.0
flutter_html: 3.0.0-beta.2
#flutter_html: 3.0.0
flutter_slidable: ^4.0.3

dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^2.16.1
freezed: ^4.0.1
json_serializable: ^6.14.1
flutter_lints: ^6.0.0

flutter:
uses-material-design: true

One more point:

providers.dart has a problem function which you should comment out.

Needs some work.

/* final repositoryProvider = ChangeNotifierProvider((ref) {

return MemoryRepository();

});

*/

Hi! Sorry, I missed these messages. Let me see if I can find a quick solution.

There were more things than @rttngmsft had that needed updated. I have the starter project done, but still need to work through the chapter to get the final project done. This will impact future chapters and text for the chapters.

cc: @robertomachorro