Giter VIP home page Giter VIP logo

Comments (12)

andrzejchm avatar andrzejchm commented on August 16, 2024 1

reading yaml and json files require first reading them from assets and then parsing them, which make the operation asynchronous and prone to runtime errors instead of compilation errors: https://suragch.medium.com/reading-configuration-files-and-settings-in-flutter-and-dart-cc14bbd93698 . I think, if possible, we could leverage yaml files, but only if we find a code generator step that could be plugged into the build phase that would then generate a dart file with the config accordingly, so that it's both compile-time check and does not require any loading or parsing in the runtime

from flutter.

fadeev avatar fadeev commented on August 16, 2024

@Zfinix mind taking on this issue?

from flutter.

Zfinix avatar Zfinix commented on August 16, 2024

from flutter.

Zfinix avatar Zfinix commented on August 16, 2024

@Zfinix mind taking on this issue?

We would use a .env file

from flutter.

andrzejchm avatar andrzejchm commented on August 16, 2024

I'd be cautious with .env files, especially due to this rule: https://dart.dev/tools/linter-rules#do_not_use_environment.

If I can suggest, we could reuse https://github.com/tendermint/flutter/blob/70ab5ce585d39b80cc5ce839300f5064fc9e66cb/starport_template/lib/utils/base_env.dart file, make the structure more flat and get rid of environment reading there.

Benefits of having this in dart is that's going to be easier to make the code that uses it testable, the state of the app is more deterministic and easier to inspect while developing

from flutter.

fadeev avatar fadeev commented on August 16, 2024

Dart already uses YAML extensively as a config file format. I wonder if we could use that? Both Starport CLI and the Vue template are using declarative config files (YAML and JSON respectively).

from flutter.

Zfinix avatar Zfinix commented on August 16, 2024

I see no issue having it in base_env.dart we just need to document it so that its easy to update and find

I'd be cautious with .env files, especially due to this rule: https://dart.dev/tools/linter-rules#do_not_use_environment.

If I can suggest, we could reuse https://github.com/tendermint/flutter/blob/70ab5ce585d39b80cc5ce839300f5064fc9e66cb/starport_template/lib/utils/base_env.dart file, make the structure more flat and get rid of environment reading there.

Benefits of having this in dart is that's going to be easier to make the code that uses it testable, the state of the app is more deterministic and easier to inspect while developing

from flutter.

Zfinix avatar Zfinix commented on August 16, 2024

What do you suggest @wal33d006 ?

from flutter.

wal33d006 avatar wal33d006 commented on August 16, 2024

I think we should leverage things that do not take control away from us. So I think possibility of using yaml with code generator as suggested by Andrzej would be a good start along with using the dart environment file

from flutter.

Zfinix avatar Zfinix commented on August 16, 2024

@wal33d006 on thursday I and @andrzejchm agreed that we would not want to use a code generator as it brings in more complexity than needed, hence why we chose to repurpose the base_env dart file

from flutter.

wal33d006 avatar wal33d006 commented on August 16, 2024

Sounds good, then we can drop the generator part, use the base env file to keep things in dart.

from flutter.

andrzejchm avatar andrzejchm commented on August 16, 2024

@Zfinix we agreed that build_runner is not a good idea, if we could find a code generator that seamlessly generates dart file as part of the flutter build command, then it would be perfect solution, unfortunately I can't think of anything like that at the moment, so its more of a future-concept

from flutter.

Related Issues (20)

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.