zeba_academy_network_helper 0.0.1
zeba_academy_network_helper: ^0.0.1 copied to clipboard
A Flutter package to simplify network requests with automatic JSON parsing, error handling, retries, and logging.
Zeba Academy Network Helper #
A Flutter package to simplify network requests with automatic JSON parsing, retry logic, error handling, and optional logging. Designed to help developers make GET, POST, PUT, DELETE requests effortlessly, while keeping your code clean and minimal.
Features #
- Simple functions for GET, POST, PUT, DELETE requests.
- Automatic JSON parsing for responses.
- Retry logic for failed requests.
- Connectivity checks to prevent requests without internet.
- Optional logging for debugging network calls.
- Minimal, no-bloat, production-ready code.
Installation #
Add the package to your pubspec.yaml:
dependencies:
zeba_academy_network_helper:
git:
url: https://github.com/sufyanism/zeba_academy_network_helper.git
Then run:
flutter pub get
Usage #
Import #
import 'package:zeba_academy_network_helper/zeba_academy_network_helper.dart';
Initialize #
final networkHelper = ZebaNetworkHelper(
retryCount: 3, // Number of retry attempts
enableLogging: true, // Enable request/response logging
);
GET Request #
final response = await networkHelper.get('https://jsonplaceholder.typicode.com/posts/1');
print(response);
POST Request #
final response = await networkHelper.post(
'https://jsonplaceholder.typicode.com/posts',
body: {'title': 'Hello', 'body': 'World', 'userId': 1},
);
print(response);
PUT Request #
final response = await networkHelper.put(
'https://jsonplaceholder.typicode.com/posts/1',
body: {'title': 'Updated Title'},
);
print(response);
DELETE Request #
final response = await networkHelper.delete('https://jsonplaceholder.typicode.com/posts/1');
print(response);
Notes #
- Ensure the device has an active internet connection, otherwise a
SocketExceptionwill be thrown. - Logging is optional and can be enabled via the
enableLoggingparameter. - Retry attempts can be configured with the
retryCountparameter.
License #
This project is licensed under the GNU General Public License v3.0 (GPL-3.0). See LICENSE for more details.
About Me #
⨠Iām Sufyan bin Uzayr, an open-source developer passionate about building and sharing meaningful projects. You can learn more about me and my work at sufyanism.com or connect with me on LinkedIn.
Your all-in-one no-bloat hub! #
š Explore cutting-edge resources in coding, tech, and development at zeba.academy and code.zeba.academy. Empower yourself with practical skills through curated directives, real-world projects, and hands-on experience. Level up your tech game today! š»āØ
- Visit our main site: zeba.academy
- Explore hands-on courses: code.zeba.academy
- YouTube tutorials: zeba.academy
- Follow us on Instagram: zeba.academy
Thank you for visiting!