News for hackers. Stuff that matters.

Ask HN: Why No Functional Components in Flutter?

Flutter with it's pseudo-declarative approach is inspired by React (https://flutter.dev/docs/resources/architectural-overview#reactive-user-interfaces)

Why then it's still few years behind React with its verbose class based approach?

Functions are first class citizens in Dart, so what's stopping Flutter team to improve in this direction?

Would like to hear some technical aspects and implications of this matter.

( 5 comments | on HN )
Re:Ask HN: Why No Functional Components in Flutter? by pax_americana on Wednesday June 09, 2021 @12:41PM (#27450035)
Here's a pretty good explanation.

https://stackoverflow.com/a/53234826

There is a library that would allow you to declare functional components, however it relies on code generation which might discourage others from using it. Dart is planning on adding static metaprogramming though, and that might provide a way to introduce functional components to Flutter without codegen.

Re:Ask HN: Why No Functional Components in Flutter? by aristofun on Wednesday June 09, 2021 @03:10PM (#27451823)
thanks for sharing
Re:Ask HN: Why No Functional Components in Flutter? by PaulHoule on Wednesday June 09, 2021 @10:14AM (#27448091)
Functional components in React are fine. (A pure component that just maps props to a DOM tree)

The hooks however are cancer; React going forward with those is like trying to go forward in reverse gear. Replace a straightforward OO API with something "functional" where the result depends on the sequence the functions get called in...

Side effect city.

Re:Ask HN: Why No Functional Components in Flutter? by aristofun on Wednesday June 09, 2021 @10:42AM (#27448440)
How much experience did you have with hooks based react projects?

In my experience this is a blessing, once you deeply understand the basic ideas.

By just comparing class vs hooks based react apps I worked with.

Re:Ask HN: Why No Functional Components in Flutter? by aristofun on Wednesday June 09, 2021 @10:50AM (#27448552)