rest_api_impl 0.0.7 copy "rest_api_impl: ^0.0.7" to clipboard
rest_api_impl: ^0.0.7 copied to clipboard

A Dart package providing a robust REST API IMPL service implementation with HTTP request handling, CRUD operations, and file management.

example/main.dart

import 'dart:io';

import 'package:cross_file/cross_file.dart';
import 'package:flutter/material.dart';
import 'package:rest_api_impl/rest_api_impl.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  registerRestApiDataSourceServiceGetItDI(
    baseUrl: RestApiConfigConst.BASE_URL,
    apiKey: RestApiConfigConst.API_KEY,
    clientType: RestApiClientType.dio,
  );

  final restApiService = sl<IRestApiCrudService>();
  final imageService = sl<IImageServiceRestApiDataSource>();

  final response = await restApiService.addData(
    endPoint: 'user/create',
    data: {'name': 'Alice', 'email': 'alice@example.com'},
  );
  debugPrint('Create User Response: $response');

  final userData = await restApiService.getData(endPoint: 'user/1');
  print('User Data: $userData');

  final file = File('path/to/image.png');
  final xFile = XFile(file.path);
  final uploadResponse = await imageService.uploadFile(
    file: xFile,
    endPoint: 'upload/image',
  );
  print('Upload Response: $uploadResponse');
}

class RestApiConfigConst {
  static const BASE_URL = 'https://api.example.com/';
  static const API_KEY = 'xyz-123-token';
}
0
likes
140
points
7
downloads

Publisher

unverified uploader

Weekly Downloads

A Dart package providing a robust REST API IMPL service implementation with HTTP request handling, CRUD operations, and file management.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

cross_file, dio, flutter, get_it_di_global_variable, http, json_annotation, local_data_impl, shared_preferences

More

Packages that depend on rest_api_impl