You can use extract method instead of extract widget. Flutter will add everything as it is, and instead of a class you will get a reusable function.