Skip to main content
Version: 0.7.1

Units

This method is used to retrieve a list of units based on the selected domain (region).

Parameters

ParameterTypeDescription
domainStringDomain code (region) to retrieve units.
langDataLanguageLanguage for units data (default: DataLanguage.id).
pageintPage number (default: 1).
variableIDint?Variable ID of the units (optional).

Examples

Example usage and output:

// Fetch units data from BPS
final result = await StadataFlutter.instance.list.units(
domain: 'example_domain_code', // Replace with the desired domain code
lang: DataLanguage.id,
page: 1,
variableID: 'example_variable_id', // Replace with the desired variable ID or null
);

final units = result.data;
final pagination = result.pagination;

// Print page information
print('Current page: ${pagination.page}');
print('Total Pages: ${pagination.pages}');
print('Total Data in This Page: ${pagination.count}');
print('PerPage: ${pagination.perPage}');
print('Total: ${pagination.total}');
print('------------------------');

// Print retrieved units data
for (final unit in units) {
print('Unit ID: ${unit.id}');
print('Title: ${unit.title}');
}

Properties (UnitData)

PropertyTypeDescription
idintThe unique identifier for the Unit.
titleStringThe title of the Unit.