Build error after upgrading Flutter

eye-catchDart and Flutter
Sponsored links

When I upgraded Flutter from 2.2.3 to 2.5.0 debug console showed a lot of build errors. I didn’t understand what caused the problem at first. I upgraded Flutter with following command.

flutter upgrade

After the process completed I got following error messages.

../../../../../Software/flutter/packages/flutter/lib/src/painting/inline_span.dart:89:14: Error: Type 'ui.StringAttribute' not found.
  final List<ui.StringAttribute> stringAttributes;
             ^^^^^^^^^^^^^^^^^^
../../../../../Software/flutter/packages/flutter/lib/src/semantics/semantics.dart:204:14: Error: Type 'StringAttribute' not found.
  final List<StringAttribute> attributes;
             ^^^^^^^^^^^^^^^
../../../../../Software/flutter/packages/flutter/lib/src/painting/inline_span.dart:59:39: Error: 'StringAttribute' isn't a type.
    this.stringAttributes = const <ui.StringAttribute>[],
                                      ^^^^^^^^^^^^^^^
../../../../../Software/flutter/packages/flutter/lib/src/scheduler/binding.dart:1104:29: Error: The getter 'frameNumber' isn't defined for the class 'FrameTiming'.
 - 'FrameTiming' is from 'dart:ui'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'frameNumber'.
      'number': frameTiming.frameNumber,
...

I don’t know how many errors there were. What I do was following.

Sponsored links

Check the current Flutter channel

I checked flutter channel because I wanted to make sure that the current version is stable one.

$ flutter channel
Flutter channels:
  master
  dev
  beta
* stable
Sponsored links

Cleanup repository

Many artifacts are created during our development and those files are in our repository. Let’s delete those files.

$ flutter clean
Deleting build...                                                    9ms
Deleting .dart_tool...                                               3ms
Deleting .packages...                                                1ms
Deleting Generated.xcconfig...                                       1ms
Deleting flutter_export_environment.sh...                            1ms
Deleting .flutter-plugins-dependencies...                            1ms
Deleting .flutter-plugins...                                         1ms

Upgrade dependencies

The dependencies used for the application might be obsolete and they might break it. Let’s update them. This step is written in official page.

$ flutter pub upgrade
Resolving dependencies...
  async 2.8.1 (2.8.2 available)
  boolean_selector 2.1.0
  characters 1.1.0
  charcode 1.3.1
  clock 1.1.0
  collection 1.15.0
  cupertino_icons 1.0.3
  fake_async 1.2.0
  flutter 0.0.0 from sdk flutter
  flutter_localizations 0.0.0 from sdk flutter
  flutter_rating_stars 1.0.3+4
  flutter_test 0.0.0 from sdk flutter
  intl 0.17.0
> lint 1.7.2 (was 1.5.3)
  matcher 0.12.10 (0.12.11 available)
  meta 1.7.0
  nested 1.0.0
  path 1.8.0
  provider 5.0.0 (6.0.0 available)
  sky_engine 0.0.99 from sdk flutter
  source_span 1.8.1
> sqflite 2.0.0+4 (was 2.0.0+3)
> sqflite_common 2.0.1+1 (was 2.0.0+2)
  stack_trace 1.10.0
  stream_channel 2.1.0
  string_scanner 1.1.0
  synchronized 3.0.0
  term_glyph 1.2.0
  test_api 0.4.2 (0.4.3 available)
  typed_data 1.3.0
  vector_math 2.1.0
Downloading lint 1.7.2...
Downloading sqflite 2.0.0+4...
Downloading sqflite_common 2.0.1+1...
Changed 3 dependencies!
4 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.

As you can see the result, there were still outdated dependencies after upgrading them. Let’s execute the command.

$ flutter pub outdated
Showing outdated packages.
[*] indicates versions that are not the latest available.

Package Name  Current   Upgradable  Resolvable  Latest   

direct dependencies:
async         *2.8.1    *2.8.1      *2.8.1      2.8.2
provider      *5.0.0    *5.0.0      6.0.0       6.0.0

transitive dev_dependencies:
matcher       *0.12.10  *0.12.10    *0.12.10    0.12.11
test_api      *0.4.2    *0.4.2      *0.4.2      0.4.3

1 dependency is constrained to a version that is older than a resolvable version.
To update it, edit pubspec.yaml, or run `flutter pub upgrade --major-versions`.

Then, upgrade.

$ flutter pub upgrade --major-versions
Resolving dependencies...
  async 2.8.1 (2.8.2 available)
  boolean_selector 2.1.0
  characters 1.1.0
  charcode 1.3.1
  clock 1.1.0
  collection 1.15.0
  cupertino_icons 1.0.3
  fake_async 1.2.0
  flutter 0.0.0 from sdk flutter
  flutter_localizations 0.0.0 from sdk flutter
  flutter_rating_stars 1.0.3+4
  flutter_test 0.0.0 from sdk flutter
  intl 0.17.0
  lint 1.7.2
  matcher 0.12.10 (0.12.11 available)
  meta 1.7.0
  nested 1.0.0
  path 1.8.0
> provider 6.0.0 (was 5.0.0)
  sky_engine 0.0.99 from sdk flutter
  source_span 1.8.1
  sqflite 2.0.0+4
  sqflite_common 2.0.1+1
  stack_trace 1.10.0
  stream_channel 2.1.0
  string_scanner 1.1.0
  synchronized 3.0.0
  term_glyph 1.2.0
  test_api 0.4.2 (0.4.3 available)
  typed_data 1.3.0
  vector_math 2.1.0
Downloading provider 6.0.0...
Changed 1 dependency!
3 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.

Changed 1 constraint in pubspec.yaml:
  provider: ^5.0.0 -> ^6.0.0

There are some packages that are still not latest version.

$ flutter pub outdated
Showing outdated packages.
[*] indicates versions that are not the latest available.

Package Name  Current   Upgradable  Resolvable  Latest   

direct dependencies:
async         *2.8.1    *2.8.1      *2.8.1      2.8.2

transitive dev_dependencies:
matcher       *0.12.10  *0.12.10    *0.12.10    0.12.11
test_api      *0.4.2    *0.4.2      *0.4.2      0.4.3
You are already using the newest resolvable versions listed in the 'Resolvable' column.
Newer versions, listed in 'Latest', may not be mutually compatible.

But I didn’t update them because build error disappeared.

Repair cache

I executed this command before upgrading dependencies. Try to execute this command if build error still occurs.

$ flutter pub pub cache repair
Downloading xml 5.1.0...
Downloading xml 5.1.2...
Downloading web_socket_channel 2.1.0...
Downloading xdg_directories 0.2.0...
Downloading webkit_inspection_protocol 1.0.0...
Downloading vm_snapshot_analysis 0.7.0...
Downloading yaml 3.1.0...
Downloading win32 2.0.5...
Downloading vm_service 6.2.0...
Downloading vm_service 7.1.1...
Downloading webdriver 3.0.0...
Downloading watcher 1.0.0...
Downloading video_player_web 2.0.0...
Downloading video_player_platform_interface 4.1.0...
Downloading vector_math 2.1.0...
Downloading video_player 2.1.1...
Downloading uuid 3.0.4...
Downloading url_launcher_web 2.0.0...
Downloading url_launcher_windows 2.0.0...
Downloading usage 4.0.2...
Downloading url_launcher_platform_interface 2.0.2...
Downloading url_launcher_macos 2.0.0...
Downloading url_launcher_linux 2.0.0...
Downloading url_launcher 6.0.3...
Downloading typed_data 1.3.0...
Downloading test_core 0.3.19...
Downloading test_core 0.4.0...
Downloading test_api 0.3.0...
Downloading test_api 0.4.2...
Downloading test 1.17.10...
Downloading term_glyph 1.2.0...
Downloading synchronized 3.0.0...
Downloading sync_http 0.3.0...
Downloading string_scanner 1.1.0...
Downloading stream_channel 2.1.0...
Downloading stack_trace 1.10.0...
Downloading sse 3.8.3...
Downloading sse 4.1.0...
Downloading sqflite_common 2.0.0+2...
Downloading sqflite 2.0.0+3...
Downloading source_span 1.8.1...
Downloading source_maps 0.10.10...
Downloading smooth_star_rating 1.1.1...
Downloading simple_star_rating 0.0.3...
Downloading shrine_images 1.1.2...
Downloading source_map_stack_trace 2.1.0...
Downloading shelf_web_socket 1.0.1...
Downloading shelf_static 1.0.0...
Downloading shelf_static 1.1.0...
Downloading shelf_proxy 1.0.0...
Downloading shelf_packages_handler 3.0.0...
Downloading shelf 1.1.1...
Downloading shelf 1.1.4...
Downloading quiver 2.1.5...
Downloading pub_semver 2.0.0...
Downloading provider 5.0.0...
Downloading pool 1.5.0...
Downloading pubspec_parse 1.0.0...
Downloading process_runner 4.0.1...
Downloading plugin_platform_interface 2.0.0...
Downloading platform 3.0.0...
Downloading process 4.2.1...
Downloading process 4.2.3...
Downloading pedantic 1.11.0...
Downloading pedantic 1.11.1...
Downloading petitparser 4.1.0...
Downloading petitparser 4.2.0...
Downloading path_provider_windows 2.0.1...
Downloading path_provider_platform_interface 2.0.1...
Downloading path_provider_macos 2.0.0...
Downloading path_provider_linux 2.0.0...
Downloading path_provider 2.0.1...
Downloading path 1.8.0...
Downloading package_config 2.0.0...
Downloading node_preamble 2.0.0...
Downloading node_preamble 2.0.1...
Downloading nested 1.0.0...
Downloading native_stack_traces 0.4.0...
Downloading native_stack_traces 0.4.3...
Downloading mustache_template 2.0.0...
Downloading multicast_dns 0.3.0...
Downloading mockito 4.1.1+1...
Downloading mime 1.0.0...
Downloading meta 1.3.0...
Downloading meta 1.7.0...
Downloading matcher 0.12.10...
Downloading logging 1.0.1...
Downloading lint 1.5.3...
Downloading json_rpc_2 2.2.2...
Downloading json_rpc_2 3.0.1...
Downloading json_annotation 4.0.1...
Downloading json_annotation 4.1.0...
Downloading js 0.6.3...
Downloading isolate 2.0.3...
Downloading io 1.0.0...
Downloading io 1.0.3...
Downloading intl 0.17.0...
Downloading image 3.0.2...
Downloading http_parser 4.0.0...
Downloading http_multi_server 3.0.1...
Downloading http 0.13.3...
Downloading glob 2.0.1...
Downloading frontend_server_client 2.1.0...
Downloading html 0.15.0...
Downloading flutter_template_images 1.0.1...
Downloading flutter_template_images 4.0.0...
Downloading flutter_rating_stars 1.0.3+4...
Downloading flutter_rating_bar 4.0.0...
Downloading fixnum 0.10.11...
Downloading fixnum 1.0.0...
Downloading file_testing 3.0.0...
Downloading flutter_gallery_assets 1.0.2...
Downloading file 6.1.0...
Downloading file 6.1.2...
Downloading ffi 1.0.0...
Downloading fake_async 1.2.0...
Downloading dwds 11.0.2...
Downloading dwds 11.2.0...
Downloading devtools_shared 2.4.0...
Downloading device_info_platform_interface 2.0.1...
Downloading device_info 2.0.0...
Downloading dds 1.7.6...
Downloading dds 2.0.3...
Downloading dart_style 2.0.1...
Downloading cupertino_icons 1.0.3...
Downloading csslib 0.17.0...
Downloading crypto 3.0.1...
Downloading coverage 1.0.2...
Downloading coverage 1.0.3...
Downloading convert 3.0.0...
Downloading convert 3.0.1...
Downloading connectivity_macos 0.2.0...
Downloading connectivity_for_web 0.4.0...
Downloading connectivity_platform_interface 2.0.1...
Downloading connectivity 3.0.3...
Downloading completion 1.0.0...
Downloading collection 1.15.0...
Downloading clock 1.1.0...
Downloading cli_util 0.3.0...
Downloading cli_util 0.3.3...
Downloading checked_yaml 2.0.1...
Downloading charcode 1.2.0...
Downloading charcode 1.3.1...
Downloading characters 1.1.0...
Downloading camera 0.5.8+17...
Downloading built_value 7.1.0...
Downloading built_value 8.1.1...
Downloading built_collection 4.3.2...
Downloading built_collection 5.1.0...
Downloading browser_launcher 1.0.0...
Downloading boolean_selector 2.1.0...
Downloading battery_platform_interface 2.0.1...
Downloading battery 2.0.1...
Downloading async 2.6.1...
Downloading async 2.8.1...
Downloading archive 3.1.2...
Downloading args 2.1.0...
Downloading args 2.2.0...
Downloading analyzer 1.5.0...
Downloading analyzer 2.0.0...
Downloading _fe_analyzer_shared 21.0.0...
Downloading _fe_analyzer_shared 23.0.0...

Reinstalled 162 packages.

Failed to start DevTools

If DevTools fails to start, this post solves the problem.

Comments

Copied title and URL