Is there an existing issue for this?
Which plugins are affected?
firebase_data_connect / Data Connect generated Dart SDK
Which platforms are affected?
Flutter / Dart
Description
The Data Connect Dart SDK generator emits code that fails to compile when a nullable Int64 / PostgreSQL bigint field is included in generated result models.
The generated model has nullable public fields:
final BigInt? installationId;
final BigInt? checkRunId;
but toJson() calls a non-nullable serializer after a null check:
if (installationId != null) {
json['installationId'] = bigIntToJson(installationId);
}
if (checkRunId != null) {
json['checkRunId'] = bigIntToJson(checkRunId);
}
The generated helper expects a non-nullable BigInt:
String bigIntToJson(BigInt value) {
return value.toString();
}
This does not compile because Dart does not promote public fields/getters from BigInt? to BigInt inside the null check.
A generated workaround that compiles is either:
json['installationId'] = bigIntToJson(installationId!);
or making the helper nullable-aware:
String? bigIntToJson(BigInt? value) {
return value?.toString();
}
Reproducing the issue
Generate a Flutter Data Connect SDK for a schema/query that returns nullable bigint / Int64 fields, for example fields like:
installationId: Int64
checkRunId: Int64
Then run flutter analyze or build the Flutter app.
Expected behavior
The generated Dart SDK should compile without manual edits.
Actual behavior
The generated code fails to compile with errors like:
lib/generated/dataconnect/get_build_job.dart:181:45: Error: The argument type 'BigInt?' can't be assigned to the parameter type 'BigInt'.
- 'BigInt' is from 'dart:core'.
json['installationId'] = bigIntToJson(installationId);
^
lib/generated/dataconnect/get_build_job.dart:34:17: Context: 'installationId' refers to a public property so it couldn't be promoted.
See http://dart.dev/go/non-promo-public-field
final BigInt? installationId;
^
lib/generated/dataconnect/get_build_job.dart:187:41: Error: The argument type 'BigInt?' can't be assigned to the parameter type 'BigInt'.
- 'BigInt' is from 'dart:core'.
json['checkRunId'] = bigIntToJson(checkRunId);
^
lib/generated/dataconnect/get_build_job.dart:36:17: Context: 'checkRunId' refers to a public property so it couldn't be promoted.
See http://dart.dev/go/non-promo-public-field
final BigInt? checkRunId;
^
The same error appears in other generated files that include the same nullable BigInt fields.
Workaround
After SDK generation, manually change the generated helper from:
String bigIntToJson(BigInt value) {
return value.toString();
}
to:
String? bigIntToJson(BigInt? value) {
return value?.toString();
}
Firebase Core version
Not sure / not relevant to generator output.
Flutter Version
Flutter 3.41.x
Relevant Log Output
flutter analyze
# fails with BigInt? cannot be assigned to BigInt in generated Data Connect files
Flutter dependencies
The issue is in generated source code. The generated SDK imports package:firebase_data_connect/firebase_data_connect.dart.
Additional context and comments
This looks like a Dart generator nullability issue rather than a runtime Data Connect issue. The null check is not enough because the generated fields are public properties and therefore are not promoted by Dart.
Is there an existing issue for this?
Which plugins are affected?
firebase_data_connect / Data Connect generated Dart SDK
Which platforms are affected?
Flutter / Dart
Description
The Data Connect Dart SDK generator emits code that fails to compile when a nullable
Int64/ PostgreSQLbigintfield is included in generated result models.The generated model has nullable public fields:
but
toJson()calls a non-nullable serializer after a null check:The generated helper expects a non-nullable
BigInt:This does not compile because Dart does not promote public fields/getters from
BigInt?toBigIntinside the null check.A generated workaround that compiles is either:
or making the helper nullable-aware:
Reproducing the issue
Generate a Flutter Data Connect SDK for a schema/query that returns nullable
bigint/Int64fields, for example fields like:Then run
flutter analyzeor build the Flutter app.Expected behavior
The generated Dart SDK should compile without manual edits.
Actual behavior
The generated code fails to compile with errors like:
The same error appears in other generated files that include the same nullable
BigIntfields.Workaround
After SDK generation, manually change the generated helper from:
to:
Firebase Core version
Not sure / not relevant to generator output.
Flutter Version
Flutter 3.41.x
Relevant Log Output
flutter analyze # fails with BigInt? cannot be assigned to BigInt in generated Data Connect filesFlutter dependencies
The issue is in generated source code. The generated SDK imports
package:firebase_data_connect/firebase_data_connect.dart.Additional context and comments
This looks like a Dart generator nullability issue rather than a runtime Data Connect issue. The null check is not enough because the generated fields are public properties and therefore are not promoted by Dart.