Skip to content

Instantly share code, notes, and snippets.

View felixblaschke's full-sized avatar

Felix Blaschke felixblaschke

  • Schwerin, Germany
View GitHub Profile
import 'package:web_socket_channel/web_socket_channel.dart';
class SomeClass {
// Contains message history
final _messages = <String>[];
late final WebSocketChannel _channel;
void createConnection() {
// Connect to web socket
_channel = WebSocketChannel.connect(Uri.parse('ws://localhost:8080/ws'));
import 'dart:io';
import 'package:shelf_plus/shelf_plus.dart';
void main() => shelfRun(init);
Handler init() {
var app = Router().plus;
// Track connected clients
import 'dart:io';
import 'package:shelf_plus/shelf_plus.dart';
void main() => shelfRun(init); // runs server with hot-reload preconfigured
Handler init() {
var app = Router().plus;
app.get('/', () => 'Hello World!');
@felixblaschke
felixblaschke / my.md
Created October 13, 2021 19:20
my.md
class MyClass {
  ...

  String interestingMethod() {
    return 'Foo';
  }
}
@felixblaschke
felixblaschke / file.dart
Created October 13, 2021 19:18
file.dart
import 'dart:math';
// #begin
class MyClass {
// #skip
int someMethod() {
return Random().nextInt(1);
}
// #resume
[Unit]
Description=dartbackend
[Service]
User=root
Type=simple
ExecStart=/usr/bin/dart bin/dart_backend.dart
WorkingDirectory=/root/dart_backend
Restart=always
RestartSec=5s
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:alfred/alfred.dart';
void main() async {
var app = Alfred();
app.get('*', (req, res) => Directory('public'));
import 'dart:io';
import 'package:alfred/alfred.dart';
void main() async {
var app = Alfred();
app.get('*', (req, res) => Directory('public'));
await app.listen(8080);
}
@felixblaschke
felixblaschke / main.dart
Created March 5, 2021 22:18
Particle blendmode
import 'package:flutter/material.dart';
import 'package:simple_animations/simple_animations.dart';
/*
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
@felixblaschke
felixblaschke / riverpod5.dart
Last active February 14, 2021 09:00
riverpod5.dart
var name = StateProvider((_) => "Peter");
var age = StateProvider((_) => 32);
// Combines "name" and "age" to a String
var greeting = Provider<String>((scope) {
return "Hi! My name is ${scope.watch(name).state} and "
"I am ${scope.watch(age).state} years old.";
});
// Refines the "greeting" String to a Widget