Skip to content

Instantly share code, notes, and snippets.

View mhmzdev's full-sized avatar
🎯
You look better when smile, Gimme a smile now!

Hamza mhmzdev

🎯
You look better when smile, Gimme a smile now!
View GitHub Profile
class SurahsList {
final List<Surah> surahs;
SurahsList({this.surahs});
factory SurahsList.fromJSON(Map<String, dynamic> json) {
Iterable surahlist = json['data']['surahs'];
List<Surah> surahsList = surahlist.map((i) => Surah.fromJSON(i)).toList();
return SurahsList(surahs: surahsList);
class SajdaList {
final List<SajdaAyat> sajdaAyahs;
SajdaList({this.sajdaAyahs});
factory SajdaList.fromJSON(Map<String, dynamic> json) {
Iterable allSajdas = json['data']['ayahs'];
List<SajdaAyat> sajdas =
allSajdas.map((e) => SajdaAyat.fromJSON(e)).toList();
return SajdaList(sajdaAyahs: sajdas);
class QuranAPI {
Future<SurahsList> getSurahList() async {
String url = "http://api.alquran.cloud/v1/quran/quran-uthmani";
final response = await http.get(url);
if (response.statusCode == 200) {
return SurahsList.fromJSON(json.decode(response.body));
} else {
print("Failed to load");
throw Exception("Failed to Load Post");
codeAutoRetrievalTimeout() {
return (String verificationID) {
_verificationId = verificationID;
};
}
_verifyCode() async {
final AuthCredential credential = PhoneAuthProvider.getCredential(
verificationId: _verificationId, smsCode: _controllerCode.text);
final FirebaseUser user =
(await _auth.signInWithCredential(credential)).user;
final FirebaseUser currentUser = await _auth.currentUser();
assert(user.uid == currentUser.uid);
if (user != null) {
Navigator.pop(context);
Navigator.push(
codeSent() {
return (String verificationID, [int forceResendingToken]) {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) {
return AlertDialog(
title: Text('Enter 6-Digit Code'),
content: Column(
mainAxisSize: MainAxisSize.min,
verificationFailed() {
return (AuthException exception) {
print('Verification Failed: ${exception.code}');
}
}
verificationCompleted() {
return (AuthCredential credential) async {
await _auth.signInWithCredential(credential).then((AuthResult value) {
if (value.user != null) {
Navigator.pop(context);
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => SecondScreen(
user: value.user,
FlatButton(
onPressed: () async {
final phoneNumber = _controllerPhone.text.trim();
_verifyPhoneNumber(phoneNumber);
_controllerPhone.clear();
},
child:
Text(
"Login",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
@mhmzdev
mhmzdev / home.dart
Last active April 4, 2020 05:51
list view
Container(
height: 500,
margin: EdgeInsets.symmetric(horizontal: 10),
child: ListView.builder(
padding: EdgeInsets.symmetric(horizontal: 10),
itemCount: _tasks.length,
itemBuilder: (context, index) {
return ListTile(
leading: Icon(Icons.check),
title: Text(_tasks[index], style: TextStyle(color: !darkTheme ? Colors.black : Colors.white),),