This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Firestore.instance.collection(ProductModel.DB_REF).where({'sku': 'MYPRD'}).getDocuments().then( (result) { | |
| if ( result.documents.length == 0 ) | |
| debugPrint('No result found'); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ProductModel { | |
| static String DB_REF = 'products'; | |
| String key; | |
| String name; | |
| String sku; | |
| double price; | |
| List<String> images; | |
| DateTime created; | |
| DateTime updated; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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( |