getUserQuery method
Builds the user query url used in the call to Shadertoy user page in order to obtain both the user and the his shaders data.
userId
: The user Idfilters
: A set of tag filterssort
: The sort order of the shadersfrom
: A 0 based index for results returned
The call is performed to a user page identified by it's id, for example user iq page
Implementation
String getUserQuery(String userId,
{Set<String>? filters, Sort? sort, int? from}) {
var num = options.pageUserShaderCount;
var queryParameters = [];
if (filters != null) {
for (var filter in filters) {
queryParameters.add('filter=$filter');
}
}
if (sort != null) {
queryParameters.add('sort=${sort.name}');
}
if (from != null) {
queryParameters.add('from=$from');
}
queryParameters.add('num=$num');
var sb = StringBuffer(_getUserUrl(userId));
for (var i = 0; i < queryParameters.length; i++) {
// Strangely the only way to filter the calls is by ommiting ? in the
// query string. This is probably a bug on the shadertoy website
// If fixed line bellow should be used to distinguish between index 0
// thus '?' and the remaining indexes (which should use '&')
sb.write('&');
sb.write(queryParameters[i]);
}
return sb.toString();
}