import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';

import 'interfaces/i_form_data.dart';

class DioFormData implements IFormData {
  final FormData _formData = FormData();

  @override
  void addFile(String field, Uint8List bytes, String filename) {
    _formData.files.add(MapEntry(
      field,
      MultipartFile.fromBytes(bytes, filename: filename),
    ));
  }

  @override
  void addField(String key, String value) {
    _formData.fields.add(MapEntry(key, value));
  }

  FormData get raw => _formData;
}
