Skip to content

Instantly share code, notes, and snippets.

View graphicbeacon's full-sized avatar
🏠
Working from home

Jermaine Oppong graphicbeacon

🏠
Working from home
View GitHub Profile
@graphicbeacon
graphicbeacon / main.dart
Created February 7, 2021 22:29
Convert map object to yaml in Dart
void main() {
final json = {
'name': 'package_name',
'version': '1.0.0',
'dependencies': {
'dep1': '^1.0.0',
'dep2': '^1.5.0',
'dep3': {
'git': 'https://github.com/graphicbeacon',
'home': {
@graphicbeacon
graphicbeacon / main.dart
Created November 27, 2020 15:41
Shelf_router server example with CORS enabled
import 'package:shelf_router/shelf_router.dart';
import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart' as io;
void start() async {
// Initiate server
const port = 8081;
final app = Router();
// CORS Settings
@graphicbeacon
graphicbeacon / index.html
Created September 7, 2020 17:25
Dispatching custom events example for Dart Web projects
<input type="text" />
@graphicbeacon
graphicbeacon / async-gen.dart
Created September 3, 2020 15:46
Async Generators example
import 'dart:async';
void main() {
// asynchronousNaturalsTo(10).listen(print);
final controller = asyncNaturalsTo(10);
controller.stream.listen((n) => print('YEss $n'),
onDone: () {
controller.close();
});
@graphicbeacon
graphicbeacon / main.dart
Last active June 26, 2020 09:00
Flutter Grid example with highlighted square
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
debugShowCheckedModeBanner: false, home: Scaffold(body: BoxApp())));
}
class BoxApp extends StatefulWidget {
@override
BoxAppState createState() => BoxAppState();
@graphicbeacon
graphicbeacon / index.html
Created June 20, 2020 22:07
Centering card with Materialize example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<!-- Compiled and minified JavaScript -->
@graphicbeacon
graphicbeacon / server.dart
Created May 25, 2020 09:20
Shelf Dart Tutorial solution code
import 'dart:io';
import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf/shelf_io.dart' as io;
// For Google Cloud Run, set _hostname to '0.0.0.0'.
const _hostname = 'localhost';
const _port = 8080;
void main(List<String> args) async {
@graphicbeacon
graphicbeacon / Dockerfile
Created May 17, 2020 18:06
Setup Dart with Docker
# ./Dockerfile
FROM google/dart-runtime
@graphicbeacon
graphicbeacon / main.dart
Last active March 22, 2020 17:02
Flutter slideout container with handle
import 'package:flutter/material.dart';
void main() => runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Page(),
),
),
);
@graphicbeacon
graphicbeacon / main.dart
Created March 21, 2020 21:03
Slideout container
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Page()
)
));
class Page extends StatefulWidget {