Skip to content

Instantly share code, notes, and snippets.

@mjohnsullivan
mjohnsullivan / book_list.dart
Last active December 1, 2023 21:53
A simple book list Flutter example using the Google Books API
/*
Copyright 2018 The Chromium Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
@mjohnsullivan
mjohnsullivan / rows_columns.dart
Created July 13, 2018 17:17
Using rows and columns to create an asymmetric grid-like layout
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
@mjohnsullivan
mjohnsullivan / scroll_detection.dart
Created July 11, 2018 17:13
Detect when a scrollable widget starts or stops scrolling
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
@mjohnsullivan
mjohnsullivan / incrementer_snackbar.dart
Created July 3, 2018 00:29
The classic Flutter incrementer app with added SnackBar
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Snackbars',
theme: ThemeData(
@mjohnsullivan
mjohnsullivan / quote.dart
Created June 25, 2018 23:20
Simple Flutter app to retrieve and display a quote of the day
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
@mjohnsullivan
mjohnsullivan / particles.dart
Last active September 13, 2023 04:52
Demonstrates drawing and animating simple shapes in Flutter
// Adapted from https://github.com/nhancv/nc_flutter_util
import 'dart:math';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/animation.dart';
import 'package:flutter/material.dart';
main() {
runApp(new MaterialApp(
@mjohnsullivan
mjohnsullivan / expanding_app_bar.dart
Last active August 27, 2021 16:53
Expanding AppBar in Flutter
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Expanding AppBar Example',
theme: new ThemeData(
@mjohnsullivan
mjohnsullivan / downloader.dart
Last active December 5, 2017 04:31
Simple HTTP downloader script in Dart
// Copyright 2017 Matt Sullivan
// Governed by the 2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:args/args.dart';
void main(List<String> args) {
var parsedArgs = parseArgs(args);
@mjohnsullivan
mjohnsullivan / generate_cloudfront_signed_cookies.py
Created January 1, 2017 16:34
Python script that generates signed cookies to control access to CloudFront content
#!/usr/bin/env python
"""
Copyright (C) 2017 Matt Sullivan
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@mjohnsullivan
mjohnsullivan / parse_json.go
Created December 14, 2015 23:17
Parse JSON objects with arbitrary key names in Go using interfaces and type assertions
// Parsing arbitrary JSON using interfaces in Go
// Demonstrates how to parse JSON with abritrary key names
// See https://blog.golang.org/json-and-go for more info on generic JSON parsing
package main
import (
"encoding/json"
"fmt"
)