My code uses this import from the Flutter package https://pub.dev/packages/http
import 'package:http/http.dart' as http;
My code itself (little bit below) attempts to make a POST to my specific endpoint. This works, however, every time the POST request is sent it uses a different PORT. How do I get a POST request of this nature to work that fulfils 2 requirements:
- Sends to the same port every time (doesn't change); and
- Sends along a JSON body
My current attempt is below. Currently, this fails because every time it sends using a different port:
Future<void> createUser() async {
var url = Uri.parse('https://MY_ENDPOINT.com/createUser');
var response =
await http.post(url, body: {'username': username, 'email': email, 'password': password});
}
I've read plenty of docs and still cannot figure this out; can anyone help? Thanks.