Skip to content

Instantly share code, notes, and snippets.

View Ansh-Rathod's full-sized avatar
😎
Nerd today, Boss tomorrow!

Ansh rathod Ansh-Rathod

😎
Nerd today, Boss tomorrow!
  • 127.0.0.1
  • Ahemdabad, Gujarat
  • 15:49 (UTC +05:30)
  • X @anshrathodfr
View GitHub Profile
@Ansh-Rathod
Ansh-Rathod / ffmepg_scale_video.dart
Last active August 24, 2024 09:22
Never have those width/height not divisible by 2 or padding dimensions are lower than size errors anymore. script is in dart you can ask ai to convert.
import 'dart:convert';
import 'dart:io';
import 'dart:math';
String generateScaleCommand(
int inputWidth, int inputHeight, int originalWidth, int originalHeight) {
final aspectRatio = originalWidth / originalHeight;
bool fitToWidth = inputWidth > inputHeight;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Ansh-Rathod
Ansh-Rathod / hotreload.sh
Last active November 11, 2023 08:25
flutter auto hot reload script.
#!/bin/bash
chmod 777 ./hotreloader.sh
echo 'Script is running';
while true
do
find lib/ -name '*.dart' | entr -dnp ./hotreloader.sh /_
done
@Ansh-Rathod
Ansh-Rathod / rotated_resizable_widget.dart
Created July 1, 2023 05:12
rotated_resizable_widget example
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:flutter/material.dart';
const duration = Duration(milliseconds: 50);
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
@Ansh-Rathod
Ansh-Rathod / main.dart
Last active June 30, 2023 10:00
Resizable-widget with rotation
import 'dart:math' as math;
import 'dart:ui';
import 'package:flutter/material.dart';
const duration = Duration(milliseconds: 50);
extension OffsetExtensions on Offset {
Offset offsetDistance(Offset end) {
double dx = end.dx - this.dx;
@Ansh-Rathod
Ansh-Rathod / deplayed_slide_up_animation.dart
Created March 8, 2023 11:56
slide up animation with fade animation
import 'dart:async';
import 'package:flutter/material.dart';
class DelayedDisplay extends StatefulWidget {
final Widget child;
final Duration delay;
final Duration fadingDuration;
// https://pub.dev/packages/file_picker
import 'package:file_picker/file_picker.dart';
getMultipalFiles() async {
FilePickerResult? result = await FilePicker.platform.pickFiles(allowMultiple: true);
List<File> files = [];
if (result != null) {
files = result.paths.map((path) => File(path)).toList();
} else {
@Ansh-Rathod
Ansh-Rathod / get_dynamic_color.dart
Created September 15, 2021 12:27
How To get dynamic colors from image in flutter.
import 'package:flutter/material.dart';
import 'package:palette_generator/palette_generator.dart';
class ColorGenrator {
Future<List<Color>> getImagePalette(ImageProvider imageProvider) async {
try {
final PaletteGenerator paletteGenerator =
await PaletteGenerator.fromImageProvider(
imageProvider,