I try edit function in sample Manage features from arcgis-maps-sdk-flutter-samples by add
Future<void> updateAttribute(Feature feature, String damageType) async {
// Disable the UI while the async operations are in progress.
setState(() => _ready = false);
// Update the damage type field to the selected value.
feature.attributes['typdamage'] = damageType;
feature.attributes['inspemail'] = null;
// Update the feature in the local table.
await _damageFeatureLayer.featureTable!.updateFeature(feature);
// Sync the change with the service on the service geodatabase.
await _damageServiceFeatureTable.serviceGeodatabase!.applyEdits();
showMessageDialog(
'Updated feature ${feature.attributes['objectid']} to $damageType.',
);
// Re-enable the UI.
setState(() => _ready = true);
}when update it's return
[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: type 'Null' is not a subtype of type 'String'So, if i want update attributes value to null, how can i do? For all type like esriFieldTypeDate, esriFieldTypeDouble, esriFieldTypeInteger ...
Strings, ints and bools aren't allowed to be nulls in Flutter. Instead, initiaIze them with a question mark in the data type:
Non-nullable- String bobo;
Nullable- String? bobo;
but attributes of Feature return type Map<String, dynamic>, example feature return from service have value feature.attributes['numoccup'] = 3, i want update to service this value to null or empty value, how can i do?
@Antigravity I think you're right. Fetching null values from a feature service is working as expected, I get "null" returned, but setting null values is throwing. It would be the case that a Dart Map would return null if the key didn't exist OR if the value was null, but yeah you should be able the manage the features using null if that's what you've defined in the feature service. Note that you can set an "empty" value (like an empty String), but not null for the issues described. We'll write this up for the team to look into and fix.
Just a further update here - we've corrected this behavior in preparation for our next release, which will be version 300 in April. With the fix you can expect the below to function as expected and without error. The workaround in the meantime remains setting empty data as opposed to null.
feature.attributes['inspemail'] = null;
Try setting a String? variable to feature.attributes['inspemail'], then set that variable to null. Not sure why inspemail is even in the function, since it's never used.
Thanks again for reporting this. This was resolved in our latest 300.0 release. You can even see your bug report marked as resolved in our release notes.