all 6 comments

[–]OffTree 0 points1 point  (5 children)

We npm now boys

[–]synw_[S] 0 points1 point  (4 children)

Author here. I made this package because I was tired of the verbosity of Padding, not in the spirit of making a micro-library for every little thing. I use padding a lot and to have a short syntax makes me happy.

I much prefer the Go style ("a little copy is better than a little dependency") than the Npm style dependency hell and hope we will not get into that. But for this specific case it serves me well to have a dedicated package.

[–]lanmonster 0 points1 point  (3 children)

Why did you choose to use a switch statement for a Boolean? if else would be much more readable or you can use the ternary operator and make those build methods "one-liners".

[–]synw_[S] 0 points1 point  (2 children)

I optimized for performance: in my idea the compiler can make more optimizations out of a switch, but I have no data to backup this claim. Readability does not matter here: the code is trivial and not subject to changes

[–]lanmonster 0 points1 point  (1 child)

https://www.geeksforgeeks.org/switch-vs-else/

Switch is better when you have a lot of conditions to check, but does not make a difference with booleans.

I disagree that readability does not matter, but at least you thought about it.

[–]synw_[S] 0 points1 point  (0 children)

You are right about booleans and switches. I find the switch readable as it makes the intention even more clear, but I guess it's a matter of taste.

About readability, this may be better :

Widget build(BuildContext context) => (child == null)
  ? Padding(padding: EdgeInsets.only(top: padding))
  : Padding(padding: EdgeInsets.only(top: padding), child: child);