url method Null safety

String url(
  1. dynamic className,
  2. {dynamic objectId = '',
  3. dynamic queries = const {},
  4. dynamic definePath = ''}
)

リクエストするURLを返す className クラス名 objectId オブジェクトID。省略時は空文字。 definePath あらかじめ決まっているパス。省略時は空文字。 queries クエリ。省略時は空のMap。

Implementation

String url(className, {objectId = '', queries = const {}, definePath = ''}) {
  List queryList = [];
  queries.forEach((key, value) {
    if (value is Map || value is List) {
      value = jsonEncode(value);
    }
    if (value is int) {
      value = value.toString();
    }
    queryList.add("$key=${Uri.encodeQueryComponent(value)}");
  });
  String queryString = queryList.length == 0 ? '' : "?${queryList.join('&')}";
  return "https://${fqdn()}${path(className, objectId: objectId, definePath: definePath)}$queryString";
}