What is the best way to build a page template in flutter - flutter

Is there any kind of template builder for flutter (e.g. similar to jinja) or what is the best way to build a page template inside the app?

Traditional template mechanisms provide a way to separate the static content (text, graphics etc) from the dynamic data at design time. At run time you provide the dynamic data and it is rendered in the template.
Flutter has no such concept - the whole display is rendered by widget code. But you can think of widget code as templates that render the run time data.

Related

How to document Flutter widgets and screens classes in my app?

I don't know what is the common way and best practices used in documenting UI widgets and components in a Flutter app, I could find a good resource on how to document dart code in general here
And how you can describe a function behavior or a model attribute.
But what is the best way to add comments for UI Classes, Screens, Refactored Widgets, etc..
so that it can be helpful and describes the widget or the screen contents?
The whole flutter project is open source. You could always check how the flutter team documents its widgets.
For example, here is the source of the Container widget:
https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/container.dart
Personally, I would only document widgets which I publish as part of a library. But tastes are different :D

Which is the better way to white-label a flutter app

I have one project that I have to sell to another clients, so I wanna found a way to unify the code to, when I release some updates, I have to manipulate only one code (and, of course, keeping the specificities from each one)
I found an article HERE which the guy creates a new folder named 'config' and set some variables there to be used in the parent project. I tried this but find out that would be very tough to do because the first app was developed specifically by one client, and with it I would need so much time to make all the aspects dynamic... Another problem is firebase, in first app I used firebase but in the second i won't. How to make it possible?
And in this article they say about 'flavours' that can be used to do something similar.
Someone knows about this approaches or there is another to reach my goal? With flavours I will have less re-factor than with config?
I appreciate any help
A third way to do this with no client specific app configuration is to make an api call to get back your client specific theme, and then set the flutter theme based on this.
If you need web support see below:
First update your assets in index.html that aren't white labeled, leaving stubs in their place that we'll fill in later. i.e.
Next show a nice loading indicator while flutter loads. To do this, just put the html for it in the body element of the index.html file.
Finally update the webpage title and favicon using javascript inside Flutter. I used package
universal_html: 2.0.8
https://pub.dev/packages/universal_html
then you can update the favicon
import 'package:universal_html/html.dart';
var favicon = document.getElementById('favicon');
favicon?.setAttribute('href','insertLinkToYourImage');
Updating the title can be accomplished in various normal ways like just setting the title attribute of a MaterialApp widget.

Is there any tool that I can use to manage global data in flutter?

Recently I'm working in a basic project to learn a little bit more of flutter.
But I found a blocker... which is that I have to pass data consistently and updated between a widget and its parent, so I wonder if is there any tool or extension to add that let me manage global scopes in my widgets.
Something like redux o a similar concept... Is there any of it? How can I control data in a flutter project if I need to use them in different widgets?
Thanks for your help

How to safely add page content via CMS?

If I were to build a custom CMS that allowed someone to log in and build a page using a WYSIWYG would it be possible to make it secure and allow JavaScript code in the content? There are times where someone wants to add a video embed code or a widget that grabs an RSS feed, these embed codes and widgets are in JavaScript. So how do I allow them to add that to their page through a CMS? My main concern is XSS/vulnerabilities.
You could store tags with references to widgets in your rich text content, like <video>id</video>, and render the javascript only in frontend... or you could choose to use any of the modern CMS's out there with plugins for video and widgets that already solved the problem for you.

how to integrate or call or interface with a 3rd party widget within a GWT app?

I am making an app in GWT. It is like a dashboard and will have out of the widgets.
Now when we ship this out, there is a use case that the customer might want to create their own GWT widget and use this in the dashboard app.
As I understand it, they will not be able to do this since we cannot ship our source code which is needed to compile the whole app again once tag of their widget/module gets into the gwt.xml file of my app.
I cannot use anything other that GWT to make this dashboard. And their widget could be say a flash heapmap, a jquery widget/plugin, another GWT module, a jsp page that renders a visualization from back end.
So far my thoughts have been to provide a widget in my app which is a wrapper in the form of an Iframe and call their main page (they will provide url), and have an api to let my app and their widget talk.
But I would like to know if there are other / better approaches?
This is exactly the problem solved by google's OpenSocial widgets. There are a few opensource implementations: http://shindig.apache.org/ is one. You can look into integrating that in to your app. An added bonus is that you can then display widgets from other applications (such as atlassian jira) that also serve opensocial widgets.
Depending on how closed source your application is (can custom JS/HTML be added to pages?), you could always provide a native Javascript (JSNI) API for some custom dashboard widgets. The simplest solution I'm thinking of would be a JSNI method which your customers could call to set the HTML content of said widget. This method would allow them to use a variety of options such as JQuery widgets, their own GWT widget generated HTML or even an IFrame pointing to their JSP pages etc... You could then provide additional JSNI API methods which would allow them to interact with your app/widget in other ways as well. This would be better than the IFrame method because you wouldn't have to deal with cross domain scripting security issues.