Skip to content

Instantly share code, notes, and snippets.

View fabiomsr's full-sized avatar

Fabio Santana fabiomsr

View GitHub Profile
@fabiomsr
fabiomsr / notifications_1.dart
Created May 1, 2019 18:50
Flutter Notifications and Values
class TimeNotification extends Notification {
final String time;
const TimeNotification({this.time});
}
void preTranslate(Matrix4 leftMatrix, double x, double y) {
if(x == 0 && y == 0) {
return;
}
for (int i = 0; i < 4; ++i) {
var value = leftMatrix.entry(0, i) * x + leftMatrix.entry(1, i) * y;
value += leftMatrix.entry(2, i) + leftMatrix.entry(3, i);
leftMatrix.setEntry( 3, i, value);
}
@fabiomsr
fabiomsr / contact_list_view.dart
Last active December 9, 2018 16:30
Navigator push
class _ContactListState extends State<ContactList> implements ContactListViewContract {
// ...
List<_ContactListItem> _buildContactList() {
return _contacts.map((contact) =>
_ContactListItem (
contact: contact,
onTap: () { _showContactPage(context, contact); }
))
@fabiomsr
fabiomsr / contact_detail_view.dart
Last active December 9, 2018 16:29
Build categories
class ContactPage extends StatelessWidget {
// ...
_ContactCategory _buildPhoneCategory() {
var phoneItems = _contact.phones.map((phone) =>
_ContactCategoryItem(
icon: Icons.message,
lines: <String>[phone.number, phone.type]
)).toList();
@fabiomsr
fabiomsr / contact_detail_page.dart
Last active December 9, 2018 16:22
Contact Page
class ContactPage extends StatelessWidget {
static const String routeName = '/contact';
final Contact _contact;
ContactPage(this._contact);
@override
Widget build(BuildContext context) {
@fabiomsr
fabiomsr / contact_detail_view.dart
Last active December 9, 2018 16:21
Contact Category
class _ContactCategory extends StatelessWidget {
final IconData icon;
final List<_ContactCategoryItem> children;
_ContactCategory({Key key, this.icon, this.children}): super(key: key);
@override
Widget build(BuildContext context) {
final ThemeData themeData = Theme.of(context);
@fabiomsr
fabiomsr / contact_detail_view.dart
Last active December 20, 2018 13:52
Contact detail item
class _ContactCategoryItem extends StatelessWidget {
final IconData icon;
final List<String> lines;
_ContactCategoryItem({ Key key, @required this.icon, @required this.lines })
: super(key: key);
@override
Widget build(BuildContext context) {
@fabiomsr
fabiomsr / app_bar.dart
Last active December 9, 2018 16:16
Flutter DecoratedBox
DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: const FractionalOffset(0.5, 0.6),
end: const FractionalOffset(0.5, 1.0),
colors: <Color>[const Color(0x00000000), const Color(0x70000000)]
)
)
)
@fabiomsr
fabiomsr / app_bar.dart
Last active January 2, 2019 12:52
Flutter flexible app bar
import 'package:flutter/material.dart';
class FlexibleAppBar extends SliverAppBar {
static const double height = 256.0;
FlexibleAppBar(String title, String imageUrl) : super(
pinned: true,
expandedHeight: height,
flexibleSpace: FlexibleSpaceBar(
title: Text(title),
@fabiomsr
fabiomsr / contact_data.dart
Last active February 24, 2019 07:43
Contact data
import 'dart:async';
import 'package:intl/intl.dart';
class Contact {
static final DateFormat _formatter = DateFormat('MMMM d, yyyy');
final String fullName;
final String gender;