LCOV - code coverage report
Current view: top level - lib/src - query_params.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 13 13 100.0 %
Date: 2020-05-04 13:08:30 Functions: 0 0 -

          Line data    Source code
       1             : class URLQueryParams {
       2             :   final Map<String, String> _values = {};
       3             : 
       4             :   // Appends a parameter to the query with received key.
       5           1 :   void append(String key, dynamic value) {
       6           2 :     if (value != null && value.toString().isNotEmpty) {
       7           4 :       _values[key] = Uri.encodeQueryComponent(value.toString());
       8             :     }
       9             :   }
      10             : 
      11             :   // Removes a parameter from query by key.
      12           1 :   void remove(String key) {
      13           2 :     _values.remove(key);
      14             :   }
      15             : 
      16             :   // Convert to query string like the next example:
      17             :   // * param1=value1&param2=value2
      18           1 :   @override
      19             :   String toString() {
      20             :     String response = '';
      21           3 :     _values.forEach((key, value) {
      22           2 :       response += '$key=$value&';
      23             :     });
      24           4 :     return response.substring(0, response.isEmpty ? 0 : response.length - 1);
      25             :   }
      26             : 
      27           1 :   String toUrl(String urls) {
      28             :     String updatedUrl;
      29           2 :     if (urls != null && urls.isNotEmpty && urls.endsWith('/')) {
      30           3 :       updatedUrl = urls.substring(0, urls.length - 1);
      31             :     } else {
      32             :       updatedUrl = urls;
      33             :     }
      34           2 :     return '$updatedUrl?${toString()}';
      35             :   }
      36             : }

Generated by: LCOV version 1.14