Skip to content

Instantly share code, notes, and snippets.

Avatar
🦊

Bharathraj bharathraj-e

🦊
View GitHub Profile
@bharathraj-e
bharathraj-e / main.dart
Last active May 22, 2022
Expansion panel - single expanded
View main.dart
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
static const String _title = 'Flutter Code Sample';
@override
View blockquote-basic.dart
BlockQuote(
child:
Text(
'Lorem ipsum dolor sit amet, is the best place to hide a text.',
textAlign: TextAlign.justify,
),
),
View blockquote-options.dart
BlockQuote(
outerPadding: const EdgeInsets.all(20),
blockColor: Colors.blueAccent,
blockWidth: 5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
'Lorem ipsum dolor sit amet, is the best place to hide a text.',
textAlign: TextAlign.justify,
@bharathraj-e
bharathraj-e / db-crud.php
Last active Aug 25, 2020
PHP DB CRUD CLASS - API Based Structure
View db-crud.php
<?php
require_once __DIR__ . '/response.php';
require_once __DIR__ . '/db.php';
class CRUD
{
private $db;
public function __construct()
@bharathraj-e
bharathraj-e / check-request.php
Created Mar 29, 2020
Check request and finalize response
View check-request.php
<?php
function err($err)
{
$res['state'] = false;
$res['err'] = $err;
echo json_encode($res);
die();
}
View permission.dart
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;
}
@bharathraj-e
bharathraj-e / date_format.dart
Created Feb 1, 2020
date picker and date to user readable string
View date_format.dart
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),
@bharathraj-e
bharathraj-e / request.dart
Last active Sep 15, 2020
Flutter http request simplified
View request.dart
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'};
View responsive_ui_demo.dart
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 Jan 11, 2020
A function to create snackbar in flutter
View snacky-bar.dart
//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);
}