Skip to content

Instantly share code, notes, and snippets.

@VB10
Last active September 21, 2022 23:16
Show Gist options
  • Select an option

  • Save VB10/a0270827b21ec1d28bf18c5f962f06d3 to your computer and use it in GitHub Desktop.

Select an option

Save VB10/a0270827b21ec1d28bf18c5f962f06d3 to your computer and use it in GitHub Desktop.
Query Enums
import 'package:dio/dio.dart';
enum QueryValues {
version,
platform,
page,
pageSize;
MapEntry<String, String> toEntry(String value) {
return MapEntry(name, value);
}
}
class DioManager {
void fetch() {
Dio().get('/sample',
queryParameters: Map.fromEntries([
QueryValues.page.toEntry('1'),
QueryValues.version.toEntry('ios'),
]));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment