// ignore_for_file: use_build_context_synchronously import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import '../globals.dart'; Future delmember(BuildContext context, int id) async{ final dio = Dio(); Response response; AlertDialog alert = AlertDialog( title: Text("Delete Sukses"), content: Text("Data terhapus"), actions: [ TextButton( child: Text('Ok'), onPressed: () => Navigator.of(context).pop(), ), ], ); AlertDialog alert2 = AlertDialog( title: Text("Delete Gagal"), content: Text("Data Invalid"), actions: [ TextButton( child: Text('Ok'), onPressed: () => Navigator.of(context).pop(), ), ], ); var auth = 'Basic ${base64Encode(utf8.encode('$USER_LOGIN:$PASS_LOGIN'))}'; Map headers = { 'content-type': 'application/json', 'accept': 'application/json', 'authorization': auth }; try { response = await dio.delete("http://localhost:8080/api/v1/projects/member/$id", options: Options(headers: headers) ); if(response.statusCode == 200){ showDialog(context: context, builder: (context) => alert); } } catch (error){ showDialog(context: context, builder: (context) => alert2); } }