FlashAPI Plugin

A Flutter plugin for API-driven BLoC generation with VS Code extension integration.

Features

  • 🌐 API Testing: Test API endpoints with various HTTP methods
  • πŸ—οΈ BLoC Generation: Automatically generate Flutter BLoC clean architecture
  • πŸ”§ VS Code Integration: Seamless integration with VS Code extension
  • πŸ“± Cross-Platform: Support for Android, iOS, Linux, macOS, and Windows
  • πŸš€ Easy to Use: Simple API for making HTTP requests

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  flashapi: ^0.1.0

Usage

Basic API Request

import 'package:flashapi/flashapi.dart';

// Make a GET request
final response = await Flashapi.makeRequest(
  url: 'https://jsonplaceholder.typicode.com/posts/1',
  method: 'GET',
  headers: {'Content-Type': 'application/json'},
);

print('Response: $response');

POST Request with Body

final response = await Flashapi.makeRequest(
  url: 'https://jsonplaceholder.typicode.com/posts',
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"title": "New Post", "body": "Post content", "userId": 1}',
);

Platform Information

// Get platform version
final platformVersion = await Flashapi.platformVersion;
print('Platform: $platformVersion');

VS Code Extension

For enhanced development experience, install the FlashAPI VS Code extension:

  1. Install the extension from the VS Code marketplace
  2. Open your Flutter project
  3. Press Ctrl+Shift+P and search for "FlashApi"
  4. Use the intuitive UI to test APIs and generate BLoC architecture

API Reference

Flashapi.makeRequest

Makes an HTTP request to the specified URL.

Parameters:

  • url (String): The URL to make the request to
  • method (String): HTTP method (GET, POST, PUT, DELETE, PATCH)
  • headers (Map<String, String>?): Optional headers
  • body (String?): Optional request body

Returns: Future<Map<String, dynamic>>

Flashapi.platformVersion

Gets the platform version information.

Returns: Future<String>

Example

import 'package:flutter/material.dart';
import 'package:flashapi/flashapi.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'FlashAPI Example',
      home: Scaffold(
        appBar: AppBar(title: Text('FlashAPI Example')),
        body: Center(
          child: FutureBuilder<Map<String, dynamic>>(
            future: Flashapi.makeRequest(
              url: 'https://jsonplaceholder.typicode.com/posts/1',
              method: 'GET',
              headers: {'Content-Type': 'application/json'},
            ),
            builder: (context, snapshot) {
              if (snapshot.hasData) {
                return Text('Title: ${snapshot.data!['title']}');
              } else if (snapshot.hasError) {
                return Text('Error: ${snapshot.error}');
              } else {
                return CircularProgressIndicator();
              }
            },
          ),
        ),
      ),
    );
  }
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.

Libraries

flashapi