Skip to content

Instantly share code, notes, and snippets.

View JoorgeFerrari's full-sized avatar

OFF! Studio Digital JoorgeFerrari

  • Balneário Camboriú, SC
View GitHub Profile
@JoorgeFerrari
JoorgeFerrari / phone_formatter.dart
Created July 21, 2020 00:22
Formatar número telefone celular brasileiro com Flutter / Dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class PhoneFormatter extends TextInputFormatter {
@override
TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
if ( newValue.text.length < oldValue.text.length ) {
bool isLastNumber = int.tryParse( newValue.text.substring(newValue.text.length - 1) ) != null;
if ( !isLastNumber )
return newValue;
@JoorgeFerrari
JoorgeFerrari / my_gridview.dart
Created July 17, 2020 11:59
Simple GridView with Flutter
class MyGridview extends StatelessWidget {
List<dynamic> myitems = [ 'lorem', 'ipsum', 'dolor' ];
@override
Widget build(BuildContext context) {
return GridView.count(
crossAxisCount: 2, // This defined the number of itens on each row
childAspectRatio: 0.85, // You use this to define the height of each child, kind of tricky at first
children: List.generate(myitems.length, (index) {
@JoorgeFerrari
JoorgeFerrari / querying_firestore.dart
Created July 16, 2020 16:30
Querying Firestore in Flutter
Firestore.instance.collection(ProductModel.DB_REF).where({'sku': 'MYPRD'}).getDocuments().then( (result) {
if ( result.documents.length == 0 )
debugPrint('No result found');
});
@JoorgeFerrari
JoorgeFerrari / product_modal.dart
Created July 16, 2020 15:31
Basic Model for Flutter With Firebase Firestore
class ProductModel {
static String DB_REF = 'products';
String key;
String name;
String sku;
double price;
List<String> images;
DateTime created;
DateTime updated;
@JoorgeFerrari
JoorgeFerrari / gridview_flexible_fix.dart
Created July 16, 2020 15:07
Using GridView inside Column and ListView with Flexible
class GridviewFlexibleFix extends StatelessWidget {
List<dynamic> mylist = [ 'one', 'two', 'three' ];
@override
Widget build(BuildContext context) {
return Column(
children: [
Text('Some other elements you might need'),
Flexible(
@JoorgeFerrari
JoorgeFerrari / gridview_container_fix.dart
Last active July 16, 2020 15:06
Use GridView insite ListView or Column with Container wrapping
class GridviewContainerFix extends StatelessWidget {
List<dynamic> mylist = [ 'one', 'two', 'three' ];
@override
Widget build(BuildContext context) {
return Column(
children: [
Text('Some other elements you might need'),
Container(