What are some good best practices to structure project folders for midsize projects.
In the apprentice book networking for example has a separate folder with corresponding models within it. Does it make sense to group models, nav, networking seperatly; group by screens? Are there any general recommendations?
It’s really up to each developer. That said, I recommend using separate folders for your projects, regardless of size. This helps if your app grows, but also helps you keep things organized.
Here’s an example from an app I’m currently working on with Simon Lightfoot.
The feature sub-folders are for each screen. You’ll also notice that the assets folder is also separated into different folders.
You might wonder why there is an app_icon.png at the root level instead of inside the iOS and Android folders. It is in those respective folders. This file is used for the main menu which is built various using widgets.
One thing to note, see on the math.dartimport statement where there is as math and show pi?
import 'dart:math' as math show pi;
First, the show pi instructs Dart to only expose pi. There is no reason to expose all the other constants and functions because you’re not going to use them.
The as math let’s you reference the objects within dart:math by using math., as shown in the usage of pi: