createFaq function

Future<Faq> createFaq(
  1. String question1,
  2. String content1,
  3. String question2,
  4. String content2,
  5. String question3,
  6. String content3,
  7. String question4,
  8. String content4,
  9. String question5,
  10. String content5,
  11. String question6,
  12. String content6,
)

Implementation

Future<Faq> createFaq(
  String question1,
  String content1,
  String question2,
  String content2,
  String question3,
  String content3,
  String question4,
  String content4,
  String question5,
  String content5,
  String question6,
  String content6,
) async {
  HttpOverrides.global = new MyHttpOverrides();
  final response = await http.post(
    // Uri.parse('https://172.30.1.33:45455/api/FaqModels'),
    Uri.parse('https://192.168.1.106:45455/api/FaqModels'),
    headers: <String, String>{
      'Content-Type': 'application/json; charset=UTF-8',
    },
    body: jsonEncode(<String, String>{
      'question1': question1,
      'content1': content1,
      'question2': question2,
      'content2': content2,
      'question3': question3,
      'content3': content3,
      'question4': question4,
      'content4': content4,
      'question5': question5,
      'content5': content5,
      'question6': question6,
      'content6': content6,
    }),
  );

  if (response.statusCode == 201) {
    // If the server did return a 201 CREATED response,
    // then parse the JSON.
    return Faq.fromJson(jsonDecode(response.body));
  } else {
    // If the server did not return a 201 CREATED response,
    // then throw an exception.
    throw Exception('Failed to create user.');
  }
}