Skip to content

Instantly share code, notes, and snippets.

View Sp4Rx's full-sized avatar
👾
GG!!

Suvajit Sarkar Sp4Rx

👾
GG!!
View GitHub Profile
@Sp4Rx
Sp4Rx / main.dart
Created September 4, 2023 02:58
Switch Button Stateless
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
{
"W": 512,
"H": 512,
"tiling": false,
"restore_faces": false,
"seed": -1,
"sampler": "DPM++ SDE Karras",
"seed_resize_from_w": 0,
"seed_resize_from_h": 0,
"steps": 25,
@Sp4Rx
Sp4Rx / main.dart
Created January 16, 2023 11:29
Video in page view
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
///Set your video from asset.
const String VIDEO_ASSET = 'assets/Butterfly-209.mp4';
void main() {
runApp(
MaterialApp(
home: _App(),
@Sp4Rx
Sp4Rx / api_client.dart
Created January 5, 2023 11:53
Flutter Api Client with dio
import 'dart:developer';
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart' as getX;
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tranzact/revamp/core/api_client/api_exception.dart';
import 'package:tranzact/revamp/core/api_client/api_result.dart';
@Sp4Rx
Sp4Rx / AndroidManifest.xml
Created December 28, 2022 03:48
Tranzact manifiest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.letstranzact.app">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />
<application
android:name="com.letstranzact.tranzact.MainApplication"
android:icon="@mipmap/ic_launcher"
@Sp4Rx
Sp4Rx / main.dart
Created September 27, 2022 21:31
Sticky bottom sheet
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@Sp4Rx
Sp4Rx / main.dart
Last active March 30, 2021 12:26
Benchmarking for to test -- operator x ~/ y is more efficient than (x / y).toInt().
import 'dart:typed_data';
void main() {
const t = 99999999999999999999.0; //A big number
const step = 18871268712.0; //Random number
const max = 999999;
//Initialise time for calculating benchmark.
var initialTime = DateTime.now().millisecondsSinceEpoch;
for (int i = 0; i < max; i++) {
@Sp4Rx
Sp4Rx / weird_dart_mixin.dart
Created June 28, 2020 00:24
Weird Dart Mixin
void main() {
Foo foo = Foo();
print(foo.fromA);
print(foo.fromB);
print("=====================");
Foo1 foo1 = Foo1();
print(foo1.fromC);
print(foo1.fromD);
@Sp4Rx
Sp4Rx / JsonKey.dart
Created May 20, 2020 12:45
Just to check what dart returns if there is no key
void main() {
var data = {'key': 'value'};
try {
var value = data['wrongKey'];
print(value);
value = data['key'];
print(value);
print('---------------');
//This is just to simulate an error
@Sp4Rx
Sp4Rx / ImageFilePath.java
Last active December 7, 2017 11:44
Get real image path from uri
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;