I have many pages and I want to share file content between some pages, also giving this pages ability to modify content, the file contains (obj, data (int, bool, ...)).
1st: share file content between some pages can be done by using Constructor.
2nd: ability to modify conten can only be done by global variable+ key, but go for stateManagement.
I suggest, you should go for StateManagement. It can handle that.
I perefer using riverpod, also people suggest using getx being easy to use.
for more read this.
You can try the provider package as it's an effective tool for sharing data a cross your flutter app: https://flutter.dev/docs/development/data-and-backend/state-mgmt/simple
Either use constructors to dig through the widgets or simply use one of the packages for state management like provider, getx, bloc and many others.
But if you are a beginner then go with provider package as it is recommended by flutter team
Related
So currently i am using flutter providers package for managing state in my app.
Things i am able to do currently:
Maintaining a bool variable and using it to maintain states globally.
Having a string in which there is some text and it changes as user types in something and displayed on home page.
when i click on a button is there a way to erase all my maintained states to earlier one, i.e. to remove all states? I am managing lots of states for my app and it is cumbersome to manually change them to earlier one on clicking button.
Check out this question. The top answer is by the author of the Provider package. Alternatively, you could try out the Phoenix package as suggested in another response.
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.
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
I am using the Table Calendar package with flutter. Please note that I am using Firestore.
I am trying to figure out how to update the list of items instantly when the user adds or deletes items. So far I need to click on the day again to see changes. I am using setState in the onDaySelected which currently updates the data. Thanks in advance for your help.
That requires a more complex state management than using setState. Check the flutter_bloc package for example. You also have riverpod and one of the most simple is provider. You can find a lot of information in their apis and even online.
The packages:
flutter_bloc
riverpod
proivider
There is also a complete list of all the state management packages you can use in Flutter. Here's the official list, and you also a not official list (however it is also valid!).
Please note i am not talking about the .abr files.
I have been following several tutorials on internationalization in Flutter using the intl package. I noticed that they always use a single AppLocalization class for storing all the messages that will be used in the application. Since it was a tutorial, I am wondering if we will always have to do it that way. I mean in a real application we will probably have hundreds messages to maintain. It would be a mess to put them all in a single class.
Maybe we should have a localization class for each Page?
What are your suggestions?
Flutter Intl package it's the right solution; also i used to Easy Localization.
This package has a "inherited widget " concept, so if you want to change automatically change UI for changed Local Language, it will be quite useful to you.
Maybe you want to localization JSON update to server and use application new key-value without deploy store. EasyLocalzation does read the server-side JSON file.