1 year ago

#388321

test-img

Eric Efrain Almendras Arnez

Equivalence in post method from angular to dart/flutter

I am working with a mobile application (flutter/dart), and I also have a web page, which is made in the backend with laravel and frontend with angular-cli.. ok, i have the following post method, in dart:

Future<void> postPedido(ControlCargaPedido pedido) async {
   final http.Response response = await http.post(
     Uri.parse(apiUrl+'/control-de-carga/pedido-materiales'),
     headers: <String, String>{
     'Content-Type': 'application/x-www-form-urlencoded',
     },
     body: pedido.toJson(),
    );
 }

Basically I add a record to the database of a new order. and I have my web interface with laravel and angular, where I show one with all the requests

orders_view.jpg

what I want is to show in real time the updated table with the new order that is generated when the post method is used. I know that in angular cli it is done in the following way:

  private _refresh$ = new Subject<void>();
    get refresh$(){
        return this.refresh$;
     }

 postPedido():Observable<any>{
   let headers = new HttpHeaders().set('Content-Type','application/x-www-form-urlencoded');
   return this._http.post(this.url+'control-de-carga/pedido-materiales',{headers: headers})
   .pipe(
      tap(() => (
         this.refresh$.next()
      ))
   )
 }

but since I don't have my post method in angular-cli, but I have it in dart, I wanted to know how I can do the same or similar in dart.

laravel

flutter

dart

angular-cli

0 Answers

Your Answer

Accepted video resources