Flutter Dartdoc: How to Document State Objects in Statefull Widgets? - flutter

This is a part of a project where i am building a clone of the Flickr App for educational purposes.
I am playing around for the first time with Dartdoc and Documentation concept in general, I managed to use Dartdoc and create a Doc folder with documentation for my project. However, for all my Stateful widgets, The widget itself has documented Properly however the state object (the object where I have my build methods, my initstate methods, and my state variables), I don't get any documentation for that, is that the default behavior or am I doing something wrong? I want to generate Documentation for this state object, the methods inside it, and the variables inside.
Apart From that, I am getting a couple of warnings, I will search further into those, and if can't manage to resolve them I will open a separate question.
Here is how I used Dartdoc:
Dartdoc command
End of Dartdoc command
Generated Doc
Generated Doc _ Methods
Forgive me if my question is stupid, it is my first time ever working with documentation :D
EDIT: A naive solution that I am doing, is that I moved most of my variables and methods to the widget object instead of my state object. Is this the right way to go about this?

Your State class is private (_FlickrCameraScreen), so it will not generate public documentation. If you want public documentation for it, you will need to rename it to FlickrCameraScreenState. You can give it a private constructor if you need to restrict creation to your FlickrCameraScreen widget.

Related

How to properly implement repository in flutter/dart

Being new to flutter and dart, I am looking for ways to structure my projects. I have found that the Repository pattern made its way to dart (I have a strong Java background), but I have found that there's not the necessary tools yet to properly implement a repository.
How I would normally approach this is to first create the simple straightforward methods. I ended up with the following dart code:
abstract class CategoryRepository {
Future<List<Category>> getCategories();
Future<Category?> getCategoryById(String id);
}
All is good. But now imagine I have a PostRepository, and I only want to return posts of a specific category? I am missing a standardized way in flutter how to add conditions to my repository select methods. I cannot believe nobody has written something for this purpose before so I am doubting whether I am on the right track here. Maybe my Java background is throwing me off.
In Java (specifically Spring JPA) I am used to specifications, predicates and criteria as documented here.
In .NET you can implement select methods of a repository pattern with the Expression class which allows you to use LINQ to add select criteria as documented here.
For Flutter or Dart, what would be the equivalent? Or am I on the wrong track?
I have found the flutter_repository package, but it is deprecated (without a reason). Looking at the documentation it indeed had Specifications which are used to add conditions. This would be exactly what I expect/need, but again it's deprecated.
This is where I cannot find the information publicly anymore and am questioning "how to properly implement repository in flutter/dart", hence the reason for posting this.

Best practice for accessing build context from multiple classes for app localization in Flutter?

So, I have got a class that needs to generate some words and sentences using the localized app resources. I access them using AppLocalizations.of(context).helloWorld. The class that needs to access these localized resources is initialized by a class which is initialized by another class with is initialized by a database helper class with is initialized by an actual widget. The problem is that only the widget has the BuildContext I need in my generating words class. Is it best practice to just pass the build context through all the constructors or methods of the different classes or is there a better way? Any advice would be highly apriciated :)
You can use flutter intl for internationalization like it shows on Localizations in Flutter .
It is better to use context when available.Here's how you'd do it.
AppLocalization.of(context).title
or
Applocalization.current.title
//In case buildcontext is not available.
Here is a reference to the implementation on medium blog.
Flutter Localization
Alternatively, I would suggest you to check out VSCode extension (if you use vscode) for Flutter intl extension and follow the steps on the extension itself.

Flutter Mobx - Passing store state between pages in PageView

How can i pass or preserve the state of my store between pages using PageView?
By example, I'm trying to upload an image at the first page to edit, and pass to a second page where i want to show the image with a form. Im using MVC, and the image is set via controller (store), but it's not working. I've been made some tests and sometimes, at debugging runtime, the image is shown at the second page. But, sometimes even debugging it isn't shown and its value is null.
I tried with AutomaticKeepAliveClientMixin also, but the behavior is the same.
Someone can tell me what i'm doing wrong or what i'm missing?
I think using singleton can solve your problem, actually I think I had this problem in two apps I made.
I used get_it plugin, this package creates singletons easily for you and it's simple to retrieve anywhere in the app without using context.
First, register your MobX as Singleton, I do it on main:
getIt.I.registerSingleton<YourStore>(YourStore());
Retrieve the same instance of your Store, if you have observables in the first page and call an action on the second page, it will trigger the observables in the first page or wherever you used any observable from this instance of Store.
GetIt.I<YourStore>().changeImageFromFirstPage();
You can call GetIt.I().youraction() anywhere in your app, it will trigger the observables you created on this Store.
final list = Provider.of<TodoList>(context);
in the MobX document, there is a provider that can be used as the above code.
I use GetIt too, it is really awesome.
there is a sample for this in the following URL for the MobX:
https://mobx.netlify.app/examples/todos

Ansible CallbackBase result object content

Our dev team provides us an Ansible package to work with. I noticed thy develop a custom stdout_callback and I'm trying to understand it.
I'm looking at the code of the class CallbackBase available here and I noticed the result variable but I can't find a description of it's content.
Is there a place I can find such information?
Next question, how does Ansible call such callback? CallbackBase contains several methods but I'd like to know where those methods are called.
Thanks for your feedbacks

GWT Composite best practices

I'm learning GWT and have started to get the hang of it. I'm at the point where my code is getting to be a spaghetti mess so I'm going back and factoring reasonable bits of it out as Composites. The first problem I ran into was that my tool support failed to give the new Composite class an initWidget() method. It did include a default constructor.
For the time being, I've simply filled in my overridden initWidget() method with a call to super(initWidget(w)) My project compiles and runs as expected, though I feel as though I must be missing something.
What should I keep in mind when overriding init and what if anything do i need to place in the constructor. Is there anything else that I need to know or does it just boil down to regular old Java after this?
Clarification - It has occurred to me that there are probably different answers to this question depending on whether you intend to release said Composite classes as part of a library or simply part of your stand-alone app. I in particular have no intention at this time of developing externally useful components (mainly because I'm so green in this particular technology.)
Thanks!
I'm not sure if I understand what you are trying to do. But for all the Composite's I've written I've never overridden the initWidget method. Because Composite itself doesn't need to be initialized with a constructor, i.e. no need to call super() my constructors of widgets extending composite look something like:
public mywidget() {
SomePanel p = new SomePanel();
....
initWidget(p);
}
As a best practice, imo, only the widget extending Composite should call it's 'own' initWidget.
"GWT Conference: Best Practices for Building Libraries" gives a couple of tips. You should also look at the source of GWT and at the source of one of the libraries for GWT (like gwt-ext)
[EDIT] I just saw another option: suco. From the description:
A micro library that helps to maintain your GWT client code clean and modular.