Hi, I'm getting this error below since updating to flutter 2.0.0. CartP
flutter --version
Flutter 2.0.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 60bd88df91 (6 days ago) • 2021-03-03 09:13:17 -0800
Engine • revision 40441def69
Tools • Dart 2.12.0
[SEVERE] json_serializable:json_serializable on lib/datamodels/application_models.dart:
Could not generate toJson code for merchants because of type Merchant.
This was working before and we had no problems. Merchant is a basic class. I'm putting the entire class below in case it's relevant.
@freezed
abstract class Merchant with _$Merchant {
Merchant._();
factory Merchant({
int id,
String name,
double rating,
int deliveryFee,
List<List<int>> availableTimes,
/// [territory], [territoryId], [territoryAvialableTimes] and [territoryTimeZone] is not set from the response.
/// It gets set locally when we get [getMerchantForId] on the [MerchantService]
String territory,
int territoryId,
List<List<int>> territoryAvailableTimes,
String territoryTimeZone,
@JsonKey(toJson: toNull, includeIfNull: false) int currentDeliveryTime,
String address,
String city,
List<String> cuisines,
String state,
double latitude,
double longitude,
String headerImageUrl,
String image,
double position,
// Ignore the value coming in because it comes in as a bool and we cannot store bools in
// sqlite
@JsonKey(ignore: true) int hideCustomizations,
String logo,
@JsonKey(name: 'display_name') String displayName,
/// Stores the opening time as a string
@JsonKey(ignore: true) DateTime firstAvailableTime,
}) = _Merchant;
bool get hasPhoto => !isNullOrEmpty(image);
factory Merchant.fromJson(Map<String, dynamic> incomingJson) {
var jsonPayload = Map<String, dynamic>.from(incomingJson);
if (jsonPayload['availableTimes'] is String) {
jsonPayload['availableTimes'] =
json.decode(jsonPayload['availableTimes']);
}
if (jsonPayload['territoryAvailableTimes'] is String) {
jsonPayload['territoryAvailableTimes'] =
json.decode(jsonPayload['territoryAvailableTimes']);
}
if (jsonPayload['cuisines'] is String) {
jsonPayload['cuisines'] = json.decode(jsonPayload['cuisines']);
}
return _$MerchantFromJson(jsonPayload).copyWith(
// Convert the bool to an integer and set it to the hideCustomizations value
hideCustomizations: boolToIntOrInt(jsonPayload['hideCustomizations']),
);
}
bool get shouldHideCustomizations => (hideCustomizations ?? 0) == 1;
String get fullAddress => '$address, $city, $state';
String cuisinesText([String separator = '-']) =>
(cuisines?.isNotEmpty ?? false)
? '${separator == '-' ? ' - ' : ''}${cuisines.join(' $separator ')}'
: '';
Map<String, dynamic> toDb() {
var jsonPayload = toJson();
if (availableTimes != null) {
jsonPayload['availableTimes'] = json.encode(availableTimes);
}
if (territoryAvailableTimes != null) {
jsonPayload['territoryAvailableTimes'] =
json.encode(territoryAvailableTimes);
}
if (cuisines != null) {
jsonPayload['cuisines'] = json.encode(cuisines);
}
// When serialising to db map, set the value manually since it's ignored by json serialisation
jsonPayload['hideCustomizations'] = hideCustomizations;
return jsonPayload;
}
factory Merchant.fromVendor(Vendor vendor) {
return Merchant(
id: vendor?.id,
displayName: vendor?.displayName,
latitude: vendor?.latitude,
longitude: vendor?.longitude,
address: vendor?.address,
city: vendor?.city,
state: vendor?.state,
);
}
}
The class using it is
@freezed
abstract class MerchantResponse with _$MerchantResponse {
factory MerchantResponse({
List<Bucket> buckets,
List<Merchant> merchants,
Territory territory,
}) = _MerchantResponse;
factory MerchantResponse.fromJson(Map<String, dynamic> json) =>
_$MerchantResponseFromJson(json);
}
They're all in the same file if that helps. The current package versions I have are:
dependencies:
freezed_annotation: 0.12.0
json_annotation: 3.1.0
dev_dependencies:
freezed: 0.12.2
json_serializable: 3.5.1
build_runner: 1.10.2
dependency_overrides:
analyzer: 0.41.1
I'm trying to get it working (been trying for about 3 hours trying all the combinations of packages). Below is the verbose output of the build runner
flutter pub run build_runner build --delete-conflicting-outputs --verbose
[ +68 ms] executing: [C:\src\flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[ +64 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[ ] 60bd88df915880d23877bfc1602e8ddcf4c4dd2a
[ ] executing: [C:\src\flutter/] git tag --points-at 60bd88df915880d23877bfc1602e8ddcf4c4dd2a
[ +57 ms] Exit code 0 from: git tag --points-at 60bd88df915880d23877bfc1602e8ddcf4c4dd2a
[ ] 2.0.0
[ +34 ms] executing: [C:\src\flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[ +35 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[ ] origin/stable
[ ] executing: [C:\src\flutter/] git ls-remote --get-url origin
[ +32 ms] Exit code 0 from: git ls-remote --get-url origin
[ ] https://github.com/flutter/flutter.git
[ +66 ms] executing: [C:\src\flutter/] git rev-parse --abbrev-ref HEAD
[ +34 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[ ] stable
[ +71 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ +11 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ +2 ms] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ +8 ms] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +49 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[ ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[ ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ +8 ms] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[ +1 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ +1 ms] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[ +24 ms] Using C:\src\flutter\.pub-cache for the pub cache.
[ +4 ms] executing: C:\src\flutter\bin\cache\dart-sdk\bin\pub.bat run build_runner build --delete-conflicting-outputs --verbose
[INFO] Generating build script...
[INFO] Generating build script completed, took 390ms
[WARNING] Deleted previous snapshot due to missing asset graph.
[INFO] Creating build script snapshot......
[INFO] Creating build script snapshot... completed, took 10.0s
[INFO] BuildDefinition:Initializing inputs
[INFO] BuildDefinition:Building new asset graph...
[INFO] BuildDefinition:Building new asset graph completed, took 1.1s
[INFO] BuildDefinition:Checking for unexpected pre-existing outputs....
[INFO] BuildDefinition:Deleting 2 declared outputs which already existed on disk.
[INFO] BuildDefinition:Checking for unexpected pre-existing outputs. completed, took 2ms
[INFO] Build:Running build...
[INFO] Heartbeat:1.1s elapsed, 0/16 actions completed.
[FINE] freezed:freezed on test/graphql_responses/test_available_merchants.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/graphql_responses/test_general_responses.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/graphql_responses/test_merchant_menu.dart:Running FreezedGenerator
[INFO] Heartbeat:4.3s elapsed, 3/19 actions completed.
[INFO] Heartbeat:5.4s elapsed, 3/19 actions completed.
[INFO] Heartbeat:6.6s elapsed, 3/19 actions completed.
[INFO] Heartbeat:7.8s elapsed, 3/19 actions completed.
[INFO] Heartbeat:9.0s elapsed, 3/19 actions completed.
[INFO] Heartbeat:10.0s elapsed, 3/19 actions completed.
[INFO] Heartbeat:11.0s elapsed, 3/19 actions completed.
[INFO] Heartbeat:12.4s elapsed, 3/19 actions completed.
[INFO] Heartbeat:13.8s elapsed, 3/19 actions completed.
[INFO] Heartbeat:15.2s elapsed, 3/19 actions completed.
[INFO] Heartbeat:16.3s elapsed, 3/19 actions completed.
[INFO] Heartbeat:17.6s elapsed, 3/19 actions completed.
[WARNING] Heartbeat:
No actions completed for 15.0s, waiting on:
- freezed:freezed on test/database_integration_test.dart
- freezed:freezed on test/data_serialisation_tests/model_properties_test.dart
- freezed:freezed on test/data_serialisation_tests/model_converters_test.dart
- freezed:freezed on test/firebase_mock.dart
- freezed:freezed on test/delivery_dudes_gql_test.dart
.. and 11 more
[INFO] Heartbeat:18.9s elapsed, 3/19 actions completed.
[INFO] Heartbeat:19.9s elapsed, 3/19 actions completed.
[INFO] Heartbeat:21.0s elapsed, 3/19 actions completed.
[INFO] Heartbeat:22.1s elapsed, 3/19 actions completed.
[INFO] Heartbeat:23.1s elapsed, 3/19 actions completed.
FINE] freezed:freezed on test/data_serialisation_tests/model_properties_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/delivery_dudes_gql_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/services_tests/algolia_service_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/services_tests/delivery_service_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/firebase_mock.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/services_tests/remote_config_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/services_tests/stripe_service_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/utils/card_helpers_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/utils/discount_helper_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/utils/firebase_exception_helper_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/services_tests/authentication_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/services_tests/api_integration_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/database_integration_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/services_tests/cart_service_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/services_tests/order_service_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/services_tests/merchant_service_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/data_serialisation_tests/model_converters_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/services_tests/search_service_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/services_tests/push_notification_service_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/services_tests/overlay_service_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/test_data.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/services_tests/user_service_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/test_helpers.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/utils/graphql_parser_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/utils/image_helper_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/utils/order_status_helper_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/utils/string_helper_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/utils/time_helper_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/address_bottom_sheet_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/add_payment_method_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/address_details_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/add_card_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/address_selection_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/browse_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/change_password_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/checkouterror_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/checkout_waiting_room_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/checkout_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/delivery_bottom_sheet_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/create_profile_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/delivery_addresses_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/enroute_driver_banner_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/driver_tracking_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/favourites_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/forgot_password_confirmation_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/guest_mode_bottom_sheet_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/help_center_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/home_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/merchant_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/login_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/order_details_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/order_history_details_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/order_history_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/api/delivery_dudes_api.dart:Running FreezedGenerator
[FINE] freezed:freezed on test/viewmodel_tests/order_status_viewmodel_test.dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/api/delivery_dudes_gql_api.dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/api/graph_ql_parser.dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/api/graph_ql_queries.dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/app/flavor_config.dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/app/lifecycle_manager.dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/app/locator.dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/app/logger.dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/constants/app_constants.dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/constants/app_strings.dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/app/app.dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/database/dddatabase.dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/database/_fake_data.dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/datamodels/application_models.dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/datamodels/data_converters.dart:Running FreezedGenerator
...
NE] json_serializable:json_serializable on test/viewmodel_tests/browse_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/browse_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/change_password_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/change_password_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/checkouterror_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/checkouterror_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/checkout_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/checkout_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/checkout_waiting_room_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/checkout_waiting_room_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/create_profile_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/create_profile_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/delivery_addresses_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/delivery_addresses_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/delivery_bottom_sheet_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/delivery_bottom_sheet_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/driver_tracking_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/driver_tracking_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/enroute_driver_banner_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/enroute_driver_banner_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/favourites_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/favourites_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/forgot_password_confirmation_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/forgot_password_confirmation_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/guest_mode_bottom_sheet_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/guest_mode_bottom_sheet_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/help_center_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/help_center_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/home_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/home_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/login_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/login_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/merchant_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/merchant_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/order_details_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/order_details_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/order_history_details_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/order_history_details_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/order_history_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/order_history_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/order_status_viewmodel_test.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on test/viewmodel_tests/order_status_viewmodel_test.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on lib/api/delivery_dudes_api.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on lib/api/delivery_dudes_api.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on lib/api/delivery_dudes_gql_api.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on lib/api/delivery_dudes_gql_api.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on lib/api/graph_ql_parser.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on lib/api/graph_ql_parser.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on lib/api/graph_ql_queries.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on lib/api/graph_ql_queries.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on lib/app/app.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on lib/app/app.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on lib/app/flavor_config.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on lib/app/flavor_config.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on lib/app/lifecycle_manager.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on lib/app/lifecycle_manager.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on lib/app/locator.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on lib/app/locator.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on lib/app/logger.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on lib/app/logger.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on lib/constants/app_constants.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on lib/constants/app_constants.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on lib/constants/app_strings.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on lib/constants/app_strings.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on lib/database/dddatabase.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on lib/database/dddatabase.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on lib/database/_fake_data.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on lib/database/_fake_data.dart:Running JsonLiteralGenerator - 2 of 2
[FINE] json_serializable:json_serializable on lib/datamodels/application_models.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on lib/datamodels/data_converters.dart:Running JsonSerializableGenerator - 1 of 2
[FINE] json_serializable:json_serializable on lib/datamodels/data_converters.dart:Running JsonLiteralGenerator - 2 of 2
[SEVERE] json_serializable:json_serializable on lib/datamodels/application_models.dart:
Could not generate `toJson` code for `merchants` because of type `Merchant`.
package:customer_app/datamodels/application_models.freezed.dart:2174:24
â•·
2174 │ final List<Merchant> merchants;
│ ^^^^^^^^^
╵
package:json_serializable/src/encoder_helper.dart 133:7 EncodeHelper._serializeField
package:json_serializable/src/encoder_helper.dart 59:42 EncodeHelper._writeToJsonSimple.<fn>
dart:core StringBuffer.writeAll
package:json_serializable/src/encoder_helper.dart 56:9 EncodeHelper._writeToJsonSimple
package:json_serializable/src/encoder_helper.dart 44:7 EncodeHelper.createToJson.sync_op
...
[FINE] stacked_generator:stackedRouterGenerator on lib/ui/views/search/search_results.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/ui/views/search/search_suggestions.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/ui/views/search/search_view.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/ui/views/search/search_viewmodel.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/ui/views/select_previous_order_bottom_sheet/select_previous_order_bottom_sheet.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/ui/views/shared/base_app_viewmodel.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/ui/views/signup/signup_view.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/ui/views/signup/signup_viewmodel.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/ui/views/startup/startup_view.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/ui/views/startup/startup_viewmodel.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/ui/views/status_tracking_viewmodel.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/ui/views/user_information/user_information_view.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/ui/views/welcome/welcome_view.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/ui/views/user_information/user_information_viewmodel.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/ui/views/welcome/welcome_viewmodel.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/util/card_helpers.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/util/discount_helper.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/util/firebase_exception_helper.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/util/image_helper.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/util/map_helper.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/util/order_status_helper.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/util/platform_helper.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/util/snackbar_helper.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/util/time_helper.dart:Running StackedRouterGenerator
[FINE] stacked_generator:stackedRouterGenerator on lib/app/locator.config.dart:Running StackedRouterGenerator
[INFO] Build:Running build completed, took 2m 5s
[INFO] Build:Caching finalized dependency graph...
[INFO] Heartbeat:2m 6s elapsed, 3101/3101 actions completed.
[INFO] Build:Caching finalized dependency graph completed, took 1.2s
[SEVERE] Build:
Failed after 2m 6s
[+140810 ms] "flutter run" took 140 951ms.
[ +5 ms] pub finished with exit code 1
[ +35 ms]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 _DefaultPub.interactively (package:flutter_tools/src/dart/pub.dart:364:7)
<asynchronous suspension>
#2 PackagesForwardCommand.runCommand (package:flutter_tools/src/commands/packages.dart:238:5)
<asynchronous suspension>
#3 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1157:12)
<asynchronous suspension>
#4 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1009:27)
<asynchronous suspension>
#5 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#6 AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
<asynchronous suspension>
#7 CommandRunner.runCommand (package:args/command_runner.dart:197:13)
<asynchronous suspension>
#8 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:278:9)
<asynchronous suspension>
#9 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#10 AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
<asynchronous suspension>
#11 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:234:5)
<asynchronous suspension>
#12 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:64:9)
<asynchronous suspension>
#13 run.<anonymous closure> (package:flutter_tools/runner.dart:62:12)
<asynchronous suspension>
#14 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#15 AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
<asynchronous suspension>
#16 runInContext (package:flutter_tools/src/context_runner.dart:73:10)
<asynchronous suspension>
#17 main (package:flutter_tools/executable.dart:90:3)
<asynchronous suspension>
[ +364 ms] ensureAnalyticsSent: 252ms
[ +2 ms] Running shutdown hooks
[ +14 ms] Shutdown hooks complete
[ +2 ms] exiting with code 1
This is still happening. I have absolutely no idea why this is occurring. Could anyone give a pointer as to why this is happening? I'm gonna look through the source now to find the problem. hopefully I can find it in less than 3 hours. Been a full day now and nothing I do changes it.
Is there any idea of what could be causing this? The type looks fine to me, all the other types are working fine. Just need some direction on why this is happening
Packages updated to later versions and still getting this error
I've reduced it to the following models that cause this isse
@freezed
abstract class SearchInformation with _$SearchInformation {
SearchInformation._();
factory SearchInformation({
String query,
// List<CartProduct> products,
List<Merchant> merchants,
}) = _SearchInformation;
bool get hasSearchResults =>
(products != null && products.isNotEmpty) ||
(merchants != null && merchants.isNotEmpty);
int get searchCount => (products?.length ?? 0) + (merchants?.length ?? 0);
factory SearchInformation.fromJson(Map<String, dynamic> json) =>
_$SearchInformationFromJson(json);
}
@freezed
abstract class Merchant with _$Merchant {
factory Merchant({
int id,
}) = _Merchant;
}
Really need help with this to move forward. Can anyone see any mistakes in the freezed models. It worked fine before flutter 2.0
I found out what the problem is. For each of the models I had some additional from json logic I wrote it like this.
factory Merchant.fromJson(Map<String, dynamic> incomingJson) {
var jsonPayload = Map<String, dynamic>.from(incomingJson);
if (jsonPayload['availableTimes'] is String) {
jsonPayload['availableTimes'] =
json.decode(jsonPayload['availableTimes']);
}
if (jsonPayload['territoryAvailableTimes'] is String) {
jsonPayload['territoryAvailableTimes'] =
json.decode(jsonPayload['territoryAvailableTimes']);
}
if (jsonPayload['cuisines'] is String) {
jsonPayload['cuisines'] = json.decode(jsonPayload['cuisines']);
}
return _$MerchantFromJson(jsonPayload).copyWith(
// Convert the bool to an integer and set it to the hideCustomizations value
hideCustomizations: boolToIntOrInt(jsonPayload['hideCustomizations']),
);
}
This caused the generator to ignore the json code generation. Which I discovered from this comment. So I updated all my custom fromJson functions to this.
factory Merchant.fromJson(Map<String, dynamic> incomingJson) =>
_customFromJson(incomingJson);
static Merchant _customFromJson(Map<String, dynamic> incomingJson) {
var jsonPayload = Map<String, dynamic>.from(incomingJson);
if (jsonPayload['availableTimes'] is String) {
jsonPayload['availableTimes'] =
json.decode(jsonPayload['availableTimes']);
}
if (jsonPayload['territoryAvailableTimes'] is String) {
jsonPayload['territoryAvailableTimes'] =
json.decode(jsonPayload['territoryAvailableTimes']);
}
if (jsonPayload['cuisines'] is String) {
jsonPayload['cuisines'] = json.decode(jsonPayload['cuisines']);
}
if (jsonPayload['subVendors'] is String) {
jsonPayload['subVendors'] = json.decode(jsonPayload['subVendors']);
}
return _$MerchantFromJson(jsonPayload).copyWith(
// Convert the bool to an integer and set it to the hideCustomizations value
hideCustomizations: boolToIntOrInt(jsonPayload['hideCustomizations']),
);
}
The important part is to ensure that fromJson function has => otherwise it will be ignored for some reason.
Most helpful comment
I found out what the problem is. For each of the models I had some additional from json logic I wrote it like this.
This caused the generator to ignore the json code generation. Which I discovered from this comment. So I updated all my custom fromJson functions to this.
The important part is to ensure that fromJson function has
=>otherwise it will be ignored for some reason.