According to the Package layout conventions the web
folder should contain the following:
HTML, CSS, images, and, heck, probably even some JavaScript. All of that goes into your package’s web directory. You’re free to organize the contents of that to your heart’s content. Go crazy with subdirectories if that makes you happy.
So my web
directory looks something like this:
web/data_access
web/model
web/ui
web/ui/navigation
etc.
Now, how to I manage all those import statements. I get a lot of statements like:
import '../../model/my_model.dart';
import '../../data_access/mock_dao.dart';
etc.
I don't like using that many ../
in my imports because this is fragile and I get problems whenever I change anything in my folder structure.
Is there a better way to organize code inside the web
folder?
or
Is there another way to do the imports?
start from the domain layer and identify the model classes and business logic for manipulating them. create a folder for each model (or group of models) that belong together. within that folder, create the presentation , application , domain , data sub-folders as needed. inside each sub-folder, add all the files you ...
Using the path File-> New File creates a new dart file with name nextpage. dart inside the lib folder. Import the package 'package:flutter/material. dart'.
I put almost all of my app's code into lib, to avoid the issues you're seeing. This works even for web components.
See this components from widget.dart: https://github.com/kevmoo/widget.dart/tree/master/lib/components
I usually only put app.dart into web/, which simply pulls in libraries from lib and initializes the app.
See this example of an app that pulls in a pub package that has components: https://github.com/sethladd/catpic-app
This is what my HTML file looks like. Notice the inclusion of packages in the path:
<!DOCTYPE html>
<html>
<head>
<title>Your life is complete</title>
<link rel="components" href="packages/catpic/components/cat_pic.html">
<link rel="components" href="packages/frame/components/frame.html">
<link rel="stylesheet" href="styles.css">
</head>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With