Skip to content

Instantly share code, notes, and snippets.

View timsneath's full-sized avatar

Tim Sneath timsneath

View GitHub Profile
@timsneath
timsneath / dismissible.dart
Created April 5, 2018 00:55
Adding support for dismissible jokes
_refreshAction() {
setState(() {
_response = http.read(dadJokeApi, headers: httpHeaders);
});
}
...
if (decoded['status'] == 200) {
_displayedJoke = decoded['joke'];
@timsneath
timsneath / shareFragment.dart
Last active April 6, 2018 15:57
Example of using the Flutter share package
import 'package:share/share.dart';
...
shareAction() {
if (displayedJoke != '') {
share(displayedJoke);
}
}
@timsneath
timsneath / pubspec.yaml
Last active April 6, 2018 15:57
Example of adding a dependency on a Flutter package
dependencies:
share: "^0.3.1"
@timsneath
timsneath / joke.cmd
Last active April 6, 2018 15:59
Using a Dart script from the command line
[C:\git\dart] dart joke.dart
Why did the burglar hang his mugshot on the wall? To prove that he was framed!
[C:\git\dart]
@timsneath
timsneath / joke.dart
Last active April 6, 2018 16:00
Basic example of an async HTTP GET call to a JSON web service
import 'package:http/http.dart' as http;
import 'dart:convert';
const dadJokeApi = "https://icanhazdadjoke.com/";
const httpHeaders = const {
'User-Agent': 'DadJokes (https://github.com/timsneath/dadjokes)',
'Accept': 'application/json',
};
main() async {
@timsneath
timsneath / buildWidget.dart
Created May 4, 2018 20:28
Simple example of a Widget build method without new keyword in Dart 2.
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: Text(widget.title),
actions: <Widget>[
IconButton(
icon: Icon(Icons.info),
onPressed: _aboutAction,
),
IconButton(
icon: Icon(Icons.share),
@timsneath
timsneath / scopedConst.dart
Created May 4, 2018 21:07
Example of scoped constant.
const comments = <Comment>[
Comment(
"Creating apps is just faster and more fun with Flutter.",
"Posse Inc."),
Comment(
"Yesterday I was trying #Flutter for the first time, today I published an application.",
"@CristianDudca"),
Comment(
"This weekend: Met and fell in love with Flutter.",
"@FIREYOSE"),
$ aqueduct document client
-- Aqueduct CLI Version: 3.0.0
-- Aqueduct project version: 3.0.0
*** Uncaught error
[Bad state: Invalid documenter 'HeroesController'. Reached end of controller chain and found no operations. Path has summary 'null'., #0 Controller.documentOperations (package:aqueduct/src/http/controller.dart:307:9)
#1 Controller.documentOperations (package:aqueduct/src/http/controller.dart:313:28)
#2 _RouteController.documentPaths.<anonymous closure> (package:aqueduct/src/http/router.dart:219:27)
#3 _ListBase&Object&ListMixin.fold (dart:collection/list.dart:218:22)
#4 _RouteController.documentPaths (package:aqueduct/src/http/router.dart:195:27)
#5 Router.documentPaths.<anonymous closure> (package:aqueduct/src/http/router.dart:145:24)
@timsneath
timsneath / keybase.md
Created March 19, 2019 22:45
Keybase Proof

Keybase proof

I hereby claim:

  • I am timsneath on github.
  • I am timsneath (https://keybase.io/timsneath) on keybase.
  • I have a public key ASBuO4qNQ37lc4xluDGHePGwLrbrh2z2Zj4trHu7OUugXgo

To claim this, I am signing this object:

import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Text Editing Demo',
home: SafeArea(