dorar_hadith library
Dorar Hadith - A Dart package for interacting with the Dorar.net Hadith API
Provides a type-safe interface for searching and retrieving hadiths from the Dorar.net API.
Features
- Hadith search with filters
- Unified
DetailedHadithmodel that extends the lightweightHadithlisting results - Sharh (explanations)
- Offline reference data (books, scholars, narrators)
- Built-in caching
Usage
import 'package:dorar_hadith/dorar_hadith.dart';
void main() async {
final client = DorarClient();
// Search hadiths
final results = await client.searchHadith(
HadithSearchParams(value: 'الصلاة', page: 1),
);
// Search with filters
final filtered = await client.searchHadithDetailed(
HadithSearchParams(
value: 'النية',
specialist: true,
degrees: [HadithDegree.authenticHadith],
),
);
// Browse books (offline)
final books = await client.searchBooks('صحيح');
// Get detailed book info
final bookInfo = await client.book.getById(books.first.id);
await client.dispose();
}
Classes
- $$RawiTableAnnotationComposer
- $$RawiTableFilterComposer
- $$RawiTableOrderingComposer
- $$RawiTableTableManager
- $RawiDatabaseManager
- $RawiTable
-
ApiResponse<
T> - Generic wrapper for API responses. Provides a consistent structure for all API responses with data and metadata.
- AssetLoader
- Base contract for loading asset contents.
- BookInfo
- Represents information about a book containing hadiths.
- BookItem
- Lightweight model for book references.
- BookReference
- Reference class for Islamic books containing hadiths.
- BookReferenceService
- Service for browsing and searching Hadith books.
- BookService
- Service for fetching book information from Dorar.net.
- DetailedHadith
- Represents a hadith with all Dorar-specific metadata.
- DorarClient
- Main client for interacting with the Dorar Hadith API.
- DorarEndpoints
- API endpoints and URL builders for Dorar.net
- DorarHttpClient
- HTTP client wrapper for making requests to Dorar.net API.
- ExplainedHadith
- Lightweight hadith variant that carries takhrij and sharh availability.
- FileAssetLoader
- Asset loader implementation for Dart CLI applications.
- FlutterAssetLoader
-
Asset loader that delegates to a Flutter
AssetBundle. - Hadith
- Lightweight hadith record returned by the public Dorar API.
- HadithSearchParams
- Parameters for searching hadiths. Provides a type-safe way to construct search queries.
- HadithService
- Service for searching and retrieving hadiths from Dorar.net.
- HtmlUtils
- Utilities for handling HTML content and Arabic text.
- MohdithInfo
- Represents information about a Mohdith (hadith scholar).
- MohdithItem
- Lightweight model for scholar (mohdith) references.
- MohdithReference
- Reference class for Mohdith (hadith scholars/narrators). Represents a specific scholar with their ID and name.
- MohdithReferenceService
- Service for browsing and searching Hadith scholars (Muhaddithin).
- MohdithService
- Service for fetching mohdith (hadith scholar) information from Dorar.net.
- QuerySerializer
- Utilities for serializing search parameters to API query format
- Rawi
- RawiCompanion
- RawiDatabase
- RawiItem
- Minimal model for narrator (rawi) references.
- RawiReference
- Reference class for Rawi (hadith narrators/transmitters). Due to the large number of narrators (~14,000), only few of the companions are provided as constants.
- RawiReferenceService
- Service for browsing and searching narrators (Ruwat).
- ReferenceItem
- Base class for all reference data (books, scholars, narrators).
- SearchMetadata
- Metadata about search results from the API.
- Sharh
- Represents a hadith with its sharh (explanation/commentary).
- SharhMetadata
- Metadata about sharh (explanation/commentary) for a hadith.
- SharhService
- Service for fetching sharh (hadith explanations) from Dorar.net.
- UsulHadith
- Represents the complete Usul Hadith response with the main hadith and all its sources/chains.
- UsulSource
- Represents a source/chain for a hadith in Usul Hadith.
- Validators
- Validation utilities for Dorar API inputs.
Enums
- HadithDegree
- Enum representing the different degrees/grades of hadith authenticity. Based on the rulings of hadith scholars.
- SearchMethod
- Enum representing different search methods for hadith queries.
- SearchZone
- Enum representing different hadith type classifications. Used to filter hadiths by their category/nature rather than where to search.
Mixins
Extensions
-
ApiResponsePatterns
on ApiResponse<
T> - Adds pattern-matching-related methods to ApiResponse.
- BookInfoPatterns on BookInfo
- Adds pattern-matching-related methods to BookInfo.
- BookItemPatterns on BookItem
- Adds pattern-matching-related methods to BookItem.
- DetailedHadithPatterns on DetailedHadith
- Adds pattern-matching-related methods to DetailedHadith.
- ExplainedHadithPatterns on ExplainedHadith
- Adds pattern-matching-related methods to ExplainedHadith.
- HadithPatterns on Hadith
- Adds pattern-matching-related methods to Hadith.
- HadithSearchParamsPatterns on HadithSearchParams
- Adds pattern-matching-related methods to HadithSearchParams.
- MohdithInfoPatterns on MohdithInfo
- Adds pattern-matching-related methods to MohdithInfo.
- MohdithItemPatterns on MohdithItem
- Adds pattern-matching-related methods to MohdithItem.
- RawiItemPatterns on RawiItem
- Adds pattern-matching-related methods to RawiItem.
- SearchMetadataPatterns on SearchMetadata
- Adds pattern-matching-related methods to SearchMetadata.
- SharhMetadataPatterns on SharhMetadata
- Adds pattern-matching-related methods to SharhMetadata.
- SharhPatterns on Sharh
- Adds pattern-matching-related methods to Sharh.
- UsulHadithPatterns on UsulHadith
- Adds pattern-matching-related methods to UsulHadith.
- UsulSourcePatterns on UsulSource
- Adds pattern-matching-related methods to UsulSource.
Functions
-
configureFlutterAssetLoader(
{required Future< String> bundleLoader(String key), String keyResolver(String path)?}) → void - Registers the FlutterAssetLoader as the default asset loader.
-
createAssetLoader(
) → AssetLoader - Creates the default AssetLoader for the current platform.
-
createDefaultAssetLoaderBuilder(
) → AssetLoaderBuilder -
createFlutterConnectionFactory(
{required FlutterDatabaseAssetLoader loadDatabaseBytes, Directory? targetDirectory, String databaseFileName = 'rawi.db'}) → DatabaseConnection Function() -
Creates a
DatabaseConnectionfactory suited for Flutter environments. -
ensureDefaultAssetLoaderRegistered(
) → bool - Ensures the platform-default AssetLoader is registered and ready.
-
fuzzyMatch(
String text, String query) → bool - Check if a text contains a query using fuzzy Arabic matching.
-
getExceptionMessage(
DorarException exception) → String - Helper function to handle exceptions with pattern matching example
-
normalizeArabicSearch(
String text) → String - Normalize Arabic text for searching by removing diacritics and normalizing letter variations.
-
registerDefaultAssetLoader(
AssetLoaderBuilder builder) → void - Registers the default AssetLoader factory for the current platform.
-
similarityScore(
String text1, String text2) → double - Calculate a simple similarity score between two Arabic strings.
Typedefs
-
$$RawiTableCreateCompanionBuilder
= RawiCompanion Function({Value<
int> key, required String value}) -
$$RawiTableProcessedTableManager
= ProcessedTableManager<
_$RawiDatabase, $RawiTable, RawiItem, $$RawiTableFilterComposer, $$RawiTableOrderingComposer, $$RawiTableAnnotationComposer, $$RawiTableCreateCompanionBuilder, $$RawiTableUpdateCompanionBuilder, (RawiItem, BaseReferences< _$RawiDatabase, $RawiTable, RawiItem> ), RawiItem, PrefetchHooks Function()> -
$$RawiTableUpdateCompanionBuilder
= RawiCompanion Function({Value<
int> key, Value<String> value}) - AssetLoaderBuilder = AssetLoader Function()
- Signature for creating a new AssetLoader instance.
-
FlutterDatabaseAssetLoader
= Future<
Uint8List> Function() - Signature for loading the bundled database bytes in Flutter.
- RawiConnectionFactory = DatabaseConnection Function()
Exceptions / Errors
- AssetLoaderException
- Exception thrown when an asset fails to load.
- DorarException
- Base sealed class for all Dorar API exceptions. Using sealed classes provides exhaustive pattern matching.
- DorarNetworkException
- Exception thrown when there's a network connectivity issue.
- DorarNotFoundException
- Exception thrown when a resource is not found (404).
- DorarParseException
- Exception thrown when JSON parsing fails.
- DorarRateLimitException
- Exception thrown when rate limit is exceeded.
- DorarServerException
- Exception thrown when the server returns a 5xx error.
- DorarTimeoutException
- Exception thrown when a request times out.
- DorarValidationException
- Exception thrown when input validation fails.