Skip to content

Instantly share code, notes, and snippets.

View valterh4ck3r's full-sized avatar
🏠
Working from home

Valter Negreiros valterh4ck3r

🏠
Working from home
View GitHub Profile
@valterh4ck3r
valterh4ck3r / SDL_gamecontrollerdb.h
Created October 5, 2024 02:06
Controller GUIDs with PS5 Controller
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <[email protected]>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
@valterh4ck3r
valterh4ck3r / upload_image.dart
Last active December 13, 2023 21:17
Flutter - Upload Image with ImagePicker Web and Firebase Storate
import 'dart:html' as html;
import 'package:uuid/uuid.dart';
import 'package:image_picker_web/image_picker_web.dart';
Future uploadImage() async {
var image = await ImagePicker().pickImage(source: ImageSource.gallery);
if (image != null) {
final metadata = SettableMetadata(
@valterh4ck3r
valterh4ck3r / storage_util.dart
Created April 9, 2023 03:47
Storage Util Flutter using Path Provider
import 'dart:convert';
import 'package:encrypt/encrypt.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:async';
import 'dart:io';
class StorageUtil {
static Future<String> getLocalPath() async {
@valterh4ck3r
valterh4ck3r / validate_email.dart
Created June 27, 2022 18:49
Validate Email Flutter Dart
class Util {
static bool isEmail(String email){
return RegExp(r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+").hasMatch(email);
}
}
@valterh4ck3r
valterh4ck3r / animated_button.dart
Last active May 5, 2022 16:20
Animated Button with States
import 'package:flutter/material.dart';
class AnimatedButton extends StatefulWidget {
bool Function() validate;
Function() onPressed;
bool isLoading;
bool isSuccess;
String text;
AnimatedButton(
@valterh4ck3r
valterh4ck3r / setupNavigationColor.kt
Created October 8, 2021 18:59
Android Kotlin - Change Navigation Bar Color
private fun setupNavigationColor(){
window.navigationBarColor = ContextCompat.getColor(this, R.color.colorAccent)
}
@valterh4ck3r
valterh4ck3r / slide_in_left.xml
Last active April 2, 2021 00:48
Android Animation Navigation
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="-100%" android:toXDelta="0%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="300"/>
</set>
@valterh4ck3r
valterh4ck3r / date_time_extension.dart
Last active December 22, 2020 01:44
Dart isToday DateTime Extension
extension DateTimeExtension on DateTime {
bool isSameDay(DateTime otherDate){
DateTime today = DateTime.now();
return otherDate.day == today.day && otherDate.month == today.month && otherDate.year == today.year;
}
bool isToday(){
DateTime today = DateTime.now();
return this.day == today.day && this.month == today.month && this.year == today.year;
}
@valterh4ck3r
valterh4ck3r / main.dart
Last active November 6, 2020 23:10
DateTime with Zone in Flutter
//Assumes Instant is in your pubspec
import 'package:instant/instant.dart';
//Super Simple!
DateTime myDT = DateTime.now(); //Current DateTime
DateTime EastCoast = dateTimeToZone(zone: "EST", datetime: myDT); //DateTime in EST zone
return EastCoast;
@valterh4ck3r
valterh4ck3r / build_runnder.sh
Created October 7, 2020 22:54
Flutter - Mobx Code Gen Delete Conflicts
flutter packages pub run build_runner watch --delete-conflicting-outputs