The examples of the book don’t work with the current versions of Flutter. Until 3.10 you could patch around and get things going but as of 3.13 there’s no way.
See the issues and output with the current version, and a section on how to run the examples with the Flutter SDK current at the publishing date of the booking.
Took me a long time, maybe this helps others.
Current version of Flutter
Flutter (Channel stable, 3.13.7, on Arch Linux 6.5.6-arch2-1, locale de_DE.UTF-8)
Project build through make clean get build-runner
is failing:
Because every version of component_library from path depends on intl ^0.17.0 and every version of flutter_localizations from sdk depends on intl 0.18.1, component_library from path is incompatible with
flutter_localizations from sdk.
So, because wonder_words depends on both flutter_localizations from sdk and component_library from path, version solving failed.
Add to pubspec.yaml:
dependency_overrides:
intl: ^0.18.1
Project build through make clean get build-runner
is passing.
Various errors in Android Studio
component_library/example
→ Deletemain.dart
- The type of ‘_favQsApi’ can’t be inferred because it depends on itself through the cycle: _favQsApi, _userRepository.
- The type of ‘_userRepository’ can’t be inferred because it depends on itself through the cycle: _favQsApi, _userRepository.
- The type of ‘_routerDelegate’ can’t be inferred because it depends on itself through the cycle: _routerDelegate.
→ Add type to declarations
- ‘SearchBar’ isn’t a function. in quote_list
→ Changeimport 'package:flutter/material.dart' hide SearchBar;
test
packages with errors
→ Delete
Launching fails with
Launching lib/main.dart on sdk gphone64 x86 64 in debug mode...
Upgrading build.gradle
Conflict detected between Android Studio Java version and Gradle version, upgrading Gradle version from 6.7 to 7.6.1.
Upgrading gradle-wrapper.properties
Running Gradle task 'assembleDebug'...
Warning: The plugin integration_test requires Android SDK version 33.
For more information about build configuration, see https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
One or more plugins require a higher Android SDK version.
Fix this issue by adding the following to /mnt/Development/flutter/projects/others/rwf-materials/08-deep-linking/projects/starter/android/app/build.gradle:
android {
compileSdkVersion 33
...
}
/home/user/.pub-cache/hosted/pub.dev/sliver_tools-0.2.6/lib/src/sliver_stack.dart:282:55: Error: A value of type 'RenderObject?' can't be assigned to a variable of type 'AbstractNode?'.
- 'RenderObject' is from 'package:flutter/src/rendering/object.dart' ('../../../../../../sdk/flutter/packages/flutter/lib/src/rendering/object.dart').
- 'AbstractNode' is from 'package:flutter/src/foundation/node.dart' ('../../../../../../sdk/flutter/packages/flutter/lib/src/foundation/node.dart').
final AbstractNode? targetParent = renderObject.parent;
^
/home/user/.pub-cache/hosted/pub.dev/sliver_tools-0.2.6/lib/src/sliver_stack.dart:283:54: Error: The method 'markNeedsLayout' isn't defined for the class 'AbstractNode?'.
- 'AbstractNode' is from 'package:flutter/src/foundation/node.dart' ('../../../../../../sdk/flutter/packages/flutter/lib/src/foundation/node.dart').
Try correcting the name to the name of an existing method, or defining a method named 'markNeedsLayout'.
if (targetParent is RenderObject) targetParent.markNeedsLayout();
^^^^^^^^^^^^^^^
Target kernel_snapshot failed: Exception
FAILURE: Build failed with an exception.
* Where:
Script '/mnt/Development/flutter/sdk/flutter/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy' line: 1297
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/mnt/Development/flutter/sdk/flutter/bin/flutter'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 27s
Exception: Gradle task assembleDebug failed with exit code 1
Everything goes downhill from here: There’s no way to make the app running again without recreating the project.
Version of the time of publishing
Flutter (Channel stable, 3.3.0, on Arch Linux 6.5.6-arch2-1, locale de_DE.UTF-8) via Flutter SDK archive
Add to makefile
:
JAVA_HOME := /usr/lib/jvm/java-11-openjdk
FLUTTER_BIN := /mnt/Development/flutter/projects/others/rwf-materials/sdk/flutter/bin
PATH := /usr/bin:$(FLUTTER_BIN)
Project build through make clean get build-runner
is passing.
Set Flutter SDK in Android Studio: Languages → Flutter → Flutter SDK path
Set Java in Run Configuration through Environment variable JAVA_HOME=/usr/lib/jvm/java-11-openjdk
Still various compile errors in Android Studio, affects test
and component_library/example
.
→ Delete
App runs in emulator despite reporting deprecation warnings:
Launching lib/main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
Note: /mnt/Development/flutter/projects/others/rwf-materials/sdk/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-4.2.1/android/src/main/java/com/it_nomads/fluttersecurestorage/FlutterSecureStoragePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /mnt/Development/flutter/projects/others/rwf-materials/sdk/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_remote_config-2.0.11/android/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfig/FirebaseRemoteConfigPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /mnt/Development/flutter/projects/others/rwf-materials/sdk/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_analytics-9.1.12/android/src/main/java/io/flutter/plugins/firebase/analytics/FlutterFirebaseAnalyticsPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /mnt/Development/flutter/projects/others/rwf-materials/sdk/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_dynamic_links-4.3.1/android/src/main/java/io/flutter/plugins/firebase/dynamiclinks/FlutterFirebaseDynamicLinksPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...
...