Skip to content

Instantly share code, notes, and snippets.

View rydmike's full-sized avatar

Rydmike rydmike

View GitHub Profile
@jogboms
jogboms / RegistryBenchMarks.md
Last active October 21, 2023 17:28
Registry benchmarks
class CustomTrianglePainter extends CustomPainter {
final Color color;
late Paint _paint;
CustomTrianglePainter(this.color) {
_paint = Paint()
..color = color
..style = PaintingStyle.fill;
}
@craiglabenz
craiglabenz / chat_message_render_box.dart
Last active July 21, 2024 10:57
Demonstrates a custom RenderObject that draws chat messages like WhatsApp, where the `sentAt` timestamp is tucked into the last line if it fits
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@rydmike
rydmike / main.dart
Last active September 13, 2022 23:10
Vikings 2022 Theme Talk - MaterialStateColor
// MIT License
//
// Copyright (c) 2022 Mike Rydstrom
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@slightfoot
slightfoot / smooth_scroll.dart
Created July 14, 2022 17:35
Correct smooth scroll for Flutter Web - by Simon Lightfoot - 14th July 2022
// MIT License
//
// Copyright (c) 2022 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@rydmike
rydmike / main.dart
Last active May 19, 2022 11:43
Flutter Nordic Roads to ThemeData talk
// MIT License
//
// Copyright (c) 2022 Mike Rydstrom
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@lukepighetti
lukepighetti / README.md
Last active December 6, 2022 10:43
sync_async_io

sync_async_io

This gist demonstrates jank observed during a large filesystem operation. There is a lint called avoid_slow_async_io that recommends people not use async io methods. These methods are definitely slower than the sync methods, but they provide concurrency which is critical to a Flutter application. We are exploring if the linter recommendation introduces jank in a flutter app or not.

Findings

If you use sync io methods that are of moderate to large size, it will freeze the ui.

If you use the linter recommendations, the result is nearly identical to using async methods as a default. I have seen some dropped frames on Simulator but it's barely noticable.

@rydmike
rydmike / platform_is.dart
Last active October 15, 2022 20:07
Flutter Universal Platform Check - That Works on Web too
import 'universal_platform_web.dart'
if (dart.library.io) 'universal_platform_vm.dart';
/// A universal platform checker.
///
/// Can be used to check active physical Flutter platform on all platforms.
///
/// To check what host platform the app is running on use:
///
/// * PlatformIs.android
@rydmike
rydmike / svg_asset_image.dart
Created March 27, 2021 12:06
Change the main color of the color used in Undraw SVG images.
import 'dart:async' show Future;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'package:flutter_svg/flutter_svg.dart';
/// Displays an SVG image provided in the applications asset bundle.
///
/// The [assetName] is the path and name of the SVG file in the asset bundle.
/// This SVG asset display widget is tuned for usage with the Undraw images
@rydmike
rydmike / analysis_options.yaml
Last active June 3, 2024 22:02
RydMike lints v2.2.0 - Personal preferences and starting point for Dart & Flutter linter rules setup.
# RydMike LINTER Preferences v2.2.0
#
# Get this file here: https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
#
# We include and activate all lint rules, later below we disable the not used or desired ones.
# You can find a list of all lint rules to put in your all_lint_rules.yaml file here:
# https://dart.dev/tools/linter-rules/all
#
# For a comparison of all lint rules settings in rule styles listed below, please see this Google
# sheet: https://docs.google.com/spreadsheets/d/1Nc1gFjmCOMubWZD7f2E4fLhWN7LYaOE__tsA7bf2NjA