12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- // ignore_for_file: use_build_context_synchronously
- import 'dart:convert';
- import 'package:dio/dio.dart';
- import 'package:flutter/material.dart';
- import 'package:go_router/go_router.dart';
- import '../globals.dart';
- Future<void> addbug(BuildContext context, String desc, String qc, String dev, String platform, String goodday, String image, String level, String status, String devStatus /*Map data*/) async {
- final dio = Dio();
- Response response;
- AlertDialog alert2 = AlertDialog(
- title: Text("Add Bug 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<String, String> headers = {
- 'content-type': 'application/json',
- 'accept': 'application/json',
- 'authorization': auth
- };
- try{
- response = await dio.post("http://localhost:8080/api/v1/bugs",
- options: Options(headers: headers),
- data:
- // data
- {'description':desc, 'qc': qc, 'dev': dev, 'platform':platform, 'goodday_url':goodday, 'image_url':image, 'level':level, 'status':status, 'dev_status':devStatus}
- );
- if (response.statusCode == 201){
- return context.go('/listbug');
- }
- } catch (error){
-
- showDialog(context: context, builder: (context) => alert2);
- }
-
- }
|