Skip to content

Instantly share code, notes, and snippets.

Seth Ladd sethladd

View GitHub Profile
@sethladd
sethladd / flutter_localized_title.dart
Last active Jul 2, 2020
Flutter example of a localized title
View flutter_localized_title.dart
// Copyright 2017 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.
// Note: I'm not the original author, I'm sharing via Gist to make
// it easy for folks to check it out. Please email
// flutter-dev@googlegroups.com if you have questions about that.
// A simple "rough and ready" example of localizing a Flutter app.
// Spanish and English (locale language codes 'en' and 'es') are
@sethladd
sethladd / more_simple_multiple_http_server_handler.dart
Last active Jan 2, 2020
Registering multiple HTTP handlers for a Dart web server. Not sure if this is the best way or not.
View more_simple_multiple_http_server_handler.dart
HttpServer.bind('127.0.0.1', 8889)
.then((HttpServer server) {
var sc = new StreamController();
sc.stream.transform(new WebSocketTransformer()).listen(handleWebSocket);
server.listen((HttpRequest request) {
if (request.uri.path == '/ws') {
sc.add(request);
} else if (request.uri.path == '/foo') {
request.response.addString('foo');
@sethladd
sethladd / streams_and_event_loop.dart
Created Feb 8, 2013
Streams, stream controller, and event loops in Dart.
View streams_and_event_loop.dart
import 'dart:async';
import 'dart:math';
/*
* Findings:
* streams can be single or broadcast, but not sure why the diff.
* can check if a stream is broadcast with isBroadcast
* StreamController make it easy to use a stream and send it events
*/
@sethladd
sethladd / app.dart
Created Feb 12, 2014
Example of lazy loading with Dart.
View app.dart
import 'dart:async';
@lazy
import 'big_lib.dart' as big show soManyFunctions;
const lazy = const DeferredLibrary('big', uri: 'big.js');
void main() {
lazy.load().then((_) {
big.soManyFunctions();
View chrome web store license respone.json
{
"kind": "chromewebstore#license",
"id": "ejbknjbccnnccddiljheadjafeeagcan/https://www.google.com/accounts/o8/id?id\u003dAItOawlh_ZYIBQi-kNV-d3Rd8WIjQEBsLDh5LDQ",
"appId": "ejbknjbccnnccddiljheadjafeeagcan",
"userId": "https://www.google.com/accounts/o8/id?id\u003dAItOawlh_ZYIBQi-kNV-d3Rd8WIjQEBsLDh5LDQ",
"result": "YES",
"accessLevel": "FREE_TRIAL"
}
View original.dart
return new SingleChildScrollView(
child: new Container(
margin: const EdgeInsets.all(16.0),
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new Expanded(child: new LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints){
@sethladd
sethladd / Original.dart
Last active Jun 3, 2017 — forked from asarazan/Original.dart
Comparing Flutter to what it might look like in Kotlin, Dart.soon, and Dart.wishlist
View Original.dart
class TutorialHome extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Scafold is a layout for the major material design widgets.
return new Scaffold(
appBar: new AppBar(
leading: new IconButton(
icon: new Icon(Icons.menu),
tooltip: 'Navigation menu',
onPressed: null,
View dartdoc_flexbox.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="widgets library API docs, for the Dart programming language.">
<title>widgets library - Dart API</title>
<!-- required because all the links are pseudo-absolute -->
View doc_layout.html
<!doctype html>
<html>
<head>
<style>
html,
body {
margin: 0;
padding: 0;
height: 100%;
@sethladd
sethladd / index.html
Last active May 22, 2017
layout with flexbox
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<link href="styles.css" rel="stylesheet">
</head>
<body>
<header>Top Nav</header>
<div class="layout-body">
You can’t perform that action at this time.