Skip to content

Instantly share code, notes, and snippets.

View Vanethos's full-sized avatar
⚒️
WIP

Gonçalo Palma Vanethos

⚒️
WIP
View GitHub Profile
@Vanethos
Vanethos / enum_extension.dart
Created October 27, 2020 12:08
Enum extension
enum StarterPokemonEnum { bulbasaur, charmander, squirtle, }
/// This extension will give us the possibility to return a String
/// when we call the [name] getter
extension StarterPokemonToString on StarterPokemonEnum {
String get name {
switch (this) {
case StarterPokemonEnum.bulbasaur:
return "Bulbasaur";
case StarterPokemonEnum.charmander:
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
@Vanethos
Vanethos / build.sh
Last active May 31, 2023 09:21
Script to run Flutter Apps
#!/bin/bash
BLUE='\x1b[34m\x1b[1m'
NC='\x1b[0m' # No Color
echo ""
printf "${BLUE}[ 🏗️ ] Build models${NC} \n"
cd modules/models
flutter packages pub run build_runner build --delete-conflicting-outputs
cd ../..
// file: src/server_login.dart
class LoginManager {
LoginManager._();
static final LoginManager instance = LoginManager._();
String login(String username, String password) => "Servered $username";
}
// file: src/firebase_login.dart
class LoginManager {
LoginManager._();
static final LoginManager instance = LoginManager._();
String login(String username, String password) => "Firebased $username";
}
Debug mode on device (including simulators, emulators):
Turns on all the assertions in the world, includes all debugging information, enables all the debugger aids (e.g. observatory) and service extensions.
Optimizes for fast develop/run cycles. Does not optimize for execution speed, binary size, or deployment.
Used by flutter run. Built with sky/tools/gn --android or sky/tools/gn --ios.
Also sometimes called "checked mode" or "slow mode".
@Vanethos
Vanethos / rsa_pem.dart
Created March 5, 2019 21:59 — forked from proteye/rsa_pem.dart
How to encode/decode RSA private/public keys to PEM format in Dart with asn1lib and pointycastle
import 'dart:convert';
import 'dart:math';
import 'dart:typed_data';
import "package:pointycastle/export.dart";
import "package:asn1lib/asn1lib.dart";
List<int> decodePEM(String pem) {
var startsWith = [
"-----BEGIN PUBLIC KEY-----",
"-----BEGIN PRIVATE KEY-----",
@Vanethos
Vanethos / BaseService.java
Created June 12, 2018 08:48
Generic Gson Deserializer and raw data GSON parser.
/*
* This class assumes that you use both RXJava and Dagger 2 in your project
*
*/
public abstract class BaseLocalService<T> {
protected ResourceProvider mResourceProvider;
protected Gson mGson;