Skip to main content
Version: 0.7.1

Variables

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

Parameters

ParameterTypeDescription
domainStringDomain code (region) to retrieve variables.
langDataLanguageLanguage for variables data (default: DataLanguage.id).
pageintPage number (default: 1).
subjectIDint?Variable ID of the variables (optional).
showExistingVariableboolA boolean flag to determine whether to only show variables that have values for the specified domain. When set to true, the function translates this to the area query parameter with a value of 1, filtering the variables to include only those that have existing values in the domain (default: false)
yearint?(Optional) The specific year for which variables are being requested.

Examples

Example usage and output:

// Fetch variables data from BPS
final result = await StadataFlutter.instance.list.variables(
domain: 'example_domain_code', // Replace with the desired domain code
lang: DataLanguage.id,
page: 1,
showExistingVariable: false,
year: 2020,
subjectID: 'example_subject_id', // Replace with the desired subject ID or null
);

final variables = 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 variables data
for (final variable in variables) {
print('Variable ID: ${unit.id}');
print('Title: ${unit.title}');
print('Subject ID: ${unit.subjectID}');
print('Subject Name: ${unit.subjectName}');
print('Vertical Variable ID: ${unit.verticalVariableID}');
print('CSA Subject Name: ${unit.csaSubjectName}');
print('Graph Name: ${unit.graphName}');
print('Notes: ${unit.notes}');
print('Unit: ${unit.unit}');
print('Type: ${unit.type}');
print('Derived Period ID: ${unit.derivedPeriodID}');
print('Derived Variable ID: ${unit.derivedVariableID}');
}

Properties (Variable)

PropertyTypeDescription
idintThe unique identifier for the Variable.
titleStringThe official title or label of the variable
subjectIDintAn identifier for the sub-category of the variable.
subjectNameStringThe name of the subject to which the variable belongs.
verticalVariableIDintAn identifier for the vertical variable.
csaSubjectNameString?The name of the cross-sectional subject related to the variable, if applicable.
graphNameStringA descriptive name used for graphing purposes.
notesStringAdditional notes or descriptions about the variable.
unitStringThe measurement unit of the variable.
typeint?The type of the variable, if applicable.
derivedPeriodIDint?The identifier for the derived period, if applicable.
derivedVariableIDint?The identifier for the derived variable, if applicable.