Skip to content

Instantly share code, notes, and snippets.

View shishirthedev's full-sized avatar

Ahidul Islam shishirthedev

View GitHub Profile
// Url Launcher ...
url_launcher: ^0.4.2
// Permission Handler...
permission_handler: ^3.2.1+1
// Device & Package Info...
device_info: ^0.1.2
package_info: ^0.4.0+6
import 'dart:convert' show utf8, base64;
main() {
final str = 'https://dartpad.dartlang.org/';
final encoded = base64.encode(UTF8.encode(str));
print('base64: $encoded');
final str2 = utf8.decode(base64.decode(encoded));
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
class PreferenceManager {
static PreferenceManager sharedInstance = PreferenceManager();
//<<<<<<<<<<<<<<<<<<<<<<<< All Setters <<<<<<<<<<<<<<<<<<<<<<
Future<bool> putString(String key, String value) async {
Initiate passwordVisible to false in initState()
@override
void initState() {
passwordVisible = false;
}
Following is the TextFormField widget :
TextFormField(
//// Using Device Info Package................
Future<String> _getId() async {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
if (Theme.of(context).platform == TargetPlatform.iOS) {
IosDeviceInfo iosDeviceInfo = await deviceInfo.iosInfo;
return iosDeviceInfo.identifierForVendor; // unique ID on iOS
} else {
AndroidDeviceInfo androidDeviceInfo = await deviceInfo.androidInfo;
return androidDeviceInfo.androidId; // unique ID on Android
import 'package:flutter/foundation.dart' show TargetPlatform;
//...
if(Theme.of(context).platform == TargetPlatform.android)
//do sth for Android
else if(Theme.of(context).platform == TargetPlatform.iOS)
//do sth else for iOS
else if(Theme.of(context).platform == TargetPlatform.fuchsia)
public abstract class BaseAdapter<D> extends RecyclerView.Adapter<BaseViewHolder> {
public static final int VIEW_TYPE_ITEM = 1;
public static final int VIEW_TYPE_FOOTER = 2;
protected ArrayList<D> dataList;
protected Context context;
protected LayoutInflater layoutInflater;
public String getAssetJsonData(Context context, String jsonFileName) {
String json = null;
try {
InputStream is = context.getAssets().open(jsonFileName + ".json");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
json = new String(buffer, "UTF-8");
@shishirthedev
shishirthedev / iOS-tableView-adapter.swift
Last active May 15, 2019 05:42
iOS tableview adapter custom code with pagination and refresh Control....
import UIKit
protocol SSAdapterDelegate {
func willDisplay(cell: UITableViewCell, indexPath: IndexPath)
func didSelected(indexPath: IndexPath)
func hasNextPage()->Bool
func isLoadingFooterAdded()->Bool
func loadMoreData()
func refreshTableData()
import UIKit
import SafariServices
class AppUtils: NSObject {
private override init() {}
public static let shared: AppUtils = AppUtils()
func showSafariVc(in vc: UIViewController, for url: String){