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 / localization.dart
Last active April 16, 2024 04:13
Portuguese BR Localization Flutter
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:intl/date_symbol_data_local.dart' as intl;
import 'package:intl/intl.dart' as intl;
class _PTBRMaterialLocalizationsDelegate
extends LocalizationsDelegate<MaterialLocalizations> {
@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 / cnpj.pipe.ts
Created July 13, 2018 20:42
Angular Pipe CNPJ
@Pipe({name: 'cnpj'})
export class CNPJPipe implements PipeTransform {
transform(value) {
return value.replace(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/g,"\$1.\$2.\$3\/\$4\-\$5")
}
}
@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 / saveImage.java
Created February 18, 2018 00:25
Save Image File in Android
public static void saveImage(Bitmap bitmapImage) {
File root = new File(Environment.getExternalStorageDirectory(), "Identidata");
if (!root.exists()) {
root.mkdirs();
}
File mypath = new File(root,"debug.jpg");
@valterh4ck3r
valterh4ck3r / sendEmail.kt
Created August 11, 2018 00:22
Send Email Android Kotlin
fun sendEmail(context: Context) {
val emailIntent = Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto", email@example.com, null))
emailIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.label_subject_email))
emailIntent.putExtra(Intent.EXTRA_TEXT, context.getString(R.string.label_email_description))
startActivity(Intent.createChooser(emailIntent, context.getString(R.string.label_send_email))
}
@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>