lynk_io 0.0.6 copy "lynk_io: ^0.0.6" to clipboard
lynk_io: ^0.0.6 copied to clipboard

A lightweight and modular Flutter networking library for clean API communication using Dio.

example/lynk_io_example.dart

import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:lynk_io/lynk_io.dart';

class User {
  final int id;
  final String name;

  User({required this.id, required this.name});

  factory User.fromJson(Map<String, dynamic> json) =>
      User(id: json['id'], name: json['name']);
}

Future<void> main() async {
  await dotenv.load();
  final baseUrl = dotenv.env['API_BASE_URL'] ?? '';

  setupDependencies(baseUrl: baseUrl);

  final api = locator<ApiClient>();

  final response = await api.get<User>(
    endpoint: '/users/1',
    fromJson: User.fromJson,
  );

  if (response.isSuccess) {
    print('User Name: ${response.data?.name}');
  } else {
    print('Error: ${response.error?.message}');
  }
}
6
likes
140
points
40
downloads

Publisher

unverified uploader

Weekly Downloads

A lightweight and modular Flutter networking library for clean API communication using Dio.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

connectivity_plus, dio, flutter, flutter_dotenv, get_it, logger, meta

More

Packages that depend on lynk_io