How to use FutureBuilder to build ListTile using List data - list

List> _userAccounts;
Result:
_CurrentUserAccounts: [
[Current Account, 10.06, United States Dollar USD],
[Demand Deposit, 55.22, British Pound GBP],
[Current Account, 250, Euro EUR],
[Deposit Account, 0, Euro EUR]
]
Format:
[AccountName, CurrentBalance, CurrencyName],
I need to use this info (List>) to build a ListTile.
This is for only one user. Some user might 1 account and some of them might have over 10 accounts.
What is the best practice to show this data? I am planing to use ListTile so, if user tabs the ListTile so they can get details of the
certain account.
So, How to use FutureBuilder to build ListTile using List data?

You have to provide an instance of FutureBuilder to home or root widget. As you can see below.
body: new FutureBuilder<List<Country>>(
future: fetchCountry(new http.Client()),
builder: (context, snapshot) {
if (snapshot.hasError) print(snapshot.error);
return snapshot.hasData
? new CountyList(country: snapshot.data)
: new Center(child: new CircularProgressIndicator());
},
I have found a simple example for it here.

Related

How to unscheduled/inactive Saved Search after refreshing sandbox account Netsuite?

After refresh sandbox account from production account , some scheduled saved search who are made to run on production account run on sandbox and it's not what I want.
There is a way to prevent this ?
Saved search are not an accessible record so I don't Know how to do with a script or a workflow. Maybe a general preference or a rule or setting during the refreshing exist but I didn't find it .
The only solution I found except delete all the schedule searchs is to set an
unreachable filters to get 0 results
if someone have a better solution please let me know
function execute(scriptContext) {
var searchSavedSearch = search.create({
type: search.Type.SAV , filters: {
name: 'sendscheduledemails',
operator: search.Operator.IS,
values: ['T']
}
})
var searchResult = searchSavedSearch.run().getRange({ start: 0, end: 1000 })
var resultNumber = searchResult.length
for (var x = 0; x < resultNumber; x++) {
var searchRecord = search.load({ type: search.Type.SAVED_SEARCH, id: searchSavedsearch[x].id })
var filtersArr = searchRecord.filters
filtersArr.push(search.createFilter({
name: 'internalid',
operator: search.Operator.IS,
values: -1
}))
searchRecord.save()
}
}
Have you set email delivery preferences for you Sandbox account? If not go to Setup > Company > Email > Email Preferences (Administrator). Choose your preference on the Sandbox and Release Preview subtab, under Sandbox Options. Reference Suite Answer Id: 20152

Does an additional resolver in AppSync/ DynamoDB bill twice for read operation?

I need to query after my users favorite posts. With this query they should be able to see the post with his information like title and likes. Considering that the value of some attributes like total likes can change over time, I can't add these values into the favorite dataset. If I would do that, I had to update every favorite dataset when someone likes a post to keep them up to date.This lead me to the decision that I don't add these informations (for example total likes) into a favorite entry and just attach an additional resolver for the post attribute. It could look like this:
type Post {
pid: ID!
title: String!
content: String!
likes: Int // <-- An attribute which I need to show while displaying favorites
}
type Favorite{
fid: ID!
pid: String!
...
post: Post! // <-- This has an own resolver
}
The attribute Post has his own additional resolver attached through AWS AppSync which could look like this
{
"version": "2018-05-29",
"operation": "GetItem",
"key": {
"id": $util.dynamodb.toDynamoDBJson($ctx.source.pid),
}
}
If a user would query his own favorites, would this cost twice of the read operation ? Since it needs two GetItem Operation for each in the result
Example:
Query favorites with limit 10 would cost 20 read ops (10 for plain Favorite data (fid and pid) and 10 for post data through the additional resolver.
Or does DynamoDB bundle it up into one read operation in the background ? Furthermore is this an acceptable solution (or a normal approach) for this problem ? Are you using this technique ? Or would this get very expensive while scaling ?
EDIT: Im using only one table, so every dataset is in it.

djStripe - zero dollar plan - do not ask for credit card, but create customer

I am using Django app djStripe to work integrate Stripe into my Django app to allow users to subscribe to plans and pay using Stripe.
I want to have a zero dollar plan but create a Stripe customer account so in future using can just change subscription from zero to a paid plan, and then they will be asked for their credit card info.
This is acceptable in Stripe and according to Stripe a zero dollar subscription does not ask for credit card though it does create customer. However, djStripe does ask for credit card with a zero dollar plan.
djStripe readthedocs does hint at custom plans being the solution but I am need help to determine if
a) that is indeed the way and
b) if yes to a), then how to implement.
I've setup the plan in my app's Settings.py as follows:
DJSTRIPE_PLANS = {
"starter": {
"stripe_plan_id": "starter",
"name": "Starter",
"description": "Starter subscription.",
"statement_descriptor": "Starter co",
"price": 0, # $0
"currency": "usd",
"interval": "year",
"trial_period_days": 0,
"team_size": 2,
"image_count": 1000
}
}
I haven't customized any of the standard djStripe subscription process.
First of all add trail period in the plan, because without a trial period stripe tries to charge the customer for that it requires a credit card info. Subscribe to customer.subscription.trial_will_end stripe will send this webhook three days before the trial expires and on that event update trail for customer.

How to Retrieve Current balance of the bank Account in Netsuite

I need to retrieve the current balance of bank Account in Netsuite using SuiteTalk(Netsuite Webservise).In suite talk API there is no field/parameter to refer the balance of account.But There is UI field Balance which shows the current balance of the account.Any help/suggestions on this is appreciated
If there is no field/parameter in the API referencing that UI field, it is most likely that the field is not supported by the API.
It's definitely not intuitive, but it is possible to pull this data using the API. Here's an example using the netsuite ruby bindings.
def balance_for_account(ns_account)
search = NetSuite::Records::Account.search(
criteria: {
basic: [
{
field: 'internalIdNumber',
operator: 'equalTo',
value: ns_account.internal_id
}
]
},
columns: {
'listAcct:basic' => {
'platformCommon:internalId/' => {},
'platformCommon:balance' => {}
}
}
)
search.results.first.attributes[:balance].to_f
end

Using facebook fql, how do I find where a school is?

[Note: the first two answers, which includes the one I wrote, do not yet deal with the "optional" fql.multiquery issue.]
When I am using facebook's fql, I can get a list of schools I have attended, or that friends have attended. Specifically, I can get the school's name, and it's facebook id. However, I do not know how to query for deeper information about these schools.
Specifically, I would like to find out where the schools were located. But, I do not know what facebook graph entity (or whatever else) those school ids are part of.
How would I find out from facebook where these schools are located?
Optional: It would be even better if this can be done in the same multiquery that returned the lists of schools in the first place (this would be a query against the user table for my id and another query against the user table for some ids of my friends).
Here's an expanded version of the optional part mentioned in the above paragraph (note that I tried adding this as a separate question, but when I went in make the illustrative data more relevant, I saw that it had silently vanished. So I am assuming I tripped over some feature of stack overflow designed to weed out questions which are too similar to each other. So, instead, let's just say that this is a clarification of what I meant, in the above paragraph)
Using facebook's javascript sdk, this fails, silently:
FB.login(function(response){
disp('loginResponse', response);
var userQuery= FB.Data.query(
'select uid,name,education from user where uid= {0}'
, response.session.uid);
var friendlist = FB.Data.query(
'select uid2 from friend where uid1 = {0} order by rand() limit 10'
, response.session.uid);
var friends = FB.Data.query(
'select uid,name,education from user where uid in (select uid2 from {0})'
, friendlist);
var friendSchools= FB.Data.query(
'select page_id,name,location from page where page_id in (select education.school.id from {0})'
, friends);
self.queries= [userQuery, friendlist, friends, friendSchools];
FB.Data.waitOn(queries
, function() {alert(1)});
})
If I remove the friendSchools element from the queries array, it works just fine, and a friend might be represented by an object like this:
{
uid: '...',
name: '...',
education:
[
{
school:
{
id: '115920001751600',
name: 'Burlington High School'
},
year:
{
id: '138792749476094',
name: '1978'
},
type: 'High School'
},
{
school:
{
id: '20697868961',
name: 'Boston University'
},
degree:
{
id: '188387604516411',
name: 'BS'
},
year:
{
id: '103823546338323',
name: '1982'
},
type: 'College'
}
]
}
So, how do I restructure the where clause in the friendSchools query so that that query can be performed?
In other words, how can I use fql.multiquery to find information about schools (or other such entities) returned elsewhere in the multiquery?
I would suggest using batch requests (more information here: https://developers.facebook.com/docs/reference/api/batch/) to query the graph based on the schools ID you already have. The location of the school can be retrieved in it's default basic information returned (example below).
{
"id": "6192688417",
"name": "Stanford University",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/41571_6192688417_2310209_s.jpg",
"link": "https://www.facebook.com/stanford",
"likes": 203153,
"category": "Education",
"website": "http://www.stanford.edu",
"username": "stanford",
"founded": "1891",
"location": {
"street": "450 Serra Mall",
"city": "Stanford",
"state": "CA",
"country": "United States",
"zip": "94305",
"latitude": 37.42895,
"longitude": -122.1697
},
"public_transit": "http://transportation.stanford.edu",
"general_info": "Located between San Francisco and San Jose in the heart of Silicon Valley, Stanford University is recognized as one of the world's leading research and teaching institutions.\n\nLeland and Jane Stanford founded the University to \"promote the public welfare by exercising an influence on behalf of humanity and civilization.\" Stanford opened its doors in 1891, and more than a century later, it remains dedicated to finding solutions to the great challenges of the day and to preparing our students for leadership in today's complex world.",
"checkins": 9938
}
And, it looks like to get fql to work I want to be querying the page table. For example:
select name,location from page where page_id = 87873693141
(That said, I'm still trying to figure out how to extract the list my education's school ids into the where clause for a multi-query.)