Send JSON to server

This commit is contained in:
2023-12-26 16:06:24 +03:00
parent 503a82f79e
commit a8ed8b75b1
9 changed files with 48 additions and 53 deletions

View File

@@ -9,8 +9,9 @@ import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_m
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
import 'package:flutter/material.dart';
import 'dart:convert';
import 'package:http/http.dart' as http;
class AdditionalInformationScreen extends StatefulWidget {
class AdditionalInformationScreen extends StatelessWidget {
const AdditionalInformationScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
@@ -25,13 +26,6 @@ class AdditionalInformationScreen extends StatefulWidget {
child: AdditionalInformationScreen());
}
@override
State<AdditionalInformationScreen> createState() =>
_AdditionalInformationScreenState();
}
class _AdditionalInformationScreenState
extends State<AdditionalInformationScreen> {
@override
Widget build(BuildContext context) {
mediaQueryData = MediaQuery.of(context);
@@ -70,14 +64,17 @@ class _AdditionalInformationScreenState
margin: EdgeInsets.only(
left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: () {
var message;
onPressed: () async {
UserRegistrationSheet sheet = state
.additionalInformationModelObj!
.userRegistrationSheet;
sheet.additionalInfo = state.editTextController!.text;
message = sheet.toJson();
print(message);
final response = await http.post(
Uri.parse('http://10.55.5.126:1092/api/register'),
headers: {'Content-Type': 'application/json'},
body: json.encode(sheet),
);
print(response.body);
});
}),
SizedBox(height: 17.v),
@@ -140,7 +137,7 @@ class _AdditionalInformationScreenState
context: context,
builder: (_) => AlertDialog(
title: const Text('Регистрация завершена!'),
content: const Text(text),
content: const Text('1'),
actions: [
TextButton(
onPressed: () {