Skip to content

Instantly share code, notes, and snippets.

View haroonkhan9426's full-sized avatar

Haroon khan haroonkhan9426

View GitHub Profile
@haroonkhan9426
haroonkhan9426 / local-state-example.dart
Last active April 6, 2020 14:47
Managing Local State Example
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
bool isChecked = false;
@override
Widget build(BuildContext context) {
enum AuthResultStatus {
successful,
emailAlreadyExists,
wrongPassword,
invalidEmail,
userNotFound,
userDisabled,
operationNotAllowed,
tooManyRequests,
undefined,
class AuthExceptionHandler {
static handleException(e) {
print(e.code);
var status;
switch (e.code) {
case "ERROR_INVALID_EMAIL":
status = AuthResultStatus.invalidEmail;
break;
case "ERROR_WRONG_PASSWORD":
status = AuthResultStatus.wrongPassword;
@haroonkhan9426
haroonkhan9426 / firebase-auth-helper.dart
Last active September 5, 2020 09:00
Firebase Authentication
class FirebaseAuthHelper {
final _auth = FirebaseAuth.instance;
AuthResultStatus _status;
///
/// Helper Functions
///
Future<void> createAccount({email, pass}) async {
try {
_createAccount() async {
final status = await FirebaseAuthHelper().createAccount(
email: email, pass: password);
if (status == AuthResultStatus.successful) {
// Navigate to success page
} else {
final errorMsg = AuthExceptionHandler.generateExceptionMessage(
status);
_showAlertDialog(errorMsg);
}
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
class LocationService {
/// BuildContext is used to show alert dialog later.
BuildContext context;
LocationService(this.context);
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.maps_blog_part1">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<application
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:maps_blog_part1/services/location_service.dart';
class CurrentLocationExample extends StatefulWidget {
@override
_CurrentLocationExampleState createState() => _CurrentLocationExampleState();
}
class _CurrentLocationExampleState extends State<CurrentLocationExample> {
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:maps_blog_part1/services/location_service.dart';
class RealtimeLocationUpdateExample extends StatefulWidget {
@override
_RealtimeLocationUpdateExampleState createState() =>
_RealtimeLocationUpdateExampleState();
}
@haroonkhan9426
haroonkhan9426 / readme.md
Created May 12, 2022 08:31 — forked from umairian/readme.md
AntonX Node (Express) Task

Build A Small Ecommerce App - AntonX Full Stack Task

Backend Technologies to be Used

Express and Sequelize (MySQL)

Backend Requirements

  1. Make two tables users and shops via migrations in the database.
  2. users table must contain name, email, password(must be hashed), role(ENUM type having User, Admin values), createdAt and updatedAt fields.
  3. While shops table must contain name, description, fk_user_id(foreign key of users table), address, createdAt, and updatedAt fields.
  4. There should be one to many relationship between users and shops.i.e. one user can have multiple shops.