Directory Structure
## Introduction
Keeping projects organized can be difficult when there are a lot of moving parts.
Nylo tries to solve this with a simple project structure.
App Directories
All the app directories are listed inside the lib directory where your main.dart file runs.
-
appthis folder includes any files relating to models, controllers and networking.-
controllersInclude your controllers here for your Widget pages. -
modelsCreate your model classes here. -
networkingAdd any networking classes here for managing APIs or fetching data from the internet.
-
-
configthis folder includes configuration files like for the theme or anything else you need. -
resourcesthis folder includes any files that are key components for your users UI experience like pages, widgets and themes.-
pagesInclude your Widgets here that you will use as Page's in your project. E.g. home_page.dart. -
themesBy default we include two themes here but you can add more if your project needs to support more. -
widgetsAny widgets you need to create can be inserted here like a date_picker_widget.dart file.
-
-
routesthis folder includes any files relating to models, controllers and networking.- router.dart contains the router for your application.
Public assets
All public assets can be found in public/assets. This directory is commonly used for images, fonts and more files that you may want to include in your project.
It's important to add any new files into the
pubspec.yamlfile too.
-
app_iconThis is used for generating app_icons for the project. -
imagesInclude any images here in this directory. -
fontsAdd any custom fonts here.
Retrieving an image asset
To get a image asset you can use getImageAsset(String key)
Image.asset(
getImageAsset("nylo_logo.png"),
height: 50,
width: 50,
),
In this example, our public/assets/images/ directory has one file nylo_logo.png.
- public/assets/images/nylo_logo.png
Retrieving a public asset
You can get any public asset using getPublicAsset(String key)
_controller = VideoPlayerController.asset(
getPublicAsset('videos/intro.mp4'))
..initialize().then((_) {
setState(() {});
});
In this example, our public/assets/videos/ directory has one file intro.mp4.
- public/assets/images/intro.mp4