form_bloc icon indicating copy to clipboard operation
form_bloc copied to clipboard

How to submitting form_bloc into API using model & params?

Open nameaisy opened this issue 3 years ago • 1 comments

I have a model and I want to submit data input from form_bloc into it, the data should be submitted into params and the data is placed inside List<dynamic>? response; how to submit it with using form_bloc?

class FormModel {
  bool? status;
  String? message;
  List<dynamic>? response;
  double? generated;
  int? tokenExpire;
  int? serverTime;

  FormModel({
    this.status,
    this.message,
    this.response,
    this.generated,
    this.tokenExpire,
    this.serverTime,
  });

  FormModel.fromJson(Map<String, dynamic> json) {
    status = json['status'] as bool?;
    message = json['message'] as String?;
    response = json['response'] as List?;
    generated = json['generated'] as double?;
    tokenExpire = json['tokenExpire'] as int?;
    serverTime = json['serverTime'] as int?;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> json = <String, dynamic>{};
    json['status'] = status;
    json['message'] = message;
    json['response'] = response;
    json['generated'] = generated;
    json['tokenExpire'] = tokenExpire;
    json['serverTime'] = serverTime;
    return json;
  }
}

nameaisy avatar Nov 30 '22 03:11 nameaisy

https://github.com/GiancarloCode/form_bloc/pull/312#issuecomment-1164240179

vasilich6107 avatar Mar 11 '23 18:03 vasilich6107