Giter VIP home page Giter VIP logo

flutter_starter's Introduction

My Flutter Project Structure

a project structure for a flutter app that use riverpod for state-management, auto-route for navigation and dio for api request this structure is suitable for api based project , if we have also a local db create a folder for database and i prefer to use drift as it provide a good type-safety & auto-completion

Getting Started

all the code is writted inside /lib/src we have /localization for a 'arb' file and /gen for a assest and font auto generate files

inside src we have

  • main : any things that belongs to the complete app like route , material app and other
  • shared: shared across the app
  • screen: described below
  • model folder: json model for the data
  • dto folder: data transfer object for communacite with the api or other place (this a object used for sent/receive data not a real model)
  • service: service for working with a plugin like image_picker or onesignal
  • api: api client connection and also any api service

each service/api class must has a provider define in top of it

presentation

in the folder we represent every screen or feature from the app we have as a folder each folder could have 4 part (state,controller,page,widget) and we may also have other file if needed any other code that is only related to this screen should be putted here too

  • our state should be define using freezed package as a union type or single type

  • our controller may be StateNotifier/StorageNotifier or any other class with a riverpod provider see setting_controller for example

Assets

The assets directory houses images, fonts, and any other files you want to include with your application.

we use flutter_gen to generate a static strong type interface for our assets and fonts

Assets.images.flutterLogo.image()

Localization

This project generates localized messages based on arb files found in the lib/localization directory. read this article to learn more about this https://lokalise.com/blog/flutter-i18n/

Hydrated

we use StorageNotifier/StorageNotifierMixin to save any state data that we need it to be saved when the app closed like language and theme mode , see setting_controller for more info. the code is writted inside /src/service/storage_service we implements hive and secure-storage , you could use any other package if you need

routing

we use auto_route as it provide a strong type generator route and help parsing the argument too see home_page, main/route.dart for example of using it

ScriptRunner

we use script_runner for mange our script

so insted of writeing

flutter packages pub run build_runner build --delete-conflicting-outputs

we write

scr buildd

see script_runner.yaml and https://pub.dev/packages/script_runner for more info

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.