getCategoryList method

Future<CategoryList> getCategoryList({
  1. required List<BaiduCategory> categorys,
  2. String parentPath = '/',
  3. bool showDir = false,
  4. bool recursion = false,
  5. List<String> ext = const [],
  6. int start = 0,
  7. int limit = 1000,
  8. BaiduOrder order = BaiduOrder.time,
  9. bool desc = false,
})

获取分类文件列表

参数查看 官方文档

Implementation

Future<CategoryList> getCategoryList({
  required List<BaiduCategory> categorys,
  String parentPath = '/',
  bool showDir = false,
  bool recursion = false,
  List<String> ext = const [],
  int start = 0,
  int limit = 1000,
  BaiduOrder order = BaiduOrder.time,
  bool desc = false,
}) async {
  if (categorys.isEmpty) {
    throw Exception('categorys is empty');
  }

  final path = 'rest/2.0/xpan/multimedia';

  var param = <String, String>{
    'method': 'categorylist',
    'parent_path': parentPath,
  };

  if (recursion) {
    param['recursion'] = '1';
  }

  _addCommonParams(params: param, order: order, desc: desc);
  param.putIfNotNull('show_dir', showDir);
  param.putIfNotNull('start', start);
  param.putIfNotNull('limit', limit);

  final categoryIndex = categorys.map((category) => category.value).join(',');
  param['category'] = categoryIndex;

  if (ext.isNotEmpty) {
    param['ext'] = ext.join(',');
  }

  final map = await _get(path, params: param);
  return CategoryList.fromJson(map);
}