I've been trying to zoom to features after definition expression is applied. is there a way to direct zoom to all features which satisfies the definition expression? I already checked all examples, Could you please suggest something to do that?
Instead of calling FeatureLayer.queryExtent, you can call FeatureTable.queryExtent:
// Create a uri to a feature service.
final uri = Uri.parse(
'https://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0',
);
// Create a service feature table with the uri.
final serviceFeatureTable = ServiceFeatureTable.withUri(uri);
// Apply a definition expression to filter features
serviceFeatureTable.definitionExpression = "firstname like '%a%'";
// Create query parameters with the definition expression
final queryParameters = QueryParameters();
queryParameters.whereClause = serviceFeatureTable.definitionExpression;
// Query the extent of features that match the definition expression
final queryResult = await serviceFeatureTable.queryExtent(queryParameters);
// Create a feature layer with the service feature table
final serviceFeatureLayer =
FeatureLayer.withFeatureTable(serviceFeatureTable);
// Add the feature layer to the map's operational layers
map.operationalLayers.add(serviceFeatureLayer);
// Load the map to ensure all layers are ready
await map.load();
// Set the map view to the extent of the queried features
_mapViewController.setViewpointGeometry(queryResult.extent);