I have created my SignUp API in NodeJs and its working fine when I try to run on thunder client but when I try to integrate in flutter it doesn't work. I have worked before with the same API and same code in flutter the similar code but the error coming up in the recent one. I don't know where's the issue coming up this is the issue come when I try to press SignUp button.
Here's the NodeJs API,
and here's the flutter integration
and here is the rest of the code of SignUp page in flutter
import 'package:flutter/material.dart';
import 'package:order_eats/APIS/user_api.dart';
import 'package:order_eats/screens/auth_screens/login.dart';
import 'package:order_eats/screens/auth_screens/widgets/custom_button.dart';
import 'package:order_eats/screens/auth_screens/widgets/custom_field.dart';
class SignUp extends StatefulWidget {
const SignUp({super.key});
static const routeName = '/signup';
@override
State<SignUp> createState() => _SignUpState();
}
class _SignUpState extends State<SignUp> {
final TextEditingController emailController = TextEditingController();
final TextEditingController passwordController = TextEditingController();
final TextEditingController nameController = TextEditingController();
final formKey = GlobalKey<FormState>();
void userSignup() {
UserApis().userSignUP(context, emailController.text,
passwordController.text, nameController.text);
setState(() {});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(10),
child: Form(
key: formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
margin: const EdgeInsets.symmetric(horizontal: 20),
child: const Text(
'Order Eats',
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.w900,
color: Color.fromRGBO(255, 97, 164, 1)),
),
),
const SizedBox(
height: 20,
),
const Text(
'Lets get started',
style: TextStyle(
fontSize: 20,
color: Colors.black,
fontWeight: FontWeight.bold),
),
const SizedBox(
height: 20,
),
CustomField(name: 'Name', controller: nameController),
const SizedBox(
height: 20,
),
CustomField(
name: 'Email',
controller: emailController,
),
const SizedBox(
height: 20,
),
CustomField(name: 'Password', controller: passwordController),
const SizedBox(
height: 20,
),
CustomButton(
ontap: () {
if (formKey.currentState!.validate()) {
userSignup();
}
},
text: 'Sign Up'),
const SizedBox(
height: 20,
),
],
),
),
),
Row(
children: [
const Text(
'Already have an account? ',
style: TextStyle(
color: Colors.black,
),
),
GestureDetector(
onTap: () =>
Navigator.of(context).pushNamed(LoginScreen.routeName),
child: const Text(
'Login',
style: TextStyle(
color: Color.fromRGBO(255, 97, 164, 1),
fontWeight: FontWeight.bold),
),
)
],
)
],
),
);
}
}