AttributeError: 'Request' object has no attribute 'post'

I am try to get data from flutter to frappe doctype by post api. But get AttributeError. I don’t understant the reson. Please help me if know the solution :smiling_face_with_tear:

frappe code:

import frappe

@frappe.whitelist(allow_guest=True)
def receive_post_data():
    data = frappe.request.post
    print(f"\n\n\n{data}\n\n\n")
    return

Flutter code:

import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:http/http.dart' as http;

class Register extends StatefulWidget {
  const Register({Key? key}) : super(key: key);

  @override
  State<Register> createState() => _RegisterState();
}

class _RegisterState extends State<Register> {
  TextEditingController email=TextEditingController();
  TextEditingController name=TextEditingController();
  TextEditingController pass=TextEditingController();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Resister"),
        centerTitle: true,
      ),
      body:Padding(
        padding: EdgeInsets.only(left: 28.0, right: 28.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            TextField(controller: email, decoration: InputDecoration(hintText: "Email"),),
            TextField(controller: name, decoration: InputDecoration(hintText: "Name"),),
            TextField(controller: pass, decoration: InputDecoration(hintText: "Password"),),
            ElevatedButton(onPressed: (){registerUser();}, child: Text("Resigter"))
          ],
        ),
      )
    );
  }

  void registerUser()async{

    var url="http://192.168.0.208:8004/api/method/brl_http.utils.receive_post_data";
    var data = {
      "name": name.text,
      "email": email.text,
      "pass": pass.text,
    };
    
    var bodyy=jsonEncode(data);
    var urlParse = Uri.parse(url);
    final response= await http.post(
      urlParse,
      body: bodyy,
      headers: {
        "Authorization": "Token 440acd4c0783e1d:aa548178410e21a",
        'Content-Type': 'application/json',
      }
    );
    if (response.statusCode == 200) {
      print('Data posted successfully');
    } else {
      print(response.statusCode);
      print('Failed to post data');
    }
  }
}

This is the offending line. frappe.request is of type Request which doesn’t have the attribute post.

Either your app hasn’t set that attribute or it’s working on a false assumption. You may want to use frappe.local.form_dict, frappe.desk.reportview.get_form_params or something similar to fetch params. Although, it would be best to define your endpoint with defined named params & types (better security) like

@frappe.whitelist()
def validate_token(token: str):
   ...