This dart plugin provides access to the Hadith data offline.
Available Hadith data:
- Bukhari
- Muslim
- Abu Dawud
- Tirmidhi
- Nasai
- Ibn Majah
Hadith data is taken from sunnah.com.
Getting Started
To use this plugin, add hadith as a dependency in your pubspec.yaml file.
Functions:
Collections:
getCollections()- Returns a list of Hadith collections availablegetCollection(Collection collection)- Takescollectionas an argument and returns a Collection object.getCollectionData(Collections collection, Languages language)- Takescollectionandlanguageas arguments and returns a CollectionData object.
Books:_
getBooks(Collections collection)- Takescollectionas an argument and returns a list of Book objects.getBook(Collections collection, int bookNumber)- TakescollectionandbookNumberas arguments and returns a Book object.getBookData(Collections collection, int bookNumber, Languages language)- Takescollection,bookNumberandlanguageas arguments and returns a BookData object.
Hadiths:
getHadiths(Collections collection, int bookNumber)- TakescollectionandbookNumberas arguments and returns a list of Hadith objects.getHadith(Collections collection, int bookNumber, int hadithNumber)- Takescollection,bookNumberandhadithNumberas arguments and returns a Hadith object.getHadithByNumber(Collections collection, String hadithNumber)- TakescollectionandhadithNumberas arguments and returns a Hadith object.getHadithData(Collections collection, int bookNumber, int hadithNumber, Languages language)- Takescollection,bookNumber,hadithNumberandlanguageas arguments and returns a HadithData object.getHadithDataByNumber(Collections collection, String hadithNumber, Languages language)- Takescollection,hadithNumberandlanguageas arguments and returns a HadithData object.
URLs:
getCollectionURL(Collections collection)- Takescollectionas argument and returns the URL (from sunnah.com) of that collectiongetBookURL(Collections collection, int bookNumber)- TakescollectionandbookNumberas arguments and returns the URL (from sunnah.com) of that book
Enums:
Collections:
- Bukhari -
Collections.bukhari - Muslim -
Collections.muslim - Abu Dawud -
Collections.abudawud - Tirmidhi -
Collections.tirmidhi - Nasai -
Collections.nasai - Ibn Majah -
Collections.ibnmajah
Languages:
- English -
Languages.en - Arabic -
Languages.ar
Example
Collections:
Get available collections:
import 'package:hadith/hadith.dart';
void main() {
print(getCollections());
}
Get a single collection:
import 'package:hadith/hadith.dart';
void main() {
print(getCollection(Collections.bukhari));
}
Get collection data:
import 'package:hadith/hadith.dart';
void main() {
print(getCollectionData(Collections.bukhari, Languages.en));
}
Books:
Get books of a collection:
import 'package:hadith/hadith.dart';
void main() {
print(getBooks(Collections.bukhari));
}
Get a single book:
import 'package:hadith/hadith.dart';
void main() {
print(getBook(Collections.bukhari, 1));
}
Get book data:
import 'package:hadith/hadith.dart';
void main() {
print(getBookData(Collections.bukhari, 1, Languages.en));
}
Hadiths:
Get hadiths of a book:
import 'package:hadith/hadith.dart';
void main() {
print(getHadiths(Collections.bukhari, 1));
}
Get a single hadith:
import 'package:hadith/hadith.dart';
void main() {
print(getHadith(Collections.bukhari, 1, 1));
}
Get hadith data:
import 'package:hadith/hadith.dart';
void main() {
print(getHadithData(Collections.bukhari, 1, 1, Languages.en));
}
Get hadith data by hadith number:
import 'package:hadith/hadith.dart';
void main() {
print(getHadithDataByNumber(Collections.bukhari, '1', Languages.en));
}
import 'package:hadith/hadith.dart';
void main() {
print(getHadithDataByNumber(Collections.muslim, '36 b', Languages.en));
}
URLs:
Get collection URL:
import 'package:hadith/hadith.dart';
void main() {
print(getCollectionURL(Collections.bukhari));
}
Get book URL:
import 'package:hadith/hadith.dart';
void main() {
print(getBookURL(Collections.bukhari, 1));
}