Skip to content

Instantly share code, notes, and snippets.

View diefferson's full-sized avatar
🎯
Focusing

Diefferson Santos diefferson

🎯
Focusing
View GitHub Profile
@diefferson
diefferson / app_rest.dart
Last active January 24, 2024 15:43
Flutter error Handling
import 'dart:convert';
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:dio_cache_interceptor/dio_cache_interceptor.dart';
import 'package:flutter/services.dart';
import 'package:noodle_commons/src/domain/exception/error_handler.dart';
import 'package:noodle_commons/src/utils/json_utils.dart';
import 'package:uuid/uuid.dart';
import 'dio/dio_client.dart';
@diefferson
diefferson / account_api.dart
Last active January 24, 2024 15:26
Flutter API integration
import 'dart:io';
import 'dart:typed_data';
import 'package:base/base.dart';
import 'package:module_account/module_account.dart';
import 'package:module_banking/module_banking.dart';
class AccountApiV1 implements AccountApi {
AccountApiV1(
this._appRest
@diefferson
diefferson / Base strecture.md
Created January 24, 2024 14:57
Files structure sample
Captura de Tela 2024-01-24 às 11 54 12
@diefferson
diefferson / faq_page.dart
Created January 24, 2024 14:42
MVPA (BLOC) Example
import 'package:base/base.dart';
import 'package:flutter/material.dart';
import 'package:module_home/module_home.dart';
import 'package:module_home/src/analytics/help_events.dart';
import 'package:module_home/src/presentation/widgets/faq_category_item.dart';
import 'faq_page_actions.dart';
import 'faq_page_presenter.dart';
class FaqPage extends StatefulWidget {
@diefferson
diefferson / feedback_send_suggestion_page.dart
Created January 24, 2024 14:36
MVPA - (Block implementation)
import 'package:base/base.dart';
import 'package:flutter/material.dart';
import 'package:module_home/res/strings/home_strings.dart';
import 'package:module_home/src/analytics/feedback_events.dart';
import 'feedback_send_suggestion_presenter.dart';
import 'feedback_send_suggestion_actions.dart';
class FeedbackSendSuggestionPage extends StatefulWidget {
const FeedbackSendSuggestionPage({
super.key,
@diefferson
diefferson / example.dart
Created January 24, 2024 14:24
Flutter Themes
import 'package:design_system/design_system.dart';
import 'package:example/pages/buttons/buttons_example_page.dart';
import 'package:example/pages/feedbacks/feedbacks_example_page.dart';
import 'package:example/pages/inputs/inputs_example_page.dart';
import 'package:example/pages/inputs/liststile_example_page.dart';
import 'package:example/pages/inputs/searchfield_example_page.dart';
import 'package:example/pages/layouts/layouts_example_page.dart';
import 'package:flutter/material.dart';
void main() {
@diefferson
diefferson / example.dart
Last active April 12, 2023 23:34
Json utils
import 'package:base/base.dart';
class Client {
String name;
String socialName;
String email;
TaxIdentifier taxIdentifier;
Phone mobilePhone;
Address? mailAddress;
@diefferson
diefferson / cnpj.dart
Created June 21, 2022 20:07
Validate Pix
class CNPJ {
// Formatar número de CNPJ
static String? format(String? cnpj) {
if (cnpj == null) return null;
// Obter somente os números do CNPJ
final numbers = cnpj.replaceAll(RegExp(r'[^0-9]'), '');
// Testar se o CNPJ possui 14 dígitos
if (numbers.length != 14) return cnpj;
@diefferson
diefferson / finance_utils.dart
Last active March 16, 2022 13:50
FinanceUtils
import 'dart:math';
class FinanceUtils {
FinanceUtils._();
///Calcula o pagamento periódico de um investimento anual,
///com base em pagamentos periódicos e constantes
///e em uma taxa de juros constante.
static double calcPmt({
required double amount,
@diefferson
diefferson / genericSort.kt
Created March 11, 2022 13:38
Generic sort by field
package br.com.juno.domain.utils
data class Item (val id:Int, val name: String)
enum class ItemSortBy {
ID,
NAME
}
fun List<Item>.sortByField(field: ItemSortBy): List<Item> {