Skip to content

Instantly share code, notes, and snippets.

View shaon2016's full-sized avatar

Ashiqul Islam Shaon shaon2016

View GitHub Profile
@shaon2016
shaon2016 / A Singleton SharedPref
Created July 18, 2021 09:19
A Singleton sharedpref using GetX
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';
class SharedPref extends GetxService {
static late SharedPreferences _pref;
Future<SharedPref> init() async {
_pref = await SharedPreferences.getInstance();
return this;
}
import android.content.Context
import com.sslwireless.alil.view.activity.payment.SSLCommerzCredentialResponseData
import com.sslwireless.sslcommerzlibrary.model.initializer.SSLCommerzInitialization
import com.sslwireless.sslcommerzlibrary.model.util.SSLCCurrencyType
import com.sslwireless.sslcommerzlibrary.model.util.SSLCSdkType
import com.sslwireless.sslcommerzlibrary.view.singleton.IntegrateSSLCommerz
import com.sslwireless.sslcommerzlibrary.viewmodel.listener.SSLCTransactionResponseListener
object MySSLCommerz {
fun initPayment(
@shaon2016
shaon2016 / RestClient and Db
Last active June 19, 2021 16:29
Networking Client using Dio package and DB using Floor package
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:dio/dio.dart';
import 'package:get/get_state_manager/src/rx_flutter/rx_disposable.dart';
enum Method { POST, GET, PUT, DELETE, PATCH }
const BASE_URL = "https://hris.sslwireless.com/api/v1/";
import 'package:clean_architecture/feature/home/controller/HomeController.dart';
import 'package:get/get.dart';
class HomeBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<HomeController>(() => HomeController());
}
}
@shaon2016
shaon2016 / Pagination
Created June 19, 2021 16:15
Example to show pagination using GetX
class HomeController extends BaseController with StateMixin, ScrollMixin {
final donors = <BloodDonors>[].obs;
var page = 1;
var isToLoadMore = true;
@override
onInit() {
super.onInit();
@shaon2016
shaon2016 / BaseController
Created June 19, 2021 16:03
BaseController for all GetXController
import 'package:clean_architecture/core/network/rest_client.dart';
import 'package:get/get.dart';
class BaseController extends GetxController {
late RestClient restClient;
@override
onInit() {
super.onInit();
restClient = Get.find();
@shaon2016
shaon2016 / SpinnerDialog.txt
Last active September 24, 2020 11:43
Create a spinner dialog using Recycler view and Higher order function
# This is the Util function
````
import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.view.LayoutInflater
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
@shaon2016
shaon2016 / P
Created December 10, 2019 12:18
object P {
private val TAG = P::class.java.simpleName
private var prefs: SharedPreferences? = null
private var prefsEditor: SharedPreferences.Editor? = null
@SuppressLint("CommitPrefEdits")
private fun assurePrefNotNull(context: Context) {
if (prefs == null)
@shaon2016
shaon2016 / Util
Last active December 10, 2019 12:16
Util functions
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.animation.ValueAnimator
import android.annotation.SuppressLint
import android.app.Activity
import android.app.AlertDialog
import android.app.Dialog
import android.content.Context
import android.content.Intent
// For pre lollipop and post lollipop
import android.content.IntentFilter
import android.net.ConnectivityManager.CONNECTIVITY_ACTION
import android.util.Log
import com.firebase.jobdispatcher.JobParameters
import com.firebase.jobdispatcher.JobService
import com.osellers.fragments.HomeFragment
import com.osellers.receiver.ConnectivityReceiver