Last active
September 21, 2022 23:16
-
-
Save VB10/a0270827b21ec1d28bf18c5f962f06d3 to your computer and use it in GitHub Desktop.
Query Enums
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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