Skip to content

Instantly share code, notes, and snippets.

View artificerchris's full-sized avatar

Chris Hendrickson artificerchris

View GitHub Profile
@artificerchris
artificerchris / fp.dart
Created October 25, 2022 12:27
FP Question
import 'dart:convert';
/// Mock [Response] implementation
class Response {
final String body;
Response(this.body);
}
/// Mock for `post` API request
Response post(
@artificerchris
artificerchris / main.dart
Last active July 1, 2022 23:46
dart:ui with no Flutter
import 'dart:ui';
final paint = Paint()
..color = const Color(0xFFFFFFFF)
..style = PaintingStyle.stroke;
void main() {
window.onBeginFrame = beginFrame;
window.scheduleFrame();
}
@artificerchris
artificerchris / text_field_list_view.dart
Last active October 31, 2021 04:10
Example of using a text field inside a stateful widget
import 'package:flutter/material.dart';
void main() {
final inputList = List.generate(
100,
(index) => InputModel(index, 'Initial Value ${index}'),
);
runApp(MyApp(inputModels: inputList));
}
@artificerchris
artificerchris / gist-index.md
Last active July 2, 2021 16:37
Artificer's Gist Index

Artificer's Gist Index

Dart & Flutter

  • Hero Widget Demo w/ AnimatedTextStyle
  • Extension for num to support Range mapping
  • Flutter ListView w/ Variable Height Children
@artificerchris
artificerchris / list_view_example.dart
Last active November 17, 2021 16:42
Example of Flutter ListView with a list of variable height children.
import 'dart:math' as math;
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@artificerchris
artificerchris / dart_number_range_map_extension.dart
Last active November 17, 2021 16:41
Simple Extension on Dart's `num` type to allow you to map it from one range to another.
extension NumX on num {
/// Maps [this] from the range [inputLow] to [inputHight] on the range
/// [outputLow] tp [outputHigh]. This function is reversable by swapping the
/// input and output ranges.
///
/// For Example:
/// ```dart
/// assert(0.5.map(0, 1, 0, 10) == 5);
/// assert(5.map(0, 10, 0, 1) == 0.5);
/// assert(4327.map(0, 8003, 0, 1) == 0.5406722479070348);
@artificerchris
artificerchris / rainbow_hero_text.dart
Last active November 17, 2021 16:40
Hero Widget Demo w/ Animated TextStyle during transition.
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(HeroExampleApp());
}
class HeroExampleApp extends StatelessWidget {
@override
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,