# Best practices for folder structure

**URL:** <https://forums.kodeco.com/t/best-practices-for-folder-structure/153299>\
**Category:** Flutter Apprentice\
**Created:** [October 15, 2021, 2:27pm UTC](https://forums.kodeco.com/t/best-practices-for-folder-structure/153299 "2021-10-15T14:27:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarav1n](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/sarav1n/32/81494_2.png) [@sarav1n](https://forums.kodeco.com/u/sarav1n)\
**Post date:** [October 15, 2021, 2:27pm UTC](https://forums.kodeco.com/t/best-practices-for-folder-structure/153299/1 "2021-10-15T14:27:20Z")

</div>

Hi Folks,

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?

Thanks

---

<div class="post-metadata">

**Author:** ![jefff9511](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jefff9511/32/102075_2.png) [@jefff9511](https://forums.kodeco.com/u/jefff9511)\
**Post date:** [October 15, 2021, 4:22pm UTC](https://forums.kodeco.com/t/best-practices-for-folder-structure/153299/2 "2021-10-15T16:22:47Z")

</div>

I’ve been wondering that also … but for smaller projects.

---

<div class="post-metadata">

**Author:** ![spgms](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/spgms/32/111854_2.png) [@spgms](https://forums.kodeco.com/u/spgms)\
**Post date:** [October 15, 2021, 9:26pm UTC](https://forums.kodeco.com/t/best-practices-for-folder-structure/153299/3 "2021-10-15T21:26:42Z")

</div>

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.  
 ![Screen Shot 2021-10-15 at 13.59.17](https://files.chunter.kodeco.com/original/3X/9/e/9e257b1aa288c2664614ca7030d6206b2304cf07.png)

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.

Hope this helps,  
Stef

---

<div class="post-metadata">

**Author:** ![sarav1n](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/sarav1n/32/81494_2.png) [@sarav1n](https://forums.kodeco.com/u/sarav1n)\
**Post date:** [October 16, 2021, 3:52am UTC](https://forums.kodeco.com/t/best-practices-for-folder-structure/153299/4 "2021-10-16T03:52:44Z")

</div>

Thanks Stef! This actually helps a lot.

How do you typically handle route/navigation files?

---

<div class="post-metadata">

**Author:** ![jefff9511](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jefff9511/32/102075_2.png) [@jefff9511](https://forums.kodeco.com/u/jefff9511)\
**Post date:** [October 16, 2021, 10:45am UTC](https://forums.kodeco.com/t/best-practices-for-folder-structure/153299/5 "2021-10-16T10:45:41Z")

</div>

@spgms … What types of things are in the `resources.dart` and the `info` and `utils `folders? Where are the constants placed?

---

<div class="post-metadata">

**Author:** ![spgms](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/spgms/32/111854_2.png) [@spgms](https://forums.kodeco.com/u/spgms)\
**Post date:** [October 18, 2021, 12:14am UTC](https://forums.kodeco.com/t/best-practices-for-folder-structure/153299/6 "2021-10-18T00:14:13Z")

</div>

Hi @jefff9511. Here are the details about each of the things you asked about.

- **resources.dart** is where game resources are defined:

```auto
class GameResources {
  const GameResources._();

  // Effects

  // Fonts

  // Images

  // Music
  static const musicTrashyAliens = 'assets/music/trashy_aliens.mp3';
}

```

- The **info** folder pertains details displayed on my `info` screen (I’m using “info” instead of “about”).

- The **utils** folder currently holds **common.dart** and **math.dart** which each contain `const` definitions that are used in multiple places:

**common.dart**

```auto
import 'package:flutter/material.dart';

const verticalPadding4 = EdgeInsets.symmetric(vertical: 4.0);
const verticalPadding8 = EdgeInsets.symmetric(vertical: 8.0);
const verticalPadding12 = EdgeInsets.symmetric(vertical: 12.0);
const verticalPadding16 = EdgeInsets.symmetric(vertical: 16.0);
const verticalPadding24 = EdgeInsets.symmetric(vertical: 24.0);
const verticalPadding32 = EdgeInsets.symmetric(vertical: 32.0);

const horizontalPadding4 = EdgeInsets.symmetric(horizontal: 4.0);
const horizontalPadding8 = EdgeInsets.symmetric(horizontal: 8.0);
const horizontalPadding12 = EdgeInsets.symmetric(horizontal: 12.0);
const horizontalPadding16 = EdgeInsets.symmetric(horizontal: 16.0);
const horizontalPadding24 = EdgeInsets.symmetric(horizontal: 24.0);
const horizontalPadding32 = EdgeInsets.symmetric(horizontal: 32.0);

const allPadding4 = EdgeInsets.all(4.0);
const allPadding8 = EdgeInsets.all(8.0);
const allPadding12 = EdgeInsets.all(12.0);
const allPadding16 = EdgeInsets.all(16.0);
const allPadding24 = EdgeInsets.all(16.0);
const allPadding32 = EdgeInsets.all(32.0);

```

**math.dart**

```auto
import 'dart:math' as math show pi;

double degrees2radians(double degrees) {
  return degrees * (math.pi / 180.0);
}

```

I hope this helps.

Stef

---

<div class="post-metadata">

**Author:** ![spgms](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/spgms/32/111854_2.png) [@spgms](https://forums.kodeco.com/u/spgms)\
**Post date:** [October 18, 2021, 12:16am UTC](https://forums.kodeco.com/t/best-practices-for-folder-structure/153299/7 "2021-10-18T00:16:46Z")

</div>

@sarav1n route/navigation is currently setup in the **main\_menu.dart** file.

---

<div class="post-metadata">

**Author:** ![jefff9511](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jefff9511/32/102075_2.png) [@jefff9511](https://forums.kodeco.com/u/jefff9511)\
**Post date:** [October 18, 2021, 10:57am UTC](https://forums.kodeco.com/t/best-practices-for-folder-structure/153299/8 "2021-10-18T10:57:14Z")

</div>

@spgms … it REALLY helped to see what you did with the constants. THANKS!!

---

<div class="post-metadata">

**Author:** ![spgms](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/spgms/32/111854_2.png) [@spgms](https://forums.kodeco.com/u/spgms)\
**Post date:** [October 18, 2021, 4:12pm UTC](https://forums.kodeco.com/t/best-practices-for-folder-structure/153299/9 "2021-10-18T16:12:56Z")

</div>

@jefff9511 I’m glad I was able to help.

One thing to note, see on the **math.dart** `import` statement where there is `as math` and `show pi`?

> ```auto
> 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`:

> `return degrees * (math.pi / 180.0);`
