Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
vijaycreations

Vijay R vijayinyoutube

:octocat:
vijaycreations
View GitHub Profile
View elevated_btn.dart
ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: 0,
primary: primaryColor,
minimumSize: const Size(double.infinity, 50),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
),
child: Text(
View cascade.dart
void main() {
Student()
..name = 'Alice'
..id = 'A01'
..method1()
..method2();
}
View main.dart
void main() {
Student student = Student();
student.name='Alice';
student.id='A01';
student.method1();
student.method2();
}
View data.dart
class Student {
String? name;
String? id;
void method1() {
debugPrint('This is method 1. Name: $name');
}
void method2() {
debugPrint('This is method 2. ID: $id');
View ui.dart
import '../../../../Data/Models/home_page_model.dart';
import '../../../../Data/Repository/home_page_repo.dart';
import 'package:flutter/material.dart';
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
View repo.dart
import 'package:flutter_dotenv/flutter_dotenv.dart';
import '../API/base_client.dart';
import '../Models/home_page_model.dart';
abstract class DemoRepository {
Future<DemoModel> fetchData();
}
class DemoRepo extends DemoRepository {
View exception_handlers.dart
import 'dart:async';
import 'dart:io';
class ExceptionHandlers {
getExceptionString(error) {
if (error is SocketException) {
return 'No internet connection.';
} else if (error is HttpException) {
return 'HTTP error occured.';
} else if (error is FormatException) {
View base_client.dart
import 'dart:async';
import 'dart:convert';
import 'package:http/http.dart' as http;
import '../../Business_Logic/Exceptions/exception_handlers.dart';
class BaseClient {
static const int timeOutDuration = 35;
View sendOTP.dart
sendOTP(String phoneNumber) async {
this.phoneNumber = phoneNumber;
FirebaseAuth auth = FirebaseAuth.instance;
ConfirmationResult confirmationResult = await auth.signInWithPhoneNumber(
'+91 $phoneNumber',
);
printMessage("OTP Sent to +91 $phoneNumber");
return confirmationResult;
}
View validateOTP.dart
authenticateMe(ConfirmationResult confirmationResult, String otp) async {
UserCredential userCredential = await confirmationResult.confirm(otp);
userCredential.additionalUserInfo!.isNewUser
? printMessage("Successful Authentication")
: printMessage("User already exists");
}