Skip to content

Instantly share code, notes, and snippets.

View rapPayne's full-sized avatar
:octocat:
Working from home

Rap Payne rapPayne

:octocat:
Working from home
View GitHub Profile
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Prestige Worldwide Registration")),
// TODO 1: Wrap the body in a Form widget
body: Form( // <-- Add this widget. (Don't forget to close it!)
child: Container(
alignment: Alignment.center,
child: Column(
children: <Widget>[
@rapPayne
rapPayne / Register.dart
Last active September 24, 2020 17:31
Medium - Flutter Forms Ultimate Guide 1 adding a form
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Prestige Worldwide Registration")),
// TODO 1: Wrap the body in a Form widget
body: Container(
alignment: Alignment.center,
child: Column(
children: <Widget>[
_buildEmailField,
@rapPayne
rapPayne / PersonUpsert.dart
Last active October 16, 2019 20:25
Flutter/Firebase person upsert form
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
class PeopleUpsert extends StatefulWidget {
@override
_PeopleUpsertState createState() => _PeopleUpsertState();
}
class _PeopleUpsertState extends State<PeopleUpsert> {
GlobalKey<FormState> _key = GlobalKey<FormState>();
// Say goReadAFile() is slow and returns a Future
Future myFuture = goReadAFile();
@rapPayne
rapPayne / AsynCallback.dart
Last active June 3, 2019 22:52
To get a value out of an async callback, you set an external variable
class FooState extends State<FooComponent> {
String _firstName; // <-- A variable known by the whole class
Widget build(BuildContext context) {
// return a widget
}
void _myCallback(String someVar) {
_firstName = someVar; // <-- Getting a value OUT of an async callback
}
}
@rapPayne
rapPayne / futures.md
Last active March 30, 2019 19:41
Futures - Table of Futures examples
Type of future When it's ready, I'll have a ...
Future<String> ... string
Future<Foo> ... Foo
Future> ... Map whose keys are Strings and whose values are dynamic.
@rapPayne
rapPayne / async.dart
Last active March 30, 2019 19:27
Futures - Async after
Future<Bar> someFunction() async {
Foo theIncomingData = await somethingThatReturnsAFuture();
return new Bar();
}
@rapPayne
rapPayne / async.dart
Last active April 29, 2019 13:11
Futures - Async before
Bar someFunction() {
  Foo theIncomingData = someFunction();
return new Bar();
}
@rapPayne
rapPayne / callbackSig.dart
Last active June 3, 2019 22:44
Futures - Signature of a callback
void myCallback(Foo theIncomingData) {
 doSomethingWith(theIncomingData);
}
@rapPayne
rapPayne / Landing.dart
Last active March 24, 2019 14:34
React Native vs Flutter - Flutter's build method
@override
Widget build(BuildContext context) {
return StoreProvider<AppState>(
store: this.store,
child: StoreConnector<AppState, AppState>(converter: (store) {
return store.state;
},
builder: (context, callback) {
if (store.state.showFilmDetails) // <-- 9
return showFilmDetails(this.store.state.selectedFilm); // <-- 9