Skip to content

Instantly share code, notes, and snippets.

View moritzmorgenroth's full-sized avatar

Moritz Morgenroth moritzmorgenroth

View GitHub Profile
import 'package:flutter/material.dart';
class PaletteSample extends StatelessWidget {
@override
Widget build(BuildContext context) {
MaterialColor primarySwatch = generateMaterialColor(Palette.primary);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Container(
import 'dart:math';
import 'package:flutter/material.dart';
MaterialColor generateMaterialColor(Color color) {
return MaterialColor(color.value, {
50: tintColor(color, 0.5),
100: tintColor(color, 0.4),
200: tintColor(color, 0.3),
300: tintColor(color, 0.2),
400: tintColor(color, 0.1),
@moritzmorgenroth
moritzmorgenroth / async_validation_form.dart
Last active August 13, 2021 01:57
Flutter example for async form validation
class UsernameForm extends StatefulWidget {
final Function onSuccess;
UsernameForm(this.onSuccess);
@override
_UsernameFormState createState() => _UsernameFormState(onSuccess);
}
class _UsernameFormState extends State<UsernameForm> {
@moritzmorgenroth
moritzmorgenroth / seed.ts
Last active May 6, 2022 08:22
Prisma seeding script
import { Prisma } from './../generated/prisma';
import { readFileSync } from 'fs';
// add to yarn:
// "seed": "dotenv -e .env -- ts-node ./src/seed/seed.ts"
const prisma = new Prisma({
endpoint: process.env.PRISMA_ENDPOINT, // the endpoint of the Prisma DB service (value is set in .env)
secret: process.env.PRISMA_SECRET, // taken from database/prisma.yml (value is set in .env)
debug: false // log all GraphQL queries & mutations
watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache