coderspace_network 1.0.1 copy "coderspace_network: ^1.0.1" to clipboard
coderspace_network: ^1.0.1 copied to clipboard

coderspace_network is a lightweight, developer-friendly Flutter package for making REST API calls using Dio. It provides clean, generic request handling, consistent error management, and simple utilit [...]

coderspace_network #

coderspace_network is a lightweight, developer-friendly Flutter package for making REST API calls using Dio. It provides clean, generic request handling, consistent error management, and simple utilities like auto-list parsing—all with minimal code.

📦 Installation #

Add this to your pubspec.yaml:

dependencies:
  coderspace_network: ^latest_version

📖 Usage #

✅ Import

// Import the package
import 'package:coderspace_network/coderspace_network.dart';

✅ Initialize CoderClient

// Create an instance with your base URL
final client = CoderClient(baseUrl: 'https://jsonplaceholder.typicode.com');
// OR
final client = CoderClient(
  baseUrl: 'https://your-api.com',
  timeout: const Duration(seconds: 15),
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
  },
);

✅ Make a GET request

final result = await client.get<List<Post>>(
  '/posts',
  // Use the parser to convert raw response to your model
  parser: (data) => ensureList(data, (e) => Post.fromJson(e)),
);

if (result.isSuccess) {
  final posts = result.data!;
  print('Fetched ${posts.length} posts');
} else {
  print('❌ Error: ${result.error}');
}

✅ Make a POST request

final result = await client.post<Map<String, dynamic>>(
  '/posts',
  data: {
    'title': 'Hello World',
    'body': 'This is a test post',
    'userId': 1,
  },
);

if (result.isSuccess) {
  print('✅ Created: ${result.data}');
} else {
  print('❌ Failed: ${result.error}');
}

✅ Handling Single or List Response

If the API may return a single item or a list, use ensureList:

final users = ensureList(responseData, (e) => User.fromJson(e));

🚀 About Me #

👨‍💻 Senior Flutter Developer
💡 One principle I always code by:
"Don’t just develop — Develop Innovative"

📝 Author Profile #

coderspacedev
linkedin
Stack_Overflow

Support #

For support, email thoriyaprahalad@gmail.com

0
likes
150
points
59
downloads

Publisher

verified publishercoderdev.space

Weekly Downloads

coderspace_network is a lightweight, developer-friendly Flutter package for making REST API calls using Dio. It provides clean, generic request handling, consistent error management, and simple utilities like auto-list parsing—all with minimal code.

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

dio, flutter, mockito

More

Packages that depend on coderspace_network