Upgrade Skill Di ITBOX Jadi Lebih Hemat
Special Diskon 50%
Sampai 16 November 2026!
Hari
Jam
Menit
Detik
GARUDABOX

Forum Replies Created

Viewing 16 post (of 16 total)
  • Author
    Posts
  • in reply to: error apiurl mohon pencerahanya #49397
    sandi
    Participant

      `import ‘dart:convert’;

      import ‘package:http/http.dart’ as http;

      class PostResult {
      String id;
      String name;
      String job;
      String created;

      PostResult(
      {required this.id,
      required this.name,
      required this.job,
      required this.created});

      factory PostResult.createPostResult(Map<String, dynamic> object) {
      return PostResult(
      id: object[“id”],
      name: object[“name”],
      job: object[“job”],
      created: object[“createdAt”]);
      }
      static Future<PostResult> connectToAPI(String name, String job) async {
      String apiUrl = “https://reqres.in/api/users&#8221;;

      var apiResult = await http.post(<strong>apiUrl</strong>, body: {“name”: name, “job”: job});
      var jsonObject = json.decode(apiResult.body);

      return PostResult.createPostResult(jsonObject);
      }
      }

    Viewing 16 post (of 16 total)
    Shopping cart0
    There are no products in the cart!
    Continue shopping