4min chapter

Flying High with Flutter cover image

MVVM - Flying High with Flutter #79

Flying High with Flutter

CHAPTER

How to Extend a Stateful Widget Into MVVM Workhorse

Stateful widget has everything I need for MVVM. The only problem with stateful widget from an MVVM standpoint is that it puts the UI in the states in the state class. So if you take the build function from the stateful widget state class and just move that into the stateful widgets portion, then you effectively have MVVM. And your state class would now have just your states and your business logic. Your stateful widget class would have your immutable states and your immutable build function. With 60 lines of code, I extended stateful widget into a view class. That's a generic class that that has a view model builder. It got something like 31 upvotes on flutter

00:00

Get the Snipd
podcast app

Unlock the knowledge in podcasts with the podcast player of the future.
App store bannerPlay store banner

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode

Save any
moment

Hear something you like? Tap your headphones to save it with AI-generated key takeaways

Share
& Export

Send highlights to Twitter, WhatsApp or export them to Notion, Readwise & more

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode