Skip to content

Instantly share code, notes, and snippets.

View bharathraj-e's full-sized avatar
🦊

Bharathraj bharathraj-e

🦊
View GitHub Profile
class ResponsiveExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[350],
appBar: AppBar(
title: Text('Responsive Example'),
centerTitle: true,
),
body: Container(
@bharathraj-e
bharathraj-e / snacky-bar.dart
Created January 11, 2020 04:19
A function to create snackbar in flutter
//final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
snackyBar(String content, GlobalKey<ScaffoldState> _scaffoldKey) {
final snackBar = SnackBar(
content: Text(content),
duration: const Duration(seconds: 2),
backgroundColor: Colors.lightBlue,
);
_scaffoldKey.currentState.showSnackBar(snackBar);
}
@bharathraj-e
bharathraj-e / json-decode.php
Last active July 13, 2020 05:17
decode json from file_get_contents(); ,with error displaying
function decodeJson($json, $assoc = false)
{
$json = preg_replace('/[\x00-\x1F\x7F]/u', '', $json);
$ret = json_decode($json, $assoc);
if ($error = json_last_error()) {
$errorReference = [
JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded.',
JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON.',
JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded.',
JSON_ERROR_SYNTAX => 'Syntax error.',
@bharathraj-e
bharathraj-e / error-reporting.php
Created January 9, 2020 07:13
Turning on-off error reporting in php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
@bharathraj-e
bharathraj-e / prefs.dart
Last active February 4, 2023 09:55
flutter shared preferences singleton shortcut for set and get
import 'package:shared_preferences/shared_preferences.dart';
class Prefs {
static SharedPreferences _prefs;
// call this method from iniState() function of mainApp().
static Future<SharedPreferences> init() async {
_prefs = await SharedPreferences.getInstance();
return _prefs;
@bharathraj-e
bharathraj-e / webview_downloader.java
Created January 7, 2020 04:19
webview file download code for android studio
webView.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimeType, long contentLength) {
DownloadManager.Request request = new
DownloadManager.Request(Uri.parse(url));
request.setMimeType(mimeType);
//------------------------COOKIE!!------------------------
String cookies = CookieManager.getInstance().getCookie(url);
request.addRequestHeader("cookie", cookies);