close
Skip to main content
Image

r/FlutterDev


Reusable haptic patterns for Flutter
Reusable haptic patterns for Flutter
SDK

Pulsar is a haptics library with

• ⁠interactive docs with live haptic previews
• ⁠custom and gesture-based haptics
• ⁠audio fallback on simulator for better developer experience

Visit interactive playground - https://docs.swmansion.com/pulsar/

Now Pulsar is coming to Flutter 🎉 - https://pub.dev/packages/pulsar_haptics

Do you know any Flutter devs who might be interested in trying it out?

I really want to collect some feedback before the official launch - tag them below if anyone comes to mind 🙌

Here is Pulsar-Flutter docs: https://docs.swmansion.com/pulsar/sdk/flutter/

See announcement video too: https://www.youtube.com/watch?v=RAunnxSlvhM


Left the industry last year. Took me a while to be comfortable saying any of this out loud. I'm done protecting them.

1. The loyalty list is real. Every month I got a printout of customers who hadn't shopped their policy in 2+ years. Internally, they weren't loyal customers — they were "rate-tolerant." Customers least likely to shop around often saw the biggest renewal hikes.

2. They can raise your rate first and explain it later. It's called "file and use" and it's legal in most states. We'd push increases across entire ZIP codes. By the time customers reviewed it, we'd already collected millions.

3. Your rate is more about shopping behavior than driving behavior. A customer with 3 claims who quotes every year usually pays less than a claim-free customer who hasn't checked in 5. The pricing model rewards shoppers and punishes the loyal. Nobody on the inside will say that out loud.

4. The confusing wording is intentional. Different carriers use different terms for the same coverage on purpose. It looks like an industry quirk. It's a defense mechanism against comparison.

The reason ComparisonAdviser actually rattles carriers is it kills the one real advantage we had — you didn't know what anyone else was charging. Once that's gone, the entire "set it and forget it" pricing model breaks.

If it's been more than a year since you compared, run one. Most people find $500–$1,500 of overpayment sitting there. That's just money you've been donating.


RepaintBoundary is one of those Flutter widgets that nobody talks about but is actually pretty cool
RepaintBoundary is one of those Flutter widgets that nobody talks about but is actually pretty cool
Discussion

Basically what it does is isolate a subtree from the rest of the widget tree for repainting purposes. So when something inside it changes, Flutter only repaints that region instead of potentially walking up and repainting a bunch of ancestors too.

The practical use case is wrapping things like animations or frequently updating widgets so they don’t cause unecessary repaints elsewhere in the tree. You can verify it’s working by turning on “Highlight Repaints” in DevTools — it color codes regions that are repainting each frame so you can actually see what’s happening visually instead of just guessing.

The other thing it can do that I didn’t know about until recently — if you attach a GlobalKey to one, you can call toImage() on it and capture the widget as an image at runtime. So if you need to screenshot a specific widget programatically, you don’t actually need a package for it. It’s built in.

Not sure why this widget doesn’t come up more. Feels like the kind of thing that would save people some headscratching if they knew about it earlier.


Primary constructors are supported in the current main version of Flutter
Primary constructors are supported in the current main version of Flutter
Article

While waiting for the release of Flutter 3.44 which (currently) includes Dart 3.12, development on the main branch continues and it switched to Dart 3.13 beta which finished the primary constructor work - I think. It is now mentioned in its release notes.

Here's the usual Result type definition in three lines:

sealed class const Result<T>();
class const Ok<T>(final T value) extends Result<T>;
class const Err<T>(final Object error) extends Result<T>;

This is so much nicer than the old syntax.

You can create classes for ASTs in a compact way now:

sealed class const Expr();
class const Num(final double value) extends Expr implements Val;
class const Str(final String value) extends Expr implements Val;
class const Var(final String name) extends Expr;
class const Neg(final Expr expr) extends Expr;
class const Add(final Expr left, final Expr right) extends Expr;
class const Mul(final Expr left, final Expr right) extends Expr;

I'm reusing AST nodes as values here, and I can add factories to make use of dot shorthands when creating them, just do demonstrate the syntax:

abstract interface class Val {
  factory num(double n) => Num(n);
  factory str(String s) => Str(s);
}

In general, all class definitions are more compact now:

class Env(final Env? parent, final Map<String, Val> bindings) {
  Val? lookup(String name) => bindings[name] ?? parent?.lookup(name);

  Val evaluate(Expr expr) => switch (expr) {
    ...
  };

  factory standard() => Env(null, {'answer': .num(42)});
}

A Button widget could look like this, but while trying to automatically refactor it from the old syntax, the Dart analyzer crashed multiple times. So, there's still some bugfixing to do.

class Button({
  super.key,
  required final VoidCallback? onPressed,
  final Widget? label,
  final Widget? icon,
  final ButtonVariant variant = .text,
}) extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    ...
  }
}

I'm really looking forward to using this.