How to organize dart files inside packages in flutter - flutter

I'm new at programming using flutter and I'd like to develop a small project containing a few screens: Login, Home, Settings, User, PurchaseHistory, etc.
I need to organize the code inside packages so that it can readable easily.
If I develop an Android App, I'd create some packages: model, activity, fragment, util, etc. If I create a LoginActivty, I'd put it inside activity package. If I create a User model, I'd put it inside model package. And so on.
So If I develop a flutter project, where am I supposed to put all of the files I create so far?
For now I've created only model package.

First of all, in Flutter we don't deal with activities or fragments directly, that is a naming convention from Android itself.
There are many options to architect your app and organize your folders. I wouldn't say that there is a holy grail solution. So you have to try some of them and see the best fit for you.
At the end of this article, I show an option to a folder structure when working with flavors, like this:
But there are plenty of others, so I recommend you to see how some of the GitHub projects are organized, a good way to start is having a look at the projects from this repository. Especially the 'Open Source Apps' section.

I'm currently working on a project that follows an approach like you described.
I don't know if it's the better structure, but it works really nice for me.
\lib
\-model
\-api
\-bloc
\-widgets (commom components)
\-exceptions
\-config (config classes/files like routes, theme, specific settings for each environment - dev, production, test)
\-views
\-login
\-home
\-user_profile
\-...
\-main.dart
----- EDITED -----
After work for almost a year with Flutter, I've tested some different structures, and there's one in particular that's really nice and provides an amazing organization...
Take a look at slidy, the following image represents the kind of organization it provides. More details in the package description.

Related

Customize initial project template for Flutter

I am trying to customize the starter template for a Flutter app. For projects that I work on I follow a very specific structure with my Themes, Blocs, Listeners, etc. I would love it if I could customize the starter template for Flutter so that I have everything all laid out and ready to use on doing something like flutter create .
I am aware of where the template is located. I was able to go to [flutter_dir]/packages/flutter_tools/templates/app/lib/main.dart.tmpl and customize the template.
But I am not able to figure out how I can add a new file/directory there. Let's say if I create a new file called config.dart.tmpl in the same directory as above, it does not get generated when I do flutter create
Any ideas how to get this to work or where I should be looking?
NOTE
I have already tried out other options like Mason. It works fine for me, but I am more interested in doing it with default flutter tooling.
Already seen https://stackoverflow.com/a/61974852/6891637 and IDE file templates is not what I am looking for.
Currently there's no easy way to create a template similar to skeleton, package, and plugin. There's an open issue ticket for this feature. However, if you really need to create one. You can explore how skeleton was added as a template on this pull request.
Or as a workaround, you can just create a Flutter project template on your repo and fork it when starting a project.
This is the current issue about this topic : https://github.com/flutter/flutter/issues/77104
As Felix Angelov said, Mason and VeryGoodCLI are the best alternatives right now.

Deploying .lib file in the Salesforce org

I am using this code: https://github.com/pradeepramakrishna/Lightning-Experience/tree/master/aura-components to compile on my org.
I have got one components as eventLib.lib and interactive.js in eventLib folder. I have put this folder in c:MyDevOrg\force-app\main\default\aura folder in the local machine and tried to deploy in the org using VSCode but it didn't work.
I tried creating folder in the Files tab and added the interactive.js in the folder but that is also not seeming to work with the Aura components.
How can I deploy this lib into the org as it is being used in some Aura components.
We don't know what you're trying to achieve. You asked a very technical question to which the answer is "you're probably doing it wrong". Instead try to write what business functionality you are trying to achieve and you might get better answers.
You shouldn't have to import ui:eventLib. It's supposed to be part of core Salesforce's Aura components framework. But.
You've referenced a repo that wasn't updated in a while, no promises this still compiles / is best way to do X.
This repo seems to rely on open source Aura framework which is well... dead in the water.
You might be able to reuse something from this repo in your app using SF's built-in tags - but whole ui: library has been deprecated. Announced in Winter'20 = almost 2 years ago, finally dead in May 2021.
I don't think eventLib was ever exposed, might be something needed just in open source version which complicates the matter more. The answer would be to not work with the really "decompiled" tags but with their higher abstracted versions like ui:inputDate.
So, back to my question. What exactly are you trying to achieve.
You want to build something on pure SF platform (use pure Aura/LWC).
Want to have an app written in Angular, React etc, pure JS, connecting to SF data via API? (build it, upload as static resourcethen import using lightning:container)
want to prettify an existing Java/PHP/.NET app, make it look more Lightning-ish and embed it as iframe? (look into https://www.lightningdesignsystem.com/ and connected apps + "canvas")
want to expose piece of SF as reusable element that can be embedded in another website but could even be an Outlook plugin? (search for "lightning out")
want to look at modern equivalent of that old open source Aura repo and decide what to do next? Check https://lwc.dev/ out.

Is there a way to create just ONE NuGet package that will target multiple project types (web forms, MVC, etc.)?

My company commonly uses Web Forms projects and MVC projects within Visual Studio. When creating a package, the package will/should be different for the different project types.
QUESTION: Rather than creating two slightly different NuGet packages that do exactly the same thing for the two different project types, is there a way to just create ONE NuGet package that's project-type independent? So when installing the package, there will be logic in, perhaps, the .nuspec file that will say "if the project this is being installed on is Web Forms, then do this. If it's MVC, then do this".
I've looked at the following link, for the different ProjectProperties on a project - this seems like something I would utilize, but I'm not sure how.
I would not create a single package for different platforms, because you're loosing flexibility. You might want to take a look at how the Glimpse guys have created their packages as they were facing the same issue.
Check the following packages and the way they are chained:
http://www.nuget.org/packages/Glimpse/
http://www.nuget.org/packages/Glimpse.Mvc4/
http://www.nuget.org/packages/Glimpse.AspNet/

Making an app engine to use for similar app, but with different clients

Our team has made a big app. This app has been a success with previous client.
Now other clients will be using this app, but with added requirements and/or different needs.
I would like to focus on making the current app into a generic Engine so that we can maintain this engine up-to-date across those different client-apps.
How should I:
Tackle this?
Bearing in mind that some viewControllers will need to reflect for new client
Changing all the graphics across the app
Any hint of how I can achieve? Been googling since long, could not arrive at a decent solution.
I already did something similar in the past, here is how we did:
part 1A: create a template project using demo assets (images has to have a default names ex:background_home.png).
part 1B: make sure that "special texts" are loaded from a plist (example:[HOME_TITLE:"your title"]) in this way you will be able to load customizable texts from a plist in the app bundle programmatically.
part 2: ask your designer to make a special design for the client respecting the name used by the developers in the code (ex:part 1A => background_home.png) or ask your designer to generate more or less 20 themes.
part 3: make a MACOS app or a script which will copy the original project and replace demo assets and plist by the correct one in the original project. You want the script to generate an xcode project as you will need to double check with your developer team that the project is properly setted-up, build and deployment is much easier when you have an xcode project. In other words, the script just take the folder of the original project your team made and replace some file inside. So you won't struggle with xcode project architecture, you just replace defaults assets. Also remember that storyboard files or pbxproj are xml so you can parse and edit them, but you might have some headache doing this, that's why I recommand you to just modify the assets in the project folder.
Then you can compile that project, configure it with the provisioning you want and deploy it to your clients. Thats what we did when we needed and it worked like a charm. Basically we made a MACOS app that the sale's force could use directly with the client. They just had to send to the developer team the generated xcode project in a zip and we were in charge of the compilation and deployment. We "developed" more than 600 products using that trick.
PROBLEMS:
- The code was fully visible in the xcode project and anybody could read and/or steal it.
- The projects were very similar to each others as they came from the same source code, only the texts and assets were differents.
WORKAROUND-SOLUTIONS:
- You can imagine implementing crypto when saving the archive of a project, in this way only authorized personal can unzip the archive containing the source code.
- You can create multiple projects and do the same process with different types of project. In this way you can change the type of a generated project according to client wishes ...
Hope this help!

Auto upload files in included path using Netbeans

I have a NetBeans javascript project with several included paths for plugins. I do not want to include the plugins in my core repository, so I have created separate, external folders for each and am including them via an include path. Because I test across many devices, I need my changes to upload on save and this works fine for the main code base, however, I would like to be able to edit a plugin via the include path and see those changes auto uploaded as well. Is this possible?
As of right now, the only alternative I see is to create separate projects for each plugin, which I am willing to do if this is the only option. The single project workflow is very preferable to me and I might be willing to switch IDE's if this is possible in another environment.
I would be happy to elaborate if my intentions are unclear.
I don't think it's possible. What about creating one single "umbrella" project for all plugins and simply manage it the same way you do the main project?
Personal note: What you have is basically several projects and the uploading is focused always on single project. So what you want is like "I want to treat them as projects but not to at the same time" :) Btw, how do you edit a plugin? I guess open it as a project in NetBeans or use some text editor. So again you basically treat it as a project.