How to load csv from url and display as listview flutter - flutter

I am new to flutter and I found load csv from local and display as listview but I want to load from url and display. How can I do that?

A .csv from a remote source will probably have the content type of text/csv.
You should be able to call the url using a library (https://pub.dev/packages/http is a good choice, although I hear good things about Dio and probably a few others I haven't come across), get the data (e.g. as a http.Response), parse the response into some sort of model and then display it within the list view. Ideally the differences between displaying data from a local and remote source would be minimal - just where the data is coming from. This means you should be able to reuse the code you've written to load the data from a local source.
Without more information its hard to help. There's a good tutorial on building out Flutter apps using the Clean architecture at https://resocoder.com/category/tutorials/flutter/tdd-clean-architecture/. The difference will be that the Response data will be csv rather than JSON, so you'll need to sub in what you've done for the local loading.

Related

Is it possible to use the Hive database file used in Android in the Web App?

Click a button on Android or the web to upload the Hive file to the server. Then, in another operating system, download the Hive file that exists on the server and use it.
Android Hive File -> Use Web
Web Hive File -> Use Android
Is this possible?
My explanation may seem complicated. If you do not understand, please leave a comment and I will try to explain in more detail.
If you wanna just to have your Hive database saved on your backed, then consider getting it as a List:
final dataThatWillBeSent = box.values.toList();
Then pass that dataThatWillBeSent in your backend simply, you can make observables for it.
I couldn't say that's not possible to make transfers with the .hive files, but there is no point of it when you can simply send your data as regular data structures like List, Map<String, dynamix>.
the Hive saves the data in the device by encrypting it with binaries, so even if you managed to make transfers with it, you need to have decrypters also for it.

Flutter asset folder path

I want to build an app with multiple flavors, which work very well. But now I have the requirement to include static json files into my preview app, because sometime the backend differs in development speed. So I can use the json files within my app as fake/mock data.
Hard requirements are:
Preview has jsons included
Production should be release without any unused files (no jsons files)
What's the best way to do it?
I think it depends on the data. If JSON will not change anymore or rarely change, you can just load JSON from the local asset. Otherwise, getting the JSON data from the cloud is a better way. It's more flexible.

How can i browse file without uploading in GXT?

i'm beginner with GXT and i'm wondering if there is a way to parse a file and extract some informations without uploading it.
i created a formpanel that contains an uploadFile form but i don't know waht's next, how to get the complete path of the file so i can read/write with java io or how to retrieve the file or is there an alternatif solution, thank you.
Best Regards.
You can do it in some modern browsers using bleeding edge HTML5 apis for which you would need to use GWT JSNI code. There are no api's from GWT team as is.
HTML5 FileReader
FileReader includes four options for reading a file, asynchronously:
FileReader.readAsBinaryString(Blob|File) - The result property will contain the file/blob's data as a binary string.
FileReader.readAsText(Blob|File, opt_encoding) - The result property will contain the file/blob's data as a text string.
FileReader.readAsDataURL(Blob|File) - The result property will contain the file/blob's data encoded as a data URL.
FileReader.readAsArrayBuffer(Blob|File) - The result property will contain the file/blob's data as an ArrayBuffer object.
Example of GWT wrapper over these -
https://github.com/bradrydzewski/gwt-filesystem
You can read about it more from here - How to retrieve file from GWT FileUpload component?
IMHO you cannot read it .
Due to security reasons javascript(gwt) doesn't have access to the system drives files.
http://en.wikipedia.org/wiki/JavaScript#Security
see Opening a file in local file system in javascript
In order to get the file you need to make a server call.
Instead you can do your validation server side and throw proper messages to user.
P.S : i am not considering modern browser concept.What happens if someone opened in other than so called modern browsers?? Will the programm runs same?? Its always better to do server side validation..

What's the best way to download multiple images and display multiple UIImageView?

I need to download images from a website and display them on(?) multiple UIImageView.
Maybe I'll code a php to "read" the directory and search for images, write a XML file and use it as medium. But I'm not sure if it's the best way.
Let's see the options you have to fetch images from a website:
Fetching HTML and Parsing the HTML to find the images (on the iphone). Then downloading the images.
Writing a script (maybe PHP) that writes all image links to an XML file (or JSON), and then fetch the output of your script with all the links.
If you choose option (1) you'll need NSURLConnection to fetch data asynchronously (without blocking the UI). I would also use TFHpple to parse HTML using xpath queries, see this tutorial for help. Finally to fetch the images using their URLs you can use SDWebImage, SDWebimage also provides caching so your app will not download the same image multiple times.
The bad side of using option (1) is that any change in the Website you're getting the images from will break your app and you'll need to issue an update to the app store in order to fix it.
If you choose option (2), your app will be easier to fix if the website changes, you'll just need to modify your script.
If you go with option (2) you'll probably need NSURLConnection, NSXMLParser (or a third party XML parsing library) and to download the images I would recomend SDWebImage again. I would also advise using JSON (and NSJSONSerialization) instead of XML, just beacuse I find JSON easier to parse.
Yes, it will be very good if you write some php script to get image list (list of image urls).
After getting such urls you can asynchronously download and show them in image views. Look here for such async image view implementation

To add image to an excelsheet in iphone

In my app I want to retrieve data from database and add it to an excelsheet.
The Database's data are in string and BLOB format. I have retrieve the data and added to excel sheet using the frameworks:
https://github.com/andreac/RSSheet
The problem is that I want to add image to the worksheet too.
If any one has any idea about this please help me.
The RSSheet library does not currently support adding graphics to the sheet. You'll need to do this on the server side unless you expand the RSCell class to support this.
Depending on your backend this can be done easily. In PHP I used the PHPExcel library.