api_mate 0.3.0 copy "api_mate: ^0.3.0" to clipboard
api_mate: ^0.3.0 copied to clipboard

A minimal API response wrapper for Dio + Retrofit in Flutter. Built-in logger, global config, and sealed result types.

example/lib/main.dart

import 'package:api_mate/api_mate.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';

import 'api_client.dart'; // Retrofit client 정의된 파일

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'ApiMate Example',
      home: Scaffold(
        appBar: AppBar(title: const Text('ApiMate v0.2 Retrofit Example')),
        body: Center(
          child: ElevatedButton(
            child: const Text('Call API'),

            onPressed: () async {
              final dio = Dio();
              final client = ApiClient(dio);
              final request = ApiMate(() => client.getPost(1));
              await request.call();

              if (request.isSuccess && request.data != null) {
                final post = request.data!;
                debugPrint('success: ${post.title}');
              } else {
                debugPrint('fail: ${request.errorMessage}');
              }
            },
          ),
        ),
      ),
    );
  }
}
1
likes
160
points
36
downloads

Publisher

unverified uploader

Weekly Downloads

A minimal API response wrapper for Dio + Retrofit in Flutter. Built-in logger, global config, and sealed result types.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

dio, retrofit

More

Packages that depend on api_mate