Skip to content

Instantly share code, notes, and snippets.

View felangel's full-sized avatar
coding

Felix Angelov felangel

coding
View GitHub Profile
@felangel
felangel / _middleware.dart
Last active December 16, 2022 17:44
Dart Frog Catch All Middleware
import 'package:dart_frog/dart_frog.dart';
Handler middleware(Handler handler) {
return Cascade().add(handler).add(catchAll).handler;
}
Response catchAll(RequestContext context) => Response(body: 'Catch All');
@felangel
felangel / main.dart
Last active December 16, 2022 17:40
Dart Frog Catch All Handler Custom Entrypoint
import 'dart:io';
import 'package:dart_frog/dart_frog.dart';
Future<HttpServer> run(Handler handler, InternetAddress ip, int port) {
final cascade = Cascade().add(handler).add(catchAll);
return serve(cascade.handler, ip, port);
}
Response catchAll(RequestContext context) => Response(body: 'Catch All');
@felangel
felangel / main.dart
Created December 14, 2022 16:00
Dart Frog Trackable Static Files
import 'dart:io';
import 'package:dart_frog/dart_frog.dart';
Future<HttpServer> run(Handler handler, InternetAddress ip, int port) {
final cascade = Cascade().add(trackableStaticFileHandler).add(handler);
return serve(cascade.handler, ip, port);
}
Future<Response> trackableStaticFileHandler(RequestContext context) async {
@felangel
felangel / starship.toml
Created January 20, 2022 23:05
Starship Config 🚀🌟
format = "$all"
add_newline = true
[character]
success_symbol="[\\$](bold bright-red)"
error_symbol = "[✖](bold bright-red)"
[battery]
full_symbol = "🔋"
@felangel
felangel / main.dart
Last active May 9, 2024 13:42
Flutter Bloc Counter Example
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
void main() => runApp(App());
abstract class CounterEvent {}
class Increment extends CounterEvent {}
class CounterBloc extends Bloc<CounterEvent, int> {
@felangel
felangel / main.dart
Created October 6, 2021 15:54
[flutter_bloc_recipes] Navigation: Navigator 2.0
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:flow_builder/flow_builder.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class Book extends Equatable {
const Book(this.title, this.author);
final String title;
@felangel
felangel / main.dart
Last active June 19, 2020 00:05
StatefulRebuilder
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
@felangel
felangel / main.dart
Created June 18, 2020 23:17
StatefulWidget demo
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
@felangel
felangel / main.dart
Last active June 18, 2020 23:13
StatefulBuilder Demo
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
@felangel
felangel / main.dart
Created February 28, 2020 18:31
Recipe: Bloc Access (Generated Routes)
import 'package:flutter/material.dart';
import 'package:bloc/bloc.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class SimpleBlocDelegate extends BlocDelegate {
@override
void onEvent(Bloc bloc, Object event) {
super.onEvent(bloc, event);
print(event);
}