flashapi_generator 0.1.0
flashapi_generator: ^0.1.0 copied to clipboard
A Flutter plugin for API-driven BLoC generation with VS Code extension integration
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:
- Install the extension from the VS Code marketplace
- Open your Flutter project
- Press
Ctrl+Shift+Pand search for "FlashApi" - 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 tomethod(String): HTTP method (GET, POST, PUT, DELETE, PATCH)headers(Map<String, String>?): Optional headersbody(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.