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-10-22 15:41:59 Functions: 0 0 -

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

Generated by: LCOV version 1.15