nobetci_eczane_api 1.0.0 copy "nobetci_eczane_api: ^1.0.0" to clipboard
nobetci_eczane_api: ^1.0.0 copied to clipboard

Turkiye ve KKTC nobetci eczaneler, il ve ilce eczane listeleri ve en yakin eczaneleri sorgulamak icin resmi Dart ve Flutter SDK paketi.

🏥 nobetci_eczane_api (Dart & Flutter SDK) #

Türkiye ve KKTC genelindeki 81 ilin nöbetçi eczane verilerine, il/ilçe sorgularına, GPS koordinat bazlı en yakın eczane lokasyonlarına programatik erişim sağlayan resmi Dart & Flutter SDK paketidir.

Pub Version License: MIT Platforms


📦 Kurulum (Installation) #

Flutter Projenize Ekleyin: #

flutter pub add nobetci_eczane_api

Dart Projenize Ekleyin: #

dart pub add nobetci_eczane_api

pubspec.yaml ile Manuel Ekleme: #

dependencies:
  nobetci_eczane_api: ^1.0.0

🚀 Hızlı Başlangıç (Quick Start) #

import 'package:nobetci_eczane_api/nobetci_eczane_api.dart';

void main() async {
  // 1. İstemciyi başlatın
  final client = NobetciEczaneClient(apiKey: 'SENIN_API_ANAHTARIN');

  try {
    // 2. İstanbul (34) nöbetçi eczanelerini çekin
    final response = await client.getSentryByCity(cityId: 34);

    if (response.data != null) {
      for (final item in response.data!) {
        print('💊 ${item.name} (${item.district} / ${item.locality})');
        print('   📞 Tel: ${item.phone}');
        print('   📍 Adres: ${item.address}');
        print('   🗺️ Konum: ${item.coordinates?.latitude}, ${item.coordinates?.longitude}');
      }
    }
  } on NobetciEczaneApiException catch (e) {
    print('API Hatası (${e.statusCode}): ${e.message}');
  } finally {
    client.close();
  }
}

📱 Flutter Örnek Kullanımı (StatefulWidget) #

import 'package:flutter/material.dart';
import 'package:nobetci_eczane_api/nobetci_eczane_api.dart';

class PharmacyListScreen extends StatefulWidget {
  const PharmacyListScreen({super.key});

  @override
  State<PharmacyListScreen> createState() => _PharmacyListScreenState();
}

class _PharmacyListScreenState extends State<PharmacyListScreen> {
  final _client = NobetciEczaneClient(apiKey: 'SENIN_API_ANAHTARIN');
  List<Pharmacy> _pharmacies = [];
  bool _isLoading = true;

  @override
  void initState() {
    super.initState();
    _fetchData();
  }

  Future<void> _fetchData() async {
    try {
      final res = await _client.getSentryByCity(cityId: 34); // İstanbul
      setState(() {
        _pharmacies = res.data ?? [];
        _isLoading = false;
      });
    } catch (e) {
      setState(() => _isLoading = false);
    }
  }

  @override
  void dispose() {
    _client.close();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    if (_isLoading) {
      return const Scaffold(body: Center(child: CircularProgressIndicator()));
    }

    return Scaffold(
      appBar: AppBar(title: const Text('İstanbul Nöbetçi Eczaneler')),
      body: ListView.builder(
        itemCount: _pharmacies.length,
        itemBuilder: (context, index) {
          final p = _pharmacies[index];
          return ListTile(
            leading: const Icon(Icons.local_pharmacy, color: Colors.red),
            title: Text(p.name, style: const TextStyle(fontWeight: FontWeight.bold)),
            subtitle: Text('${p.district} - ${p.address}'),
            trailing: Text(p.phone ?? ''),
          );
        },
      ),
    );
  }
}

💻 Tüm Metodlar (API Reference) #

  • getSentryPharmacies({int page = 1, int limit = 25}): Türkiye ve KKTC genelindeki tüm nöbetçi eczaneler.
  • getSentryByCity({required int cityId, int limit = 50}): İl bazlı nöbetçi eczaneler.
  • getSentryByDistrict({required int cityId, required int districtId, int limit = 50}): İlçe bazlı nöbetçi eczaneler.
  • getNearbyPharmacies({required double latitude, required double longitude, bool isSentry = true, int limit = 10}): Koordinata göre en yakın eczaneler.
  • getCities(): 81 il ve KKTC listesi.
  • getDistricts({required int cityId}): İle bağlı ilçe listesi.
  • getAccountInfo(): Lisans ve kalan gün/kota bilgisi.
  • updateWhitelist({required String ips}): Dinamik IP Whitelist güncelleme.

🛡️ Hata Yönetimi #

try {
  final res = await client.getSentryByCity(cityId: 34);
} on AuthenticationException catch (e) {
  // 401: API anahtarı geçersiz
} on ForbiddenException catch (e) {
  // 403: IP Whitelist eşleşmedi
} on RateLimitException catch (e) {
  // 429: İstek limiti aşıldı
} on NobetciEczaneApiException catch (e) {
  // Genel API hatası
}

📄 Lisans & İletişim #

0
likes
150
points
--
downloads

Documentation

API reference

Publisher

unverified uploader

Turkiye ve KKTC nobetci eczaneler, il ve ilce eczane listeleri ve en yakin eczaneleri sorgulamak icin resmi Dart ve Flutter SDK paketi.

License

MIT (license)

Dependencies

http

More

Packages that depend on nobetci_eczane_api