This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ini_set('display_errors', 1); | |
ini_set('display_startup_errors', 1); | |
error_reporting(E_ALL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:convert'; | |
import 'package:http/http.dart' as http; | |
const String _host = "https://<....>"; | |
class MyRequest { | |
final String url; | |
final Map<String, String> headers = {'Authorization': 'Bearer token'}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:intl/intl.dart'; | |
Future<DateTime> fetchDate(BuildContext context, | |
{DateTime initialDate, DateTime last}) async { | |
DateTime t = await showDatePicker( | |
context: context, | |
firstDate: DateTime(DateTime.now().year - 1), | |
initialDate: initialDate ?? DateTime.now(), | |
lastDate: last ?? DateTime(DateTime.now().year + 2), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:permission_handler/permission_handler.dart'; | |
() async { | |
PermissionStatus p = await PermissionHandler() | |
.checkPermissionStatus(PermissionGroup.contacts); | |
if (p == PermissionStatus.disabled) { | |
// permission got already / success | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function err($err) | |
{ | |
$res['state'] = false; | |
$res['err'] = $err; | |
echo json_encode($res); | |
die(); | |
} |
OlderNewer