kandi background
Explore Kits

grover | Neural Fake News | Machine Learning library

 by   rowanz Python Version: Current License: Apache-2.0

 by   rowanz Python Version: Current License: Apache-2.0

Download this library from

kandi X-RAY | grover Summary

grover is a Python library typically used in Artificial Intelligence, Machine Learning, Deep Learning, Tensorflow applications. grover has no bugs, it has no vulnerabilities, it has a Permissive License and it has high support. However grover build file is not available. You can download it from GitHub.
(aka, code for Defending Against Neural Fake News). Grover is a model for Neural Fake News -- both generation and detection. However, it probably can also be used for other generation tasks. Visit our project page at rowanzellers.com/grover, the AI2 online demo, or read the full paper at arxiv.org/abs/1905.12616.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • grover has a highly active ecosystem.
  • It has 826 star(s) with 202 fork(s). There are 39 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 28 open issues and 24 have been closed. On average issues are closed in 21 days. There are 5 open pull requests and 0 closed requests.
  • It has a negative sentiment in the developer community.
  • The latest version of grover is current.
grover Support
Best in #Machine Learning
Average in #Machine Learning
grover Support
Best in #Machine Learning
Average in #Machine Learning

quality kandi Quality

  • grover has 0 bugs and 31 code smells.
grover Quality
Best in #Machine Learning
Average in #Machine Learning
grover Quality
Best in #Machine Learning
Average in #Machine Learning

securitySecurity

  • grover has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • grover code analysis shows 0 unresolved vulnerabilities.
  • There are 6 security hotspots that need review.
grover Security
Best in #Machine Learning
Average in #Machine Learning
grover Security
Best in #Machine Learning
Average in #Machine Learning

license License

  • grover is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
grover License
Best in #Machine Learning
Average in #Machine Learning
grover License
Best in #Machine Learning
Average in #Machine Learning

buildReuse

  • grover releases are not available. You will need to build from source code and install.
  • grover has no build file. You will be need to create the build yourself to build the component from source.
  • Installation instructions, examples and code snippets are available.
  • grover saves you 1068 person hours of effort in developing the same functionality from scratch.
  • It has 2421 lines of code, 110 functions and 16 files.
  • It has high code complexity. Code complexity directly impacts maintainability of the code.
grover Reuse
Best in #Machine Learning
Average in #Machine Learning
grover Reuse
Best in #Machine Learning
Average in #Machine Learning
Top functions reviewed by kandi - BETA

kandi has reviewed grover and discovered the below as its top functions. This is intended to give you an instant insight into grover implemented functionality, and help decide if they suit your requirements.

  • Build a classification model function .
  • Create a function that builds the model .
  • Initialize Grover .
  • Attention layer .
  • Apply gradients .
  • Tokenize the given item .
  • Embed word embedding .
  • Create an optimizer .
  • Main function .
  • Generate a sample .

grover Key Features

Code for Defending Against Neural Fake News, https://rowanzellers.com/grover/

Setting up your environment

copy iconCopydownload iconDownload
curl -o ~/miniconda.sh -O  https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh  && \
     chmod +x ~/miniconda.sh && \
     ~/miniconda.sh -b -p ~/conda && \
     rm ~/miniconda.sh && \
     ~/conda/bin/conda install -y python=3.6

Bibtex

copy iconCopydownload iconDownload
@inproceedings{zellers2019grover,
    title={Defending Against Neural Fake News},
    author={Zellers, Rowan and Holtzman, Ari and Rashkin, Hannah and Bisk, Yonatan and Farhadi, Ali and Roesner, Franziska and Choi, Yejin},
    booktitle={Advances in Neural Information Processing Systems 32},
    year={2019}
}

w2ui combo input doesn't work inside a popup

copy iconCopydownload iconDownload
function openAddSymbolPopup() {
    w2popup.open({
        title     : 'Add Symbol',
        body      : '<div style="height: 25px"></div>' +
        '<div class="w2ui-field w2ui-span3">' +
            '<label>Symbol:</label>' +
            '<div> <input type="combo"><span class="legend"></span> </div>' +
        '</div>' +
        '<div style="height: 20px"></div>',
        buttons   : '<button class="w2ui-btn" onclick="w2popup.close();">Close</button> ',
        width     : 300,
        height    : 200,
        overflow  : 'hidden',
        color     : '#333',
        speed     : '0.3',
        opacity   : '0.8',
        modal     : true,
        showClose : false,
    });
    $('input[type=combo]').w2field('combo', { items: people });
   /* ☝️ this input only exists while the popup is open. 
    *    You have to call 
    *    the above function every time you open the popup.
    */
}

var people = ['George Washington', 'John Adams', 'Thomas Jefferson', 'James Buchanan', 'James Madison', 'Abraham Lincoln', 'James Monroe', 'Andrew Johnson', 'John Adams', 'Ulysses Grant', 'Andrew Jackson', 'Rutherford Hayes', 'Martin Van Buren', 'James Garfield', 'William Harrison', 'Chester Arthur', 'John Tyler', 'Grover Cleveland', 'James Polk', 'Benjamin Harrison', 'Zachary Taylor', 'Grover Cleveland', 'Millard Fillmore', 'William McKinley', 'Franklin Pierce', 'Theodore Roosevelt', 'John Kennedy', 'William Howard', 'Lyndon Johnson', 'Woodrow Wilson', 'Richard Nixon', 'Warren Harding', 'Gerald Ford', 'Calvin Coolidge', 'James Carter', 'Herbert Hoover', 'Ronald Reagan', 'Franklin Roosevelt', 'George Bush', 'Harry Truman', 'William Clinton', 'Dwight Eisenhower', 'George W. Bush', 'Barack Obama'];
people.sort();
<link rel="stylesheet" href="http://rawgit.com/vitmalina/w2ui/master/dist/w2ui.min.css"><script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="http://rawgit.com/vitmalina/w2ui/master/dist/w2ui.min.js"></script>
<script src="http://w2ui.com/src/w2ui-1.5.min.js"></script>

<button onclick="openAddSymbolPopup()">w2ui Popup</button>
function openAddSymbolPopup() {
    w2popup.open({
        title     : 'Add Symbol',
        body      : '<div style="height: 25px"></div>' +
        '<div class="w2ui-field w2ui-span3">' +
            '<label>Symbol:</label>' +
            '<div> <input type="combo" id="popup-combo"><span class="legend"></span> </div>' +
        '</div>' +
        '<div style="height: 20px"></div>',
        buttons   : '<button class="w2ui-btn" onclick="w2popup.close();">Close</button> ',
        width     : 300,
        height    : 200,
        overflow  : 'hidden',
        color     : '#333',
        speed     : '0.3',
        opacity   : '0.8',
        modal     : true,
        showClose : false,
    });
    $('#popup-combo').w2field('combo', { items: people });
   /* ☝️ init the combo inside the popup only, every time the popup opens.
    */   
}

var people = ['George Washington', 'John Adams', 'Thomas Jefferson', 'James Buchanan', 'James Madison', 'Abraham Lincoln', 'James Monroe', 'Andrew Johnson', 'John Adams', 'Ulysses Grant', 'Andrew Jackson', 'Rutherford Hayes', 'Martin Van Buren', 'James Garfield', 'William Harrison', 'Chester Arthur', 'John Tyler', 'Grover Cleveland', 'James Polk', 'Benjamin Harrison', 'Zachary Taylor', 'Grover Cleveland', 'Millard Fillmore', 'William McKinley', 'Franklin Pierce', 'Theodore Roosevelt', 'John Kennedy', 'William Howard', 'Lyndon Johnson', 'Woodrow Wilson', 'Richard Nixon', 'Warren Harding', 'Gerald Ford', 'Calvin Coolidge', 'James Carter', 'Herbert Hoover', 'Ronald Reagan', 'Franklin Roosevelt', 'George Bush', 'Harry Truman', 'William Clinton', 'Dwight Eisenhower', 'George W. Bush', 'Barack Obama'];
people.sort();

$('input[type=combo]').w2field('combo', { items: people });
/* ☝️ init any combos you have in the page (placed outside of popups).
 */
<link rel="stylesheet" href="http://rawgit.com/vitmalina/w2ui/master/dist/w2ui.min.css"><script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="http://rawgit.com/vitmalina/w2ui/master/dist/w2ui.min.js"></script>
<script src="http://w2ui.com/src/w2ui-1.5.min.js"></script>

<button onclick="openAddSymbolPopup()">w2ui Popup</button>
<hr>
<br>This input should work and so should the one in the popup.
<br>You shouldn't init this one more than once.
<br><input type="combo">
-----------------------
function openAddSymbolPopup() {
    w2popup.open({
        title     : 'Add Symbol',
        body      : '<div style="height: 25px"></div>' +
        '<div class="w2ui-field w2ui-span3">' +
            '<label>Symbol:</label>' +
            '<div> <input type="combo"><span class="legend"></span> </div>' +
        '</div>' +
        '<div style="height: 20px"></div>',
        buttons   : '<button class="w2ui-btn" onclick="w2popup.close();">Close</button> ',
        width     : 300,
        height    : 200,
        overflow  : 'hidden',
        color     : '#333',
        speed     : '0.3',
        opacity   : '0.8',
        modal     : true,
        showClose : false,
    });
    $('input[type=combo]').w2field('combo', { items: people });
   /* ☝️ this input only exists while the popup is open. 
    *    You have to call 
    *    the above function every time you open the popup.
    */
}

var people = ['George Washington', 'John Adams', 'Thomas Jefferson', 'James Buchanan', 'James Madison', 'Abraham Lincoln', 'James Monroe', 'Andrew Johnson', 'John Adams', 'Ulysses Grant', 'Andrew Jackson', 'Rutherford Hayes', 'Martin Van Buren', 'James Garfield', 'William Harrison', 'Chester Arthur', 'John Tyler', 'Grover Cleveland', 'James Polk', 'Benjamin Harrison', 'Zachary Taylor', 'Grover Cleveland', 'Millard Fillmore', 'William McKinley', 'Franklin Pierce', 'Theodore Roosevelt', 'John Kennedy', 'William Howard', 'Lyndon Johnson', 'Woodrow Wilson', 'Richard Nixon', 'Warren Harding', 'Gerald Ford', 'Calvin Coolidge', 'James Carter', 'Herbert Hoover', 'Ronald Reagan', 'Franklin Roosevelt', 'George Bush', 'Harry Truman', 'William Clinton', 'Dwight Eisenhower', 'George W. Bush', 'Barack Obama'];
people.sort();
<link rel="stylesheet" href="http://rawgit.com/vitmalina/w2ui/master/dist/w2ui.min.css"><script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="http://rawgit.com/vitmalina/w2ui/master/dist/w2ui.min.js"></script>
<script src="http://w2ui.com/src/w2ui-1.5.min.js"></script>

<button onclick="openAddSymbolPopup()">w2ui Popup</button>
function openAddSymbolPopup() {
    w2popup.open({
        title     : 'Add Symbol',
        body      : '<div style="height: 25px"></div>' +
        '<div class="w2ui-field w2ui-span3">' +
            '<label>Symbol:</label>' +
            '<div> <input type="combo" id="popup-combo"><span class="legend"></span> </div>' +
        '</div>' +
        '<div style="height: 20px"></div>',
        buttons   : '<button class="w2ui-btn" onclick="w2popup.close();">Close</button> ',
        width     : 300,
        height    : 200,
        overflow  : 'hidden',
        color     : '#333',
        speed     : '0.3',
        opacity   : '0.8',
        modal     : true,
        showClose : false,
    });
    $('#popup-combo').w2field('combo', { items: people });
   /* ☝️ init the combo inside the popup only, every time the popup opens.
    */   
}

var people = ['George Washington', 'John Adams', 'Thomas Jefferson', 'James Buchanan', 'James Madison', 'Abraham Lincoln', 'James Monroe', 'Andrew Johnson', 'John Adams', 'Ulysses Grant', 'Andrew Jackson', 'Rutherford Hayes', 'Martin Van Buren', 'James Garfield', 'William Harrison', 'Chester Arthur', 'John Tyler', 'Grover Cleveland', 'James Polk', 'Benjamin Harrison', 'Zachary Taylor', 'Grover Cleveland', 'Millard Fillmore', 'William McKinley', 'Franklin Pierce', 'Theodore Roosevelt', 'John Kennedy', 'William Howard', 'Lyndon Johnson', 'Woodrow Wilson', 'Richard Nixon', 'Warren Harding', 'Gerald Ford', 'Calvin Coolidge', 'James Carter', 'Herbert Hoover', 'Ronald Reagan', 'Franklin Roosevelt', 'George Bush', 'Harry Truman', 'William Clinton', 'Dwight Eisenhower', 'George W. Bush', 'Barack Obama'];
people.sort();

$('input[type=combo]').w2field('combo', { items: people });
/* ☝️ init any combos you have in the page (placed outside of popups).
 */
<link rel="stylesheet" href="http://rawgit.com/vitmalina/w2ui/master/dist/w2ui.min.css"><script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="http://rawgit.com/vitmalina/w2ui/master/dist/w2ui.min.js"></script>
<script src="http://w2ui.com/src/w2ui-1.5.min.js"></script>

<button onclick="openAddSymbolPopup()">w2ui Popup</button>
<hr>
<br>This input should work and so should the one in the popup.
<br>You shouldn't init this one more than once.
<br><input type="combo">
-----------------------
function openAddSymbolPopup() {
    w2popup.open({
        title     : 'Add Symbol',
        body      : '<div style="height: 25px"></div>' +
        '<div class="w2ui-field w2ui-span3">' +
            '<label>Symbol:</label>' +
            '<div> <input type="combo"><span class="legend"></span> </div>' +
        '</div>' +
        '<div style="height: 20px"></div>',
        buttons   : '<button class="w2ui-btn" onclick="w2popup.close();">Close</button> ',
        width     : 300,
        height    : 200,
        overflow  : 'hidden',
        color     : '#333',
        speed     : '0.3',
        opacity   : '0.8',
        modal     : true,
        showClose : false,
    });
    $('input[type=combo]').w2field('combo', { items: people });
   /* ☝️ this input only exists while the popup is open. 
    *    You have to call 
    *    the above function every time you open the popup.
    */
}

var people = ['George Washington', 'John Adams', 'Thomas Jefferson', 'James Buchanan', 'James Madison', 'Abraham Lincoln', 'James Monroe', 'Andrew Johnson', 'John Adams', 'Ulysses Grant', 'Andrew Jackson', 'Rutherford Hayes', 'Martin Van Buren', 'James Garfield', 'William Harrison', 'Chester Arthur', 'John Tyler', 'Grover Cleveland', 'James Polk', 'Benjamin Harrison', 'Zachary Taylor', 'Grover Cleveland', 'Millard Fillmore', 'William McKinley', 'Franklin Pierce', 'Theodore Roosevelt', 'John Kennedy', 'William Howard', 'Lyndon Johnson', 'Woodrow Wilson', 'Richard Nixon', 'Warren Harding', 'Gerald Ford', 'Calvin Coolidge', 'James Carter', 'Herbert Hoover', 'Ronald Reagan', 'Franklin Roosevelt', 'George Bush', 'Harry Truman', 'William Clinton', 'Dwight Eisenhower', 'George W. Bush', 'Barack Obama'];
people.sort();
<link rel="stylesheet" href="http://rawgit.com/vitmalina/w2ui/master/dist/w2ui.min.css"><script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="http://rawgit.com/vitmalina/w2ui/master/dist/w2ui.min.js"></script>
<script src="http://w2ui.com/src/w2ui-1.5.min.js"></script>

<button onclick="openAddSymbolPopup()">w2ui Popup</button>
function openAddSymbolPopup() {
    w2popup.open({
        title     : 'Add Symbol',
        body      : '<div style="height: 25px"></div>' +
        '<div class="w2ui-field w2ui-span3">' +
            '<label>Symbol:</label>' +
            '<div> <input type="combo" id="popup-combo"><span class="legend"></span> </div>' +
        '</div>' +
        '<div style="height: 20px"></div>',
        buttons   : '<button class="w2ui-btn" onclick="w2popup.close();">Close</button> ',
        width     : 300,
        height    : 200,
        overflow  : 'hidden',
        color     : '#333',
        speed     : '0.3',
        opacity   : '0.8',
        modal     : true,
        showClose : false,
    });
    $('#popup-combo').w2field('combo', { items: people });
   /* ☝️ init the combo inside the popup only, every time the popup opens.
    */   
}

var people = ['George Washington', 'John Adams', 'Thomas Jefferson', 'James Buchanan', 'James Madison', 'Abraham Lincoln', 'James Monroe', 'Andrew Johnson', 'John Adams', 'Ulysses Grant', 'Andrew Jackson', 'Rutherford Hayes', 'Martin Van Buren', 'James Garfield', 'William Harrison', 'Chester Arthur', 'John Tyler', 'Grover Cleveland', 'James Polk', 'Benjamin Harrison', 'Zachary Taylor', 'Grover Cleveland', 'Millard Fillmore', 'William McKinley', 'Franklin Pierce', 'Theodore Roosevelt', 'John Kennedy', 'William Howard', 'Lyndon Johnson', 'Woodrow Wilson', 'Richard Nixon', 'Warren Harding', 'Gerald Ford', 'Calvin Coolidge', 'James Carter', 'Herbert Hoover', 'Ronald Reagan', 'Franklin Roosevelt', 'George Bush', 'Harry Truman', 'William Clinton', 'Dwight Eisenhower', 'George W. Bush', 'Barack Obama'];
people.sort();

$('input[type=combo]').w2field('combo', { items: people });
/* ☝️ init any combos you have in the page (placed outside of popups).
 */
<link rel="stylesheet" href="http://rawgit.com/vitmalina/w2ui/master/dist/w2ui.min.css"><script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="http://rawgit.com/vitmalina/w2ui/master/dist/w2ui.min.js"></script>
<script src="http://w2ui.com/src/w2ui-1.5.min.js"></script>

<button onclick="openAddSymbolPopup()">w2ui Popup</button>
<hr>
<br>This input should work and so should the one in the popup.
<br>You shouldn't init this one more than once.
<br><input type="combo">
-----------------------
function openAddSymbolPopup() {
    w2popup.open({
        title     : 'Add Symbol',
        body      : '<div style="height: 25px"></div>' +
        '<div class="w2ui-field w2ui-span3">' +
            '<label>Symbol:</label>' +
            '<div> <input type="combo"><span class="legend"></span> </div>' +
        '</div>' +
        '<div style="height: 20px"></div>',
        buttons   : '<button class="w2ui-btn" onclick="w2popup.close();">Close</button> ',
        width     : 300,
        height    : 200,
        overflow  : 'hidden',
        color     : '#333',
        speed     : '0.3',
        opacity   : '0.8',
        modal     : true,
        showClose : false,
    });
    $('input[type=combo]').w2field('combo', { items: people });
   /* ☝️ this input only exists while the popup is open. 
    *    You have to call 
    *    the above function every time you open the popup.
    */
}

var people = ['George Washington', 'John Adams', 'Thomas Jefferson', 'James Buchanan', 'James Madison', 'Abraham Lincoln', 'James Monroe', 'Andrew Johnson', 'John Adams', 'Ulysses Grant', 'Andrew Jackson', 'Rutherford Hayes', 'Martin Van Buren', 'James Garfield', 'William Harrison', 'Chester Arthur', 'John Tyler', 'Grover Cleveland', 'James Polk', 'Benjamin Harrison', 'Zachary Taylor', 'Grover Cleveland', 'Millard Fillmore', 'William McKinley', 'Franklin Pierce', 'Theodore Roosevelt', 'John Kennedy', 'William Howard', 'Lyndon Johnson', 'Woodrow Wilson', 'Richard Nixon', 'Warren Harding', 'Gerald Ford', 'Calvin Coolidge', 'James Carter', 'Herbert Hoover', 'Ronald Reagan', 'Franklin Roosevelt', 'George Bush', 'Harry Truman', 'William Clinton', 'Dwight Eisenhower', 'George W. Bush', 'Barack Obama'];
people.sort();
<link rel="stylesheet" href="http://rawgit.com/vitmalina/w2ui/master/dist/w2ui.min.css"><script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="http://rawgit.com/vitmalina/w2ui/master/dist/w2ui.min.js"></script>
<script src="http://w2ui.com/src/w2ui-1.5.min.js"></script>

<button onclick="openAddSymbolPopup()">w2ui Popup</button>
function openAddSymbolPopup() {
    w2popup.open({
        title     : 'Add Symbol',
        body      : '<div style="height: 25px"></div>' +
        '<div class="w2ui-field w2ui-span3">' +
            '<label>Symbol:</label>' +
            '<div> <input type="combo" id="popup-combo"><span class="legend"></span> </div>' +
        '</div>' +
        '<div style="height: 20px"></div>',
        buttons   : '<button class="w2ui-btn" onclick="w2popup.close();">Close</button> ',
        width     : 300,
        height    : 200,
        overflow  : 'hidden',
        color     : '#333',
        speed     : '0.3',
        opacity   : '0.8',
        modal     : true,
        showClose : false,
    });
    $('#popup-combo').w2field('combo', { items: people });
   /* ☝️ init the combo inside the popup only, every time the popup opens.
    */   
}

var people = ['George Washington', 'John Adams', 'Thomas Jefferson', 'James Buchanan', 'James Madison', 'Abraham Lincoln', 'James Monroe', 'Andrew Johnson', 'John Adams', 'Ulysses Grant', 'Andrew Jackson', 'Rutherford Hayes', 'Martin Van Buren', 'James Garfield', 'William Harrison', 'Chester Arthur', 'John Tyler', 'Grover Cleveland', 'James Polk', 'Benjamin Harrison', 'Zachary Taylor', 'Grover Cleveland', 'Millard Fillmore', 'William McKinley', 'Franklin Pierce', 'Theodore Roosevelt', 'John Kennedy', 'William Howard', 'Lyndon Johnson', 'Woodrow Wilson', 'Richard Nixon', 'Warren Harding', 'Gerald Ford', 'Calvin Coolidge', 'James Carter', 'Herbert Hoover', 'Ronald Reagan', 'Franklin Roosevelt', 'George Bush', 'Harry Truman', 'William Clinton', 'Dwight Eisenhower', 'George W. Bush', 'Barack Obama'];
people.sort();

$('input[type=combo]').w2field('combo', { items: people });
/* ☝️ init any combos you have in the page (placed outside of popups).
 */
<link rel="stylesheet" href="http://rawgit.com/vitmalina/w2ui/master/dist/w2ui.min.css"><script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="http://rawgit.com/vitmalina/w2ui/master/dist/w2ui.min.js"></script>
<script src="http://w2ui.com/src/w2ui-1.5.min.js"></script>

<button onclick="openAddSymbolPopup()">w2ui Popup</button>
<hr>
<br>This input should work and so should the one in the popup.
<br>You shouldn't init this one more than once.
<br><input type="combo">

Appending a key:value from one dictionary to another

copy iconCopydownload iconDownload
def intro():    
    print("Hello and welcome to the random questions test")
    global name   
    name = input("what is your name? " + "\n" + "\n")
    if name == "":
        print("Enter a valid name!")
        name = input("what is your name? " + "\n" + "\n")
    else:
        ans2 = input("\n" + "Hello " + name + " Are you sure you want to take the exam? (yes/no)"  + "\n" + "\n")
        if ans2.lower() == "no":
            print("\n" + "aw man, until next time " + name + "!" + "\n")   
        elif ans2.lower() == "yes":
            print("\n" + "Okay!" + "\n")
            ans3 = 'yes'
            while ans3.lower() == 'yes':
                ans3 = Quiz()

def Quiz():
    score = 15 - len(inc_questions)
    i = 0
    while i < len(inc_questions):
        x = inc_questions[i]
        print(Questions[x][0])
        ans = input("> ")
        if ans.lower() == Questions[x][1]:
            print("\n" + "Correct!" + "\n")
            score += 1
            inc_questions.pop(i)
        else:
            print("\n" + "Incorrect!" + "\n")
            i +=1
   
    if score == 15: 
        print("Congratulations " + name + ", you scored a perfect 15/15!")
    elif score < 15 and score > 11:
        print("Good job " + name + "! you got " + str(score) + " out of 15 correct!")
    elif score < 12 and score > 8:
        print("You did pretty well " + name + ", you got " + str(score) + " out of 15 correct!")
    elif score < 9 and score > 5:
        print("Unfortunately " + name + " you did not pass, you got " + str(score) + " out of 15 correct!")
    elif score < 6 and score > 0:
        print("Jeez " + name + " you did awful lol, you got " + str(score) + " out of 15 correct!")
    elif score == 0:
        print("Oh lord " + name +" you need some serious help you got nothing right!")

    if score == 0:
        print("\n" + "Would you like a retake?" + "\n")
        ans1 = input("> ")
    elif score < 15:
        print("\n" + "Would you like to retake the questions that were incorrect?" + "\n")
        ans1 = input("> ")
    else: ans1 = ''
    
    return ans1

q1 = """Who holds the NFL record for the most receiving yards in a single game?
        a.  Calvin Johnson
        b.  Deandre Hopkins
        c.  Flipper Anderson
        d.  Jerry Rice"""
q2 = """In what year was the eiffel tower built?
        a.  1492
        b.  1889
        c.  2013
        d.  1766"""
q3 = """How many countries are in the world today?
        a.  205
        b.  195
        c.  673
        d.  142"""
q4 = """Who is the CEO of apple currently (2020)?
        a.  Tim Cook
        b.  Sergio Kitchens
        c.  Daniel Johnson
        d.  Steve Jobs"""
q5 = """who is the 23rd president of the united states?
        a.  Grover Cleveland 
        b.  Andrew Jackson
        c.  Anderson Berkshire
        d.  Benjamin Harrison"""
q6 = """X + 5x - 10 = 500... What does X equal?
        a.  85
        b.  84
        c.  102
        d.  0"""
q7 = """Who is currently the richest person on earth?
        a.  Tim Cook
        b.  Jeff Bezos
        c.  Bill Gates
        d.  Bill Nye"""
q8 = """When was Howard University Established?
        a.  May 4, 2002
        b.  March 5, 1855
        c.  September 1, 1844
        d.  March 2, 1867"""
q9 = """What can you catch but not throw?
        a.  A football
        b.  A conversation
        c.  A cold
        d.  A tennis ball in the Appalachian Mountains"""
q10 = """Which country is responsible for the production of 95% of the worlds opal stones?
        a.  Brazil 
        b.  Mexico
        c.  Honduras
        d.  Austrailia"""
q11 = """How many species of Toothed and Baleen whales exist?
        a.  14 and 2
        b.  76 and 14
        c.  5 and 10
        d.  75,000"""
q12 = """Who holds the world record for the most chicken nuggets eaten in 1 hour?
        a.  Naader Reda
        b.  Nicolo Reda
        c.  Stefano Neder
        d.  Josh Jacobs"""
q13 = """Who invented the bessemer process?
        a.  Henry Bessemer 
        b.  Markus Bessemer
        c.  Bessemer Robinson
        d.  Anakin Skywalker"""
q14 = """When was Mortal Kombat 6 released?
        a.  April 1, 2002
        b.  August 15, 2007
        c.  October 4, 2004
        d.  December 25, 2006"""
q15 = """In which City located in the USA is it illegal to say "Oh, boy"?
        a.  Denver, Colorado  
        b.  Lexington, Kentucky
        c.  Jonesboro, Georgia
        d.  Wilbur, Washington"""

Questions = [(q1,'c'),  (q2,'b'),  (q3,'b'), (q4,'a'),  (q5,'d'),  (q6,'a'),
             (q7,'b'),  (q8,'d'),  (q9,'c'), (q10,'d'), (q11,'b'), (q12,'a'),
             (q13,'a'), (q14,'c'), (q15,'c')]

inc_questions = [i for i in range(15)]

intro()
In which City located in the USA is it illegal to say "Oh, boy"?
        a.  Denver, Colorado  
        b.  Lexington, Kentucky
        c.  Jonesboro, Georgia
        d.  Wilbur, Washington
> a

Incorrect!

Jeez Joe you did awful lol, you got 5 out of 15 correct!

Would you like to retake the questions that were incorrect?

> yes
Who holds the NFL record for the most receiving yards in a single game?
        a.  Calvin Johnson
        b.  Deandre Hopkins
        c.  Flipper Anderson
        d.  Jerry Rice
> a

Incorrect!

Who is the CEO of apple currently (2020)?
        a.  Tim Cook
        b.  Sergio Kitchens
        c.  Daniel Johnson
        d.  Steve Jobs
> a

Correct!

who is the 23rd president of the united states?
        a.  Grover Cleveland 
        b.  Andrew Jackson
        c.  Anderson Berkshire
        d.  Benjamin Harrison
> a

Incorrect!

Who is currently the richest person on earth?
        a.  Tim Cook
        b.  Jeff Bezos
        c.  Bill Gates
        d.  Bill Nye
> 
When was Mortal Kombat 6 released?
        a.  April 1, 2002
        b.  August 15, 2007
        c.  October 4, 2004
        d.  December 25, 2006
> c

Correct!

In which City located in the USA is it illegal to say "Oh, boy"?
        a.  Denver, Colorado  
        b.  Lexington, Kentucky
        c.  Jonesboro, Georgia
        d.  Wilbur, Washington
> b

Incorrect!

You did pretty well Joe, you got 10 out of 15 correct!

Would you like to retake the questions that were incorrect?

> no
>>> 
-----------------------
def intro():    
    print("Hello and welcome to the random questions test")
    global name   
    name = input("what is your name? " + "\n" + "\n")
    if name == "":
        print("Enter a valid name!")
        name = input("what is your name? " + "\n" + "\n")
    else:
        ans2 = input("\n" + "Hello " + name + " Are you sure you want to take the exam? (yes/no)"  + "\n" + "\n")
        if ans2.lower() == "no":
            print("\n" + "aw man, until next time " + name + "!" + "\n")   
        elif ans2.lower() == "yes":
            print("\n" + "Okay!" + "\n")
            ans3 = 'yes'
            while ans3.lower() == 'yes':
                ans3 = Quiz()

def Quiz():
    score = 15 - len(inc_questions)
    i = 0
    while i < len(inc_questions):
        x = inc_questions[i]
        print(Questions[x][0])
        ans = input("> ")
        if ans.lower() == Questions[x][1]:
            print("\n" + "Correct!" + "\n")
            score += 1
            inc_questions.pop(i)
        else:
            print("\n" + "Incorrect!" + "\n")
            i +=1
   
    if score == 15: 
        print("Congratulations " + name + ", you scored a perfect 15/15!")
    elif score < 15 and score > 11:
        print("Good job " + name + "! you got " + str(score) + " out of 15 correct!")
    elif score < 12 and score > 8:
        print("You did pretty well " + name + ", you got " + str(score) + " out of 15 correct!")
    elif score < 9 and score > 5:
        print("Unfortunately " + name + " you did not pass, you got " + str(score) + " out of 15 correct!")
    elif score < 6 and score > 0:
        print("Jeez " + name + " you did awful lol, you got " + str(score) + " out of 15 correct!")
    elif score == 0:
        print("Oh lord " + name +" you need some serious help you got nothing right!")

    if score == 0:
        print("\n" + "Would you like a retake?" + "\n")
        ans1 = input("> ")
    elif score < 15:
        print("\n" + "Would you like to retake the questions that were incorrect?" + "\n")
        ans1 = input("> ")
    else: ans1 = ''
    
    return ans1

q1 = """Who holds the NFL record for the most receiving yards in a single game?
        a.  Calvin Johnson
        b.  Deandre Hopkins
        c.  Flipper Anderson
        d.  Jerry Rice"""
q2 = """In what year was the eiffel tower built?
        a.  1492
        b.  1889
        c.  2013
        d.  1766"""
q3 = """How many countries are in the world today?
        a.  205
        b.  195
        c.  673
        d.  142"""
q4 = """Who is the CEO of apple currently (2020)?
        a.  Tim Cook
        b.  Sergio Kitchens
        c.  Daniel Johnson
        d.  Steve Jobs"""
q5 = """who is the 23rd president of the united states?
        a.  Grover Cleveland 
        b.  Andrew Jackson
        c.  Anderson Berkshire
        d.  Benjamin Harrison"""
q6 = """X + 5x - 10 = 500... What does X equal?
        a.  85
        b.  84
        c.  102
        d.  0"""
q7 = """Who is currently the richest person on earth?
        a.  Tim Cook
        b.  Jeff Bezos
        c.  Bill Gates
        d.  Bill Nye"""
q8 = """When was Howard University Established?
        a.  May 4, 2002
        b.  March 5, 1855
        c.  September 1, 1844
        d.  March 2, 1867"""
q9 = """What can you catch but not throw?
        a.  A football
        b.  A conversation
        c.  A cold
        d.  A tennis ball in the Appalachian Mountains"""
q10 = """Which country is responsible for the production of 95% of the worlds opal stones?
        a.  Brazil 
        b.  Mexico
        c.  Honduras
        d.  Austrailia"""
q11 = """How many species of Toothed and Baleen whales exist?
        a.  14 and 2
        b.  76 and 14
        c.  5 and 10
        d.  75,000"""
q12 = """Who holds the world record for the most chicken nuggets eaten in 1 hour?
        a.  Naader Reda
        b.  Nicolo Reda
        c.  Stefano Neder
        d.  Josh Jacobs"""
q13 = """Who invented the bessemer process?
        a.  Henry Bessemer 
        b.  Markus Bessemer
        c.  Bessemer Robinson
        d.  Anakin Skywalker"""
q14 = """When was Mortal Kombat 6 released?
        a.  April 1, 2002
        b.  August 15, 2007
        c.  October 4, 2004
        d.  December 25, 2006"""
q15 = """In which City located in the USA is it illegal to say "Oh, boy"?
        a.  Denver, Colorado  
        b.  Lexington, Kentucky
        c.  Jonesboro, Georgia
        d.  Wilbur, Washington"""

Questions = [(q1,'c'),  (q2,'b'),  (q3,'b'), (q4,'a'),  (q5,'d'),  (q6,'a'),
             (q7,'b'),  (q8,'d'),  (q9,'c'), (q10,'d'), (q11,'b'), (q12,'a'),
             (q13,'a'), (q14,'c'), (q15,'c')]

inc_questions = [i for i in range(15)]

intro()
In which City located in the USA is it illegal to say "Oh, boy"?
        a.  Denver, Colorado  
        b.  Lexington, Kentucky
        c.  Jonesboro, Georgia
        d.  Wilbur, Washington
> a

Incorrect!

Jeez Joe you did awful lol, you got 5 out of 15 correct!

Would you like to retake the questions that were incorrect?

> yes
Who holds the NFL record for the most receiving yards in a single game?
        a.  Calvin Johnson
        b.  Deandre Hopkins
        c.  Flipper Anderson
        d.  Jerry Rice
> a

Incorrect!

Who is the CEO of apple currently (2020)?
        a.  Tim Cook
        b.  Sergio Kitchens
        c.  Daniel Johnson
        d.  Steve Jobs
> a

Correct!

who is the 23rd president of the united states?
        a.  Grover Cleveland 
        b.  Andrew Jackson
        c.  Anderson Berkshire
        d.  Benjamin Harrison
> a

Incorrect!

Who is currently the richest person on earth?
        a.  Tim Cook
        b.  Jeff Bezos
        c.  Bill Gates
        d.  Bill Nye
> 
When was Mortal Kombat 6 released?
        a.  April 1, 2002
        b.  August 15, 2007
        c.  October 4, 2004
        d.  December 25, 2006
> c

Correct!

In which City located in the USA is it illegal to say "Oh, boy"?
        a.  Denver, Colorado  
        b.  Lexington, Kentucky
        c.  Jonesboro, Georgia
        d.  Wilbur, Washington
> b

Incorrect!

You did pretty well Joe, you got 10 out of 15 correct!

Would you like to retake the questions that were incorrect?

> no
>>> 
-----------------------
def intro():    
    print("Hello and welcome to the random questions test")
    global name   
    name = input("what is your name? " + "\n" + "\n")
    if name == "":
        print("Enter a valid name!")
        name = input("what is your name? " + "\n" + "\n")
    else:
        ans2 = input("\n" + "Hello " + name + " Are you sure you want to take the exam? (yes/no)"  + "\n" + "\n")
        if ans2.lower() == "no":
            print("\n" + "aw man, until next time " + name + "!" + "\n")   
        elif ans2.lower() == "yes":
            print("\n" + "Okay!" + "\n")
            ans3 = 'yes'
            while ans3.lower() == 'yes':
                ans3 = Quiz()

def Quiz():
    score = 15 - len(inc_questions)
    i = 0
    while i < len(inc_questions):
        x = inc_questions[i]
        print(Questions[x][0])
        ans = input("> ")
        if ans.lower() == Questions[x][1]:
            print("\n" + "Correct!" + "\n")
            score += 1
            inc_questions.pop(i)
        else:
            print("\n" + "Incorrect!" + "\n")
            i +=1
   
    if score == 15: 
        print("Congratulations " + name + ", you scored a perfect 15/15!")
    elif score < 15 and score > 11:
        print("Good job " + name + "! you got " + str(score) + " out of 15 correct!")
    elif score < 12 and score > 8:
        print("You did pretty well " + name + ", you got " + str(score) + " out of 15 correct!")
    elif score < 9 and score > 5:
        print("Unfortunately " + name + " you did not pass, you got " + str(score) + " out of 15 correct!")
    elif score < 6 and score > 0:
        print("Jeez " + name + " you did awful lol, you got " + str(score) + " out of 15 correct!")
    elif score == 0:
        print("Oh lord " + name +" you need some serious help you got nothing right!")

    if score == 0:
        print("\n" + "Would you like a retake?" + "\n")
        ans1 = input("> ")
    elif score < 15:
        print("\n" + "Would you like to retake the questions that were incorrect?" + "\n")
        ans1 = input("> ")
    else: ans1 = ''
    
    return ans1

q1 = """Who holds the NFL record for the most receiving yards in a single game?
        a.  Calvin Johnson
        b.  Deandre Hopkins
        c.  Flipper Anderson
        d.  Jerry Rice"""
q2 = """In what year was the eiffel tower built?
        a.  1492
        b.  1889
        c.  2013
        d.  1766"""
q3 = """How many countries are in the world today?
        a.  205
        b.  195
        c.  673
        d.  142"""
q4 = """Who is the CEO of apple currently (2020)?
        a.  Tim Cook
        b.  Sergio Kitchens
        c.  Daniel Johnson
        d.  Steve Jobs"""
q5 = """who is the 23rd president of the united states?
        a.  Grover Cleveland 
        b.  Andrew Jackson
        c.  Anderson Berkshire
        d.  Benjamin Harrison"""
q6 = """X + 5x - 10 = 500... What does X equal?
        a.  85
        b.  84
        c.  102
        d.  0"""
q7 = """Who is currently the richest person on earth?
        a.  Tim Cook
        b.  Jeff Bezos
        c.  Bill Gates
        d.  Bill Nye"""
q8 = """When was Howard University Established?
        a.  May 4, 2002
        b.  March 5, 1855
        c.  September 1, 1844
        d.  March 2, 1867"""
q9 = """What can you catch but not throw?
        a.  A football
        b.  A conversation
        c.  A cold
        d.  A tennis ball in the Appalachian Mountains"""
q10 = """Which country is responsible for the production of 95% of the worlds opal stones?
        a.  Brazil 
        b.  Mexico
        c.  Honduras
        d.  Austrailia"""
q11 = """How many species of Toothed and Baleen whales exist?
        a.  14 and 2
        b.  76 and 14
        c.  5 and 10
        d.  75,000"""
q12 = """Who holds the world record for the most chicken nuggets eaten in 1 hour?
        a.  Naader Reda
        b.  Nicolo Reda
        c.  Stefano Neder
        d.  Josh Jacobs"""
q13 = """Who invented the bessemer process?
        a.  Henry Bessemer 
        b.  Markus Bessemer
        c.  Bessemer Robinson
        d.  Anakin Skywalker"""
q14 = """When was Mortal Kombat 6 released?
        a.  April 1, 2002
        b.  August 15, 2007
        c.  October 4, 2004
        d.  December 25, 2006"""
q15 = """In which City located in the USA is it illegal to say "Oh, boy"?
        a.  Denver, Colorado  
        b.  Lexington, Kentucky
        c.  Jonesboro, Georgia
        d.  Wilbur, Washington"""

Questions = [(q1,'c'),  (q2,'b'),  (q3,'b'), (q4,'a'),  (q5,'d'),  (q6,'a'),
             (q7,'b'),  (q8,'d'),  (q9,'c'), (q10,'d'), (q11,'b'), (q12,'a'),
             (q13,'a'), (q14,'c'), (q15,'c')]

inc_questions = [i for i in range(15)]

intro()
In which City located in the USA is it illegal to say "Oh, boy"?
        a.  Denver, Colorado  
        b.  Lexington, Kentucky
        c.  Jonesboro, Georgia
        d.  Wilbur, Washington
> a

Incorrect!

Jeez Joe you did awful lol, you got 5 out of 15 correct!

Would you like to retake the questions that were incorrect?

> yes
Who holds the NFL record for the most receiving yards in a single game?
        a.  Calvin Johnson
        b.  Deandre Hopkins
        c.  Flipper Anderson
        d.  Jerry Rice
> a

Incorrect!

Who is the CEO of apple currently (2020)?
        a.  Tim Cook
        b.  Sergio Kitchens
        c.  Daniel Johnson
        d.  Steve Jobs
> a

Correct!

who is the 23rd president of the united states?
        a.  Grover Cleveland 
        b.  Andrew Jackson
        c.  Anderson Berkshire
        d.  Benjamin Harrison
> a

Incorrect!

Who is currently the richest person on earth?
        a.  Tim Cook
        b.  Jeff Bezos
        c.  Bill Gates
        d.  Bill Nye
> 
When was Mortal Kombat 6 released?
        a.  April 1, 2002
        b.  August 15, 2007
        c.  October 4, 2004
        d.  December 25, 2006
> c

Correct!

In which City located in the USA is it illegal to say "Oh, boy"?
        a.  Denver, Colorado  
        b.  Lexington, Kentucky
        c.  Jonesboro, Georgia
        d.  Wilbur, Washington
> b

Incorrect!

You did pretty well Joe, you got 10 out of 15 correct!

Would you like to retake the questions that were incorrect?

> no
>>> 

Map List of objects from a Json response to a List in flutter

copy iconCopydownload iconDownload
List<AllMealPlanModel> allMealPlanModelFromJson(String str) =>
List<AllMealPlanModel>.from(
    json.decode(str).map((x) => AllMealPlanModel.fromJson(x)));

http.Response response = http.Response(jsonString, 200);
    if (response.statusCode == 200) {
      return allMealPlanModelFromJson(response.body);
    }
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';

List<AllMealPlanModel> allMealPlanModelFromJson(String str) =>
    List<AllMealPlanModel>.from(
        json.decode(str).map((x) => AllMealPlanModel.fromJson(x)));

String allMealPlanModelToJson(List<AllMealPlanModel> data) =>
    json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

class AllMealPlanModel {
  AllMealPlanModel({
    this.id,
    this.dailyAllowanceActualPercentage,
    this.dailyCaloriesFromThisMealPlan,
    this.imperialWeightOfOneMeal,
    this.mealIngredientsWouldMake,
    this.mealsPerDay,
    this.nutrientValue,
    this.petName,
    this.showWeightOfBalancedMeal,
    this.suggestion,
    this.totalCaloriesInAMealPlan,
    this.totalImperialWeightOfAMealPlan,
    this.totalWeightOfAMealPlan,
    this.weightOfOneMeal,
    this.feedingPlanDetails,
  });

  int id;
  DailyAllowanceActualPercentage dailyAllowanceActualPercentage;
  double dailyCaloriesFromThisMealPlan;
  double imperialWeightOfOneMeal;
  int mealIngredientsWouldMake;
  int mealsPerDay;
  List<NutrientValue> nutrientValue;
  String petName;
  bool showWeightOfBalancedMeal;
  Suggestion suggestion;
  int totalCaloriesInAMealPlan;
  double totalImperialWeightOfAMealPlan;
  int totalWeightOfAMealPlan;
  double weightOfOneMeal;
  List<FeedingPlanDetail> feedingPlanDetails;

  factory AllMealPlanModel.fromJson(Map<String, dynamic> json) =>
      AllMealPlanModel(
        id: json["id"],
        dailyAllowanceActualPercentage: DailyAllowanceActualPercentage.fromJson(
            json["daily_allowance_actual_percentage"]),
        dailyCaloriesFromThisMealPlan:
            json["daily_calories_from_this_meal_plan"].toDouble(),
        imperialWeightOfOneMeal: json["imperial_weight_of_one_meal"].toDouble(),
        mealIngredientsWouldMake: json["meal_ingredients_would_make"],
        mealsPerDay: json["meals_per_day"],
        nutrientValue: List<NutrientValue>.from(
            json["nutrient_value"].map((x) => NutrientValue.fromJson(x))),
        petName: json["pet_name"],
        showWeightOfBalancedMeal: json["show_weight_of_balanced_meal"],
        suggestion: Suggestion.fromJson(json["suggestion"]),
        totalCaloriesInAMealPlan: json["total_calories_in_a_meal_plan"],
        totalImperialWeightOfAMealPlan:
            json["total_imperial_weight_of_a_meal_plan"].toDouble(),
        totalWeightOfAMealPlan: json["total_weight_of_a_meal_plan"],
        weightOfOneMeal: json["weight_of_one_meal"].toDouble(),
        feedingPlanDetails: List<FeedingPlanDetail>.from(
            json["feeding_plan_details"]
                .map((x) => FeedingPlanDetail.fromJson(x))),
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "daily_allowance_actual_percentage":
            dailyAllowanceActualPercentage.toJson(),
        "daily_calories_from_this_meal_plan": dailyCaloriesFromThisMealPlan,
        "imperial_weight_of_one_meal": imperialWeightOfOneMeal,
        "meal_ingredients_would_make": mealIngredientsWouldMake,
        "meals_per_day": mealsPerDay,
        "nutrient_value":
            List<dynamic>.from(nutrientValue.map((x) => x.toJson())),
        "pet_name": petName,
        "show_weight_of_balanced_meal": showWeightOfBalancedMeal,
        "suggestion": suggestion.toJson(),
        "total_calories_in_a_meal_plan": totalCaloriesInAMealPlan,
        "total_imperial_weight_of_a_meal_plan": totalImperialWeightOfAMealPlan,
        "total_weight_of_a_meal_plan": totalWeightOfAMealPlan,
        "weight_of_one_meal": weightOfOneMeal,
        "feeding_plan_details":
            List<dynamic>.from(feedingPlanDetails.map((x) => x.toJson())),
      };
}

class DailyAllowanceActualPercentage {
  DailyAllowanceActualPercentage({
    this.bone,
    this.muscleMeat,
    this.fruitAndVeg,
  });

  List<dynamic> bone;
  List<dynamic> muscleMeat;
  List<dynamic> fruitAndVeg;

  factory DailyAllowanceActualPercentage.fromJson(Map<String, dynamic> json) =>
      DailyAllowanceActualPercentage(
        bone: List<dynamic>.from(json["Bone"].map((x) => x)),
        muscleMeat: List<dynamic>.from(json["Muscle Meat"].map((x) => x)),
        fruitAndVeg: List<dynamic>.from(json["Fruit and Veg"].map((x) => x)),
      );

  Map<String, dynamic> toJson() => {
        "Bone": List<dynamic>.from(bone.map((x) => x)),
        "Muscle Meat": List<dynamic>.from(muscleMeat.map((x) => x)),
        "Fruit and Veg": List<dynamic>.from(fruitAndVeg.map((x) => x)),
      };
}

class FeedingPlanDetail {
  FeedingPlanDetail({
    this.id,
    this.imperialQuantity,
    this.quantity,
    this.food,
  });

  int id;
  double imperialQuantity;
  int quantity;
  Food food;

  factory FeedingPlanDetail.fromJson(Map<String, dynamic> json) =>
      FeedingPlanDetail(
        id: json["id"],
        imperialQuantity: json["imperial_quantity"].toDouble(),
        quantity: json["quantity"],
        food: Food.fromJson(json["food"]),
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "imperial_quantity": imperialQuantity,
        "quantity": quantity,
        "food": food.toJson(),
      };
}

class Food {
  Food({
    this.id,
    this.bonePercentage,
    this.calciumPhosphorousRatio,
    this.name,
    this.omegaRatio,
    this.omegaRatioColor,
    this.calciumPhosphorousRatioColor,
  });

  int id;
  int bonePercentage;
  double calciumPhosphorousRatio;
  String name;
  double omegaRatio;
  String omegaRatioColor;
  String calciumPhosphorousRatioColor;

  factory Food.fromJson(Map<String, dynamic> json) => Food(
        id: json["id"],
        bonePercentage: json["bone_percentage"],
        calciumPhosphorousRatio: json["calcium_phosphorous_ratio"].toDouble(),
        name: json["name"],
        omegaRatio: json["omega_ratio"].toDouble(),
        omegaRatioColor: json["omega_ratio_color"],
        calciumPhosphorousRatioColor: json["calcium_phosphorous_ratio_color"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "bone_percentage": bonePercentage,
        "calcium_phosphorous_ratio": calciumPhosphorousRatio,
        "name": name,
        "omega_ratio": omegaRatio,
        "omega_ratio_color": omegaRatioColor,
        "calcium_phosphorous_ratio_color": calciumPhosphorousRatioColor,
      };
}

class NutrientValue {
  NutrientValue({
    this.calcium,
    this.choline,
    this.copper,
    this.crudeFat,
    this.folate,
    this.iodine,
    this.iron,
    this.magnesium,
    this.manganese,
    this.niacinB3,
    this.omega3ExclAlaAndSda,
    this.omega6,
    this.pantothenicAcidB5,
    this.phosphorus,
    this.potassium,
    this.protein,
    this.riboflavinB2,
    this.selenium,
    this.sodiumNa,
    this.thiaminB1,
    this.vitaminA,
    this.vitaminC,
    this.vitaminD,
    this.vitaminE,
    this.zincZn,
    this.calories,
  });

  List<dynamic> calcium;
  List<dynamic> choline;
  List<dynamic> copper;
  List<dynamic> crudeFat;
  List<dynamic> folate;
  List<dynamic> iodine;
  List<dynamic> iron;
  List<dynamic> magnesium;
  List<dynamic> manganese;
  List<dynamic> niacinB3;
  List<dynamic> omega3ExclAlaAndSda;
  List<dynamic> omega6;
  List<dynamic> pantothenicAcidB5;
  List<dynamic> phosphorus;
  List<dynamic> potassium;
  List<dynamic> protein;
  List<dynamic> riboflavinB2;
  List<dynamic> selenium;
  List<dynamic> sodiumNa;
  List<dynamic> thiaminB1;
  List<dynamic> vitaminA;
  List<dynamic> vitaminC;
  List<dynamic> vitaminD;
  List<dynamic> vitaminE;
  List<dynamic> zincZn;
  List<dynamic> calories;

  factory NutrientValue.fromJson(Map<String, dynamic> json) => NutrientValue(
        calcium: json["Calcium"] == null
            ? null
            : List<dynamic>.from(json["Calcium"].map((x) => x)),
        choline: json["Choline"] == null
            ? null
            : List<dynamic>.from(json["Choline"].map((x) => x)),
        copper: json["Copper"] == null
            ? null
            : List<dynamic>.from(json["Copper"].map((x) => x)),
        crudeFat: json["Crude fat"] == null
            ? null
            : List<dynamic>.from(json["Crude fat"].map((x) => x)),
        folate: json["Folate"] == null
            ? null
            : List<dynamic>.from(json["Folate"].map((x) => x)),
        iodine: json["Iodine"] == null
            ? null
            : List<dynamic>.from(json["Iodine"].map((x) => x)),
        iron: json["Iron"] == null
            ? null
            : List<dynamic>.from(json["Iron"].map((x) => x)),
        magnesium: json["Magnesium"] == null
            ? null
            : List<dynamic>.from(json["Magnesium"].map((x) => x)),
        manganese: json["Manganese"] == null
            ? null
            : List<dynamic>.from(json["Manganese"].map((x) => x)),
        niacinB3: json["Niacin (B3)"] == null
            ? null
            : List<dynamic>.from(json["Niacin (B3)"].map((x) => x)),
        omega3ExclAlaAndSda: json["Omega-3 excl. ALA and SDA"] == null
            ? null
            : List<dynamic>.from(
                json["Omega-3 excl. ALA and SDA"].map((x) => x)),
        omega6: json["Omega-6"] == null
            ? null
            : List<dynamic>.from(json["Omega-6"].map((x) => x)),
        pantothenicAcidB5: json["Pantothenic acid (B5)"] == null
            ? null
            : List<dynamic>.from(json["Pantothenic acid (B5)"].map((x) => x)),
        phosphorus: json["Phosphorus"] == null
            ? null
            : List<dynamic>.from(json["Phosphorus"].map((x) => x)),
        potassium: json["Potassium"] == null
            ? null
            : List<dynamic>.from(json["Potassium"].map((x) => x)),
        protein: json["Protein"] == null
            ? null
            : List<dynamic>.from(json["Protein"].map((x) => x)),
        riboflavinB2: json["Riboflavin (B2)"] == null
            ? null
            : List<dynamic>.from(json["Riboflavin (B2)"].map((x) => x)),
        selenium: json["Selenium"] == null
            ? null
            : List<dynamic>.from(json["Selenium"].map((x) => x)),
        sodiumNa: json["Sodium (Na)"] == null
            ? null
            : List<dynamic>.from(json["Sodium (Na)"].map((x) => x)),
        thiaminB1: json["Thiamin (B1)"] == null
            ? null
            : List<dynamic>.from(json["Thiamin (B1)"].map((x) => x)),
        vitaminA: json["Vitamin A"] == null
            ? null
            : List<dynamic>.from(json["Vitamin A"].map((x) => x)),
        vitaminC: json["Vitamin C"] == null
            ? null
            : List<dynamic>.from(json["Vitamin C"].map((x) => x)),
        vitaminD: json["Vitamin D"] == null
            ? null
            : List<dynamic>.from(json["Vitamin D"].map((x) => x)),
        vitaminE: json["Vitamin E"] == null
            ? null
            : List<dynamic>.from(json["Vitamin E"].map((x) => x)),
        zincZn: json["Zinc (Zn)"] == null
            ? null
            : List<dynamic>.from(json["Zinc (Zn)"].map((x) => x)),
        calories: json["Calories"] == null
            ? null
            : List<dynamic>.from(json["Calories"].map((x) => x)),
      );

  Map<String, dynamic> toJson() => {
        "Calcium":
            calcium == null ? null : List<dynamic>.from(calcium.map((x) => x)),
        "Choline":
            choline == null ? null : List<dynamic>.from(choline.map((x) => x)),
        "Copper":
            copper == null ? null : List<dynamic>.from(copper.map((x) => x)),
        "Crude fat": crudeFat == null
            ? null
            : List<dynamic>.from(crudeFat.map((x) => x)),
        "Folate":
            folate == null ? null : List<dynamic>.from(folate.map((x) => x)),
        "Iodine":
            iodine == null ? null : List<dynamic>.from(iodine.map((x) => x)),
        "Iron": iron == null ? null : List<dynamic>.from(iron.map((x) => x)),
        "Magnesium": magnesium == null
            ? null
            : List<dynamic>.from(magnesium.map((x) => x)),
        "Manganese": manganese == null
            ? null
            : List<dynamic>.from(manganese.map((x) => x)),
        "Niacin (B3)": niacinB3 == null
            ? null
            : List<dynamic>.from(niacinB3.map((x) => x)),
        "Omega-3 excl. ALA and SDA": omega3ExclAlaAndSda == null
            ? null
            : List<dynamic>.from(omega3ExclAlaAndSda.map((x) => x)),
        "Omega-6":
            omega6 == null ? null : List<dynamic>.from(omega6.map((x) => x)),
        "Pantothenic acid (B5)": pantothenicAcidB5 == null
            ? null
            : List<dynamic>.from(pantothenicAcidB5.map((x) => x)),
        "Phosphorus": phosphorus == null
            ? null
            : List<dynamic>.from(phosphorus.map((x) => x)),
        "Potassium": potassium == null
            ? null
            : List<dynamic>.from(potassium.map((x) => x)),
        "Protein":
            protein == null ? null : List<dynamic>.from(protein.map((x) => x)),
        "Riboflavin (B2)": riboflavinB2 == null
            ? null
            : List<dynamic>.from(riboflavinB2.map((x) => x)),
        "Selenium": selenium == null
            ? null
            : List<dynamic>.from(selenium.map((x) => x)),
        "Sodium (Na)": sodiumNa == null
            ? null
            : List<dynamic>.from(sodiumNa.map((x) => x)),
        "Thiamin (B1)": thiaminB1 == null
            ? null
            : List<dynamic>.from(thiaminB1.map((x) => x)),
        "Vitamin A": vitaminA == null
            ? null
            : List<dynamic>.from(vitaminA.map((x) => x)),
        "Vitamin C": vitaminC == null
            ? null
            : List<dynamic>.from(vitaminC.map((x) => x)),
        "Vitamin D": vitaminD == null
            ? null
            : List<dynamic>.from(vitaminD.map((x) => x)),
        "Vitamin E": vitaminE == null
            ? null
            : List<dynamic>.from(vitaminE.map((x) => x)),
        "Zinc (Zn)":
            zincZn == null ? null : List<dynamic>.from(zincZn.map((x) => x)),
        "Calories": calories == null
            ? null
            : List<dynamic>.from(calories.map((x) => x)),
      };
}

class Suggestion {
  Suggestion({
    this.addFood,
    this.removeFood,
  });

  AddFood addFood;
  RemoveFood removeFood;

  factory Suggestion.fromJson(Map<String, dynamic> json) => Suggestion(
        addFood: AddFood.fromJson(json["add_food"]),
        removeFood: RemoveFood.fromJson(json["remove_food"]),
      );

  Map<String, dynamic> toJson() => {
        "add_food": addFood.toJson(),
        "remove_food": removeFood.toJson(),
      };
}

class AddFood {
  AddFood({
    this.yellow,
    this.red,
  });

  List<Yellow> yellow;
  List<Map<String, List<String>>> red;

  factory AddFood.fromJson(Map<String, dynamic> json) => AddFood(
        yellow:
            List<Yellow>.from(json["Yellow"].map((x) => Yellow.fromJson(x))),
        red: List<Map<String, List<String>>>.from(json["Red"].map((x) =>
            Map.from(x).map((k, v) => MapEntry<String, List<String>>(
                k, List<String>.from(v.map((x) => x)))))),
      );

  Map<String, dynamic> toJson() => {
        "Yellow": List<dynamic>.from(yellow.map((x) => x.toJson())),
        "Red": List<dynamic>.from(red.map((x) => Map.from(x).map((k, v) =>
            MapEntry<String, dynamic>(
                k, List<dynamic>.from(v.map((x) => x)))))),
      };
}

class Yellow {
  Yellow({
    this.calcium,
    this.phosphorus,
  });

  List<String> calcium;
  List<String> phosphorus;

  factory Yellow.fromJson(Map<String, dynamic> json) => Yellow(
        calcium: json["Calcium"] == null
            ? null
            : List<String>.from(json["Calcium"].map((x) => x)),
        phosphorus: json["Phosphorus"] == null
            ? null
            : List<String>.from(json["Phosphorus"].map((x) => x)),
      );

  Map<String, dynamic> toJson() => {
        "Calcium":
            calcium == null ? null : List<dynamic>.from(calcium.map((x) => x)),
        "Phosphorus": phosphorus == null
            ? null
            : List<dynamic>.from(phosphorus.map((x) => x)),
      };
}

class RemoveFood {
  RemoveFood({
    this.yellow,
    this.red,
  });

  List<dynamic> yellow;
  List<Red> red;

  factory RemoveFood.fromJson(Map<String, dynamic> json) => RemoveFood(
        yellow: List<dynamic>.from(json["Yellow"].map((x) => x)),
        red: List<Red>.from(json["Red"].map((x) => Red.fromJson(x))),
      );

  Map<String, dynamic> toJson() => {
        "Yellow": List<dynamic>.from(yellow.map((x) => x)),
        "Red": List<dynamic>.from(red.map((x) => x.toJson())),
      };
}

class Red {
  Red({
    this.magnesium,
    this.potassium,
    this.selenium,
  });

  List<String> magnesium;
  List<String> potassium;
  List<String> selenium;

  factory Red.fromJson(Map<String, dynamic> json) => Red(
        magnesium: json["Magnesium"] == null
            ? null
            : List<String>.from(json["Magnesium"].map((x) => x)),
        potassium: json["Potassium"] == null
            ? null
            : List<String>.from(json["Potassium"].map((x) => x)),
        selenium: json["Selenium"] == null
            ? null
            : List<String>.from(json["Selenium"].map((x) => x)),
      );

  Map<String, dynamic> toJson() => {
        "Magnesium": magnesium == null
            ? null
            : List<dynamic>.from(magnesium.map((x) => x)),
        "Potassium": potassium == null
            ? null
            : List<dynamic>.from(potassium.map((x) => x)),
        "Selenium": selenium == null
            ? null
            : List<dynamic>.from(selenium.map((x) => x)),
      };
}

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  Function _future;

  Future<List<AllMealPlanModel>> getAllMealPlanData(String item) async {
    String jsonString = '''
    [
  {
    "id": 7,
    "daily_allowance_actual_percentage": {
      "Bone": [
        0.01,
        "Red"
      ],
      "Muscle Meat": [
        46.15,
        "Red"
      ],
      "Fruit and Veg": [
        53.84,
        "Red"
      ]
    },
    "daily_calories_from_this_meal_plan": 823.25,
    "imperial_weight_of_one_meal": 5.732025,
    "meal_ingredients_would_make": 8,
    "meals_per_day": 2,
    "nutrient_value": [
      {
        "Calcium": [
          249.5,
          "mg",
          "Yellow",
          0.008800863,
          "ounce"
        ]
      },
      {
        "Choline": [
          203.65,
          "mg",
          "Green",
          0.0071835501,
          "ounce"
        ]
      },
      {
        "Copper": [
          1.33,
          "mg",
          "Green",
          0.00004691442,
          "ounce"
        ]
      },
      {
        "Crude fat": [
          29.75,
          "g",
          "Green",
          1.0494015,
          "ounce"
        ]
      },
      {
        "Folate": [
          469,
          "mcg",
          "Green",
          0.000016543506,
          "ounce"
        ]
      },
      {
        "Iodine": [
          2.1,
          "mcg",
          "Red",
          7.40754e-8,
          "ounce"
        ]
      },
      {
        "Iron": [
          11.77,
          "mg",
          "Green",
          0.00041517497999999997,
          "ounce"
        ]
      },
      {
        "Magnesium": [
          253,
          "mg",
          "Red",
          0.008924322,
          "ounce"
        ]
      },
      {
        "Manganese": [
          1.82,
          "mg",
          "Green",
          0.00006419868,
          "ounce"
        ]
      },
      {
        "Niacin (B3)": [
          11.88,
          "mg",
          "Green",
          0.00041905512,
          "ounce"
        ]
      },
      {
        "Omega-3 excl. ALA and SDA": [
          0.03,
          "g",
          "Green",
          0.00105822,
          "ounce"
        ]
      },
      {
        "Omega-6": [
          0.93,
          "g",
          "Green",
          0.03280482,
          "ounce"
        ]
      },
      {
        "Pantothenic acid (B5)": [
          1.7,
          "mg",
          "Green",
          0.000059965799999999994,
          "ounce"
        ]
      },
      {
        "Phosphorus": [
          800,
          "mg",
          "Yellow",
          0.0282192,
          "ounce"
        ]
      },
      {
        "Potassium": [
          2766.5,
          "mg",
          "Red",
          0.09758552100000001,
          "ounce"
        ]
      },
      {
        "Protein": [
          56.02,
          "g",
          "Green",
          1.9760494800000001,
          "ounce"
        ]
      },
      {
        "Riboflavin (B2)": [
          0.54,
          "mg",
          "Green",
          0.00001904796,
          "ounce"
        ]
      },
      {
        "Selenium": [
          39.05,
          "mcg",
          "Red",
          0.0000013774497,
          "ounce"
        ]
      },
      {
        "Sodium (Na)": [
          123,
          "mg",
          "Green",
          0.004338702,
          "ounce"
        ]
      },
      {
        "Thiamin (B1)": [
          0.78,
          "mg",
          "Green",
          0.00002751372,
          "ounce"
        ]
      },
      {
        "Vitamin A": [
          4.2,
          "mcg",
          "Red",
          1.481508e-7,
          "ounce"
        ]
      },
      {
        "Vitamin C": [
          1.75,
          "mg",
          "Green",
          0.0000617295,
          "ounce"
        ]
      },
      {
        "Vitamin D": [
          0.15,
          "mcg",
          "Red",
          5.2911000000000005e-9,
          "ounce"
        ]
      },
      {
        "Vitamin E": [
          1.03,
          "mg",
          "Red",
          0.000036332220000000006,
          "ounce"
        ]
      },
      {
        "Zinc (Zn)": [
          8.24,
          "mg",
          "Green",
          0.00029065776000000005,
          "ounce"
        ]
      },
      {
        "Calories": [
          823.25,
          "cal",
          null,
          "N/A",
          "ounce"
        ]
      }
    ],
    "pet_name": "grover",
    "show_weight_of_balanced_meal": false,
    "suggestion": {
      "add_food": {
        "Yellow": [
          {
            "Calcium": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Phosphorus": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          }
        ],
        "Red": [
          {
            "Iodine": [
              "Amaranth, grain, whole, uncooked",
              "Apricot, dried"
            ]
          },
          {
            "Vitamin A": [
              "Bean, edamame, from frozen, cooked",
              "Beef Brain"
            ]
          },
          {
            "Vitamin D": [
              "Beef kidney, raw",
              "Beef liver, raw"
            ]
          },
          {
            "Vitamin E": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Choline": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Copper": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Crude fat": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Folate": [
              "Amaranth, grain, whole, uncooked",
              "Apple, fuji, unpeeled, raw"
            ]
          },
          {
            "Iron": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Manganese": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Niacin (B3)": [
              "Apple, fuji, unpeeled, raw",
              "Apple, golden delicious, unpeeled, raw"
            ]
          },
          {
            "Omega-3 excl. ALA and SDA": [
              "Bass, fillet, raw",
              "Beef Brain"
            ]
          },
          {
            "Omega-6": [
              "Amaranth, grain, whole, uncooked",
              "Avocado, raw"
            ]
          },
          {
            "Pantothenic acid (B5)": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Protein": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Riboflavin (B2)": [
              "Amaranth, grain, whole, uncooked",
              "Apple, fuji, unpeeled, raw"
            ]
          },
          {
            "Sodium (Na)": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Thiamin (B1)": [
              "Amaranth, grain, whole, uncooked",
              "Apple, fuji, unpeeled, raw"
            ]
          },
          {
            "Zinc (Zn)": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          }
        ]
      },
      "remove_food": {
        "Yellow": [],
        "Red": [
          {
            "Magnesium": [
              "Beef, all cuts, untrimmed, raw, no bone",
              "Apricot, dried"
            ]
          },
          {
            "Potassium": [
              "Beef, all cuts, untrimmed, raw, no bone",
              "Apricot, dried"
            ]
          },
          {
            "Selenium": [
              "Beef, all cuts, untrimmed, raw, no bone",
              "Apricot, dried"
            ]
          }
        ]
      }
    },
    "total_calories_in_a_meal_plan": 3293,
    "total_imperial_weight_of_a_meal_plan": 45.8562,
    "total_weight_of_a_meal_plan": 1300,
    "weight_of_one_meal": 162.5,
    "feeding_plan_details": [
      {
        "id": 23,
        "imperial_quantity": 14.1096,
        "quantity": 400,
        "food": {
          "id": 5,
          "bone_percentage": 0,
          "calcium_phosphorous_ratio": 0.14,
          "name": "Beef, all cuts, untrimmed, raw, no bone",
          "omega_ratio": 0,
          "omega_ratio_color": "Red",
          "calcium_phosphorous_ratio_color": "Red"
        }
      },
      {
        "id": 24,
        "imperial_quantity": 7.0548,
        "quantity": 200,
        "food": {
          "id": 45,
          "bone_percentage": 0,
          "calcium_phosphorous_ratio": 0.56,
          "name": "Apricot, dried",
          "omega_ratio": 0,
          "omega_ratio_color": "Red",
          "calcium_phosphorous_ratio_color": "Yellow"
        }
      },
      {
        "id": 25,
        "imperial_quantity": 17.637,
        "quantity": 500,
        "food": {
          "id": 222,
          "bone_percentage": 0,
          "calcium_phosphorous_ratio": 0.38,
          "name": "Bean, haricot, dried",
          "omega_ratio": 0,
          "omega_ratio_color": "Red",
          "calcium_phosphorous_ratio_color": "Red"
        }
      },
      {
        "id": 26,
        "imperial_quantity": 7.0548,
        "quantity": 200,
        "food": {
          "id": 294,
          "bone_percentage": 0,
          "calcium_phosphorous_ratio": 0.08,
          "name": "Pork, all cuts, lean, raw",
          "omega_ratio": 0.09,
          "omega_ratio_color": "Yellow",
          "calcium_phosphorous_ratio_color": "Red"
        }
      }
    ]
  }
]
    ''';

    http.Response response = http.Response(jsonString, 200);
    if (response.statusCode == 200) {
      return allMealPlanModelFromJson(response.body);
    }
  }

  @override
  void initState() {
    _future = getAllMealPlanData;
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: FutureBuilder(
            future: _future("your item"),
            builder: (context, AsyncSnapshot<List<AllMealPlanModel>> snapshot) {
              switch (snapshot.connectionState) {
                case ConnectionState.none:
                  return Text('none');
                case ConnectionState.waiting:
                  return Center(child: CircularProgressIndicator());
                case ConnectionState.active:
                  return Text('');
                case ConnectionState.done:
                  if (snapshot.hasError) {
                    return Text(
                      '${snapshot.error}',
                      style: TextStyle(color: Colors.red),
                    );
                  } else {
                    return ListView.separated(
                        separatorBuilder: (BuildContext context, int index) {
                          return SizedBox(
                            height: 10,
                          );
                        },
                        shrinkWrap: true,
                        itemCount: snapshot.data.length,
                        itemBuilder: (context, index) {
                          return Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: <Widget>[
                              Column(
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: <Widget>[
                                    Text(snapshot.data[index].id.toString()),
                                    Container(
                                      //height: 50,
                                      child: ListView.separated(
                                          separatorBuilder:
                                              (BuildContext context,
                                                  int index) {
                                            return SizedBox(
                                              width: 10,
                                            );
                                          },
                                          shrinkWrap: true,
                                          scrollDirection: Axis.vertical,
                                          itemCount: snapshot.data[index]
                                              .feedingPlanDetails.length,
                                          itemBuilder: (context, index1) {
                                            return Row(
                                              children: <Widget>[
                                                Text(
                                                    "food: ${snapshot.data[index].feedingPlanDetails[index1].food.name}"),
                                                SizedBox(
                                                  width: 10,
                                                ),
                                                Text(
                                                    "quantity: ${snapshot.data[index].feedingPlanDetails[index1].quantity.toString()}"),
                                              ],
                                            );
                                          }),
                                    )
                                  ])
                            ],
                          );
                        });
                  }
              }
            }));
  }
}
-----------------------
List<AllMealPlanModel> allMealPlanModelFromJson(String str) =>
List<AllMealPlanModel>.from(
    json.decode(str).map((x) => AllMealPlanModel.fromJson(x)));

http.Response response = http.Response(jsonString, 200);
    if (response.statusCode == 200) {
      return allMealPlanModelFromJson(response.body);
    }
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';

List<AllMealPlanModel> allMealPlanModelFromJson(String str) =>
    List<AllMealPlanModel>.from(
        json.decode(str).map((x) => AllMealPlanModel.fromJson(x)));

String allMealPlanModelToJson(List<AllMealPlanModel> data) =>
    json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

class AllMealPlanModel {
  AllMealPlanModel({
    this.id,
    this.dailyAllowanceActualPercentage,
    this.dailyCaloriesFromThisMealPlan,
    this.imperialWeightOfOneMeal,
    this.mealIngredientsWouldMake,
    this.mealsPerDay,
    this.nutrientValue,
    this.petName,
    this.showWeightOfBalancedMeal,
    this.suggestion,
    this.totalCaloriesInAMealPlan,
    this.totalImperialWeightOfAMealPlan,
    this.totalWeightOfAMealPlan,
    this.weightOfOneMeal,
    this.feedingPlanDetails,
  });

  int id;
  DailyAllowanceActualPercentage dailyAllowanceActualPercentage;
  double dailyCaloriesFromThisMealPlan;
  double imperialWeightOfOneMeal;
  int mealIngredientsWouldMake;
  int mealsPerDay;
  List<NutrientValue> nutrientValue;
  String petName;
  bool showWeightOfBalancedMeal;
  Suggestion suggestion;
  int totalCaloriesInAMealPlan;
  double totalImperialWeightOfAMealPlan;
  int totalWeightOfAMealPlan;
  double weightOfOneMeal;
  List<FeedingPlanDetail> feedingPlanDetails;

  factory AllMealPlanModel.fromJson(Map<String, dynamic> json) =>
      AllMealPlanModel(
        id: json["id"],
        dailyAllowanceActualPercentage: DailyAllowanceActualPercentage.fromJson(
            json["daily_allowance_actual_percentage"]),
        dailyCaloriesFromThisMealPlan:
            json["daily_calories_from_this_meal_plan"].toDouble(),
        imperialWeightOfOneMeal: json["imperial_weight_of_one_meal"].toDouble(),
        mealIngredientsWouldMake: json["meal_ingredients_would_make"],
        mealsPerDay: json["meals_per_day"],
        nutrientValue: List<NutrientValue>.from(
            json["nutrient_value"].map((x) => NutrientValue.fromJson(x))),
        petName: json["pet_name"],
        showWeightOfBalancedMeal: json["show_weight_of_balanced_meal"],
        suggestion: Suggestion.fromJson(json["suggestion"]),
        totalCaloriesInAMealPlan: json["total_calories_in_a_meal_plan"],
        totalImperialWeightOfAMealPlan:
            json["total_imperial_weight_of_a_meal_plan"].toDouble(),
        totalWeightOfAMealPlan: json["total_weight_of_a_meal_plan"],
        weightOfOneMeal: json["weight_of_one_meal"].toDouble(),
        feedingPlanDetails: List<FeedingPlanDetail>.from(
            json["feeding_plan_details"]
                .map((x) => FeedingPlanDetail.fromJson(x))),
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "daily_allowance_actual_percentage":
            dailyAllowanceActualPercentage.toJson(),
        "daily_calories_from_this_meal_plan": dailyCaloriesFromThisMealPlan,
        "imperial_weight_of_one_meal": imperialWeightOfOneMeal,
        "meal_ingredients_would_make": mealIngredientsWouldMake,
        "meals_per_day": mealsPerDay,
        "nutrient_value":
            List<dynamic>.from(nutrientValue.map((x) => x.toJson())),
        "pet_name": petName,
        "show_weight_of_balanced_meal": showWeightOfBalancedMeal,
        "suggestion": suggestion.toJson(),
        "total_calories_in_a_meal_plan": totalCaloriesInAMealPlan,
        "total_imperial_weight_of_a_meal_plan": totalImperialWeightOfAMealPlan,
        "total_weight_of_a_meal_plan": totalWeightOfAMealPlan,
        "weight_of_one_meal": weightOfOneMeal,
        "feeding_plan_details":
            List<dynamic>.from(feedingPlanDetails.map((x) => x.toJson())),
      };
}

class DailyAllowanceActualPercentage {
  DailyAllowanceActualPercentage({
    this.bone,
    this.muscleMeat,
    this.fruitAndVeg,
  });

  List<dynamic> bone;
  List<dynamic> muscleMeat;
  List<dynamic> fruitAndVeg;

  factory DailyAllowanceActualPercentage.fromJson(Map<String, dynamic> json) =>
      DailyAllowanceActualPercentage(
        bone: List<dynamic>.from(json["Bone"].map((x) => x)),
        muscleMeat: List<dynamic>.from(json["Muscle Meat"].map((x) => x)),
        fruitAndVeg: List<dynamic>.from(json["Fruit and Veg"].map((x) => x)),
      );

  Map<String, dynamic> toJson() => {
        "Bone": List<dynamic>.from(bone.map((x) => x)),
        "Muscle Meat": List<dynamic>.from(muscleMeat.map((x) => x)),
        "Fruit and Veg": List<dynamic>.from(fruitAndVeg.map((x) => x)),
      };
}

class FeedingPlanDetail {
  FeedingPlanDetail({
    this.id,
    this.imperialQuantity,
    this.quantity,
    this.food,
  });

  int id;
  double imperialQuantity;
  int quantity;
  Food food;

  factory FeedingPlanDetail.fromJson(Map<String, dynamic> json) =>
      FeedingPlanDetail(
        id: json["id"],
        imperialQuantity: json["imperial_quantity"].toDouble(),
        quantity: json["quantity"],
        food: Food.fromJson(json["food"]),
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "imperial_quantity": imperialQuantity,
        "quantity": quantity,
        "food": food.toJson(),
      };
}

class Food {
  Food({
    this.id,
    this.bonePercentage,
    this.calciumPhosphorousRatio,
    this.name,
    this.omegaRatio,
    this.omegaRatioColor,
    this.calciumPhosphorousRatioColor,
  });

  int id;
  int bonePercentage;
  double calciumPhosphorousRatio;
  String name;
  double omegaRatio;
  String omegaRatioColor;
  String calciumPhosphorousRatioColor;

  factory Food.fromJson(Map<String, dynamic> json) => Food(
        id: json["id"],
        bonePercentage: json["bone_percentage"],
        calciumPhosphorousRatio: json["calcium_phosphorous_ratio"].toDouble(),
        name: json["name"],
        omegaRatio: json["omega_ratio"].toDouble(),
        omegaRatioColor: json["omega_ratio_color"],
        calciumPhosphorousRatioColor: json["calcium_phosphorous_ratio_color"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "bone_percentage": bonePercentage,
        "calcium_phosphorous_ratio": calciumPhosphorousRatio,
        "name": name,
        "omega_ratio": omegaRatio,
        "omega_ratio_color": omegaRatioColor,
        "calcium_phosphorous_ratio_color": calciumPhosphorousRatioColor,
      };
}

class NutrientValue {
  NutrientValue({
    this.calcium,
    this.choline,
    this.copper,
    this.crudeFat,
    this.folate,
    this.iodine,
    this.iron,
    this.magnesium,
    this.manganese,
    this.niacinB3,
    this.omega3ExclAlaAndSda,
    this.omega6,
    this.pantothenicAcidB5,
    this.phosphorus,
    this.potassium,
    this.protein,
    this.riboflavinB2,
    this.selenium,
    this.sodiumNa,
    this.thiaminB1,
    this.vitaminA,
    this.vitaminC,
    this.vitaminD,
    this.vitaminE,
    this.zincZn,
    this.calories,
  });

  List<dynamic> calcium;
  List<dynamic> choline;
  List<dynamic> copper;
  List<dynamic> crudeFat;
  List<dynamic> folate;
  List<dynamic> iodine;
  List<dynamic> iron;
  List<dynamic> magnesium;
  List<dynamic> manganese;
  List<dynamic> niacinB3;
  List<dynamic> omega3ExclAlaAndSda;
  List<dynamic> omega6;
  List<dynamic> pantothenicAcidB5;
  List<dynamic> phosphorus;
  List<dynamic> potassium;
  List<dynamic> protein;
  List<dynamic> riboflavinB2;
  List<dynamic> selenium;
  List<dynamic> sodiumNa;
  List<dynamic> thiaminB1;
  List<dynamic> vitaminA;
  List<dynamic> vitaminC;
  List<dynamic> vitaminD;
  List<dynamic> vitaminE;
  List<dynamic> zincZn;
  List<dynamic> calories;

  factory NutrientValue.fromJson(Map<String, dynamic> json) => NutrientValue(
        calcium: json["Calcium"] == null
            ? null
            : List<dynamic>.from(json["Calcium"].map((x) => x)),
        choline: json["Choline"] == null
            ? null
            : List<dynamic>.from(json["Choline"].map((x) => x)),
        copper: json["Copper"] == null
            ? null
            : List<dynamic>.from(json["Copper"].map((x) => x)),
        crudeFat: json["Crude fat"] == null
            ? null
            : List<dynamic>.from(json["Crude fat"].map((x) => x)),
        folate: json["Folate"] == null
            ? null
            : List<dynamic>.from(json["Folate"].map((x) => x)),
        iodine: json["Iodine"] == null
            ? null
            : List<dynamic>.from(json["Iodine"].map((x) => x)),
        iron: json["Iron"] == null
            ? null
            : List<dynamic>.from(json["Iron"].map((x) => x)),
        magnesium: json["Magnesium"] == null
            ? null
            : List<dynamic>.from(json["Magnesium"].map((x) => x)),
        manganese: json["Manganese"] == null
            ? null
            : List<dynamic>.from(json["Manganese"].map((x) => x)),
        niacinB3: json["Niacin (B3)"] == null
            ? null
            : List<dynamic>.from(json["Niacin (B3)"].map((x) => x)),
        omega3ExclAlaAndSda: json["Omega-3 excl. ALA and SDA"] == null
            ? null
            : List<dynamic>.from(
                json["Omega-3 excl. ALA and SDA"].map((x) => x)),
        omega6: json["Omega-6"] == null
            ? null
            : List<dynamic>.from(json["Omega-6"].map((x) => x)),
        pantothenicAcidB5: json["Pantothenic acid (B5)"] == null
            ? null
            : List<dynamic>.from(json["Pantothenic acid (B5)"].map((x) => x)),
        phosphorus: json["Phosphorus"] == null
            ? null
            : List<dynamic>.from(json["Phosphorus"].map((x) => x)),
        potassium: json["Potassium"] == null
            ? null
            : List<dynamic>.from(json["Potassium"].map((x) => x)),
        protein: json["Protein"] == null
            ? null
            : List<dynamic>.from(json["Protein"].map((x) => x)),
        riboflavinB2: json["Riboflavin (B2)"] == null
            ? null
            : List<dynamic>.from(json["Riboflavin (B2)"].map((x) => x)),
        selenium: json["Selenium"] == null
            ? null
            : List<dynamic>.from(json["Selenium"].map((x) => x)),
        sodiumNa: json["Sodium (Na)"] == null
            ? null
            : List<dynamic>.from(json["Sodium (Na)"].map((x) => x)),
        thiaminB1: json["Thiamin (B1)"] == null
            ? null
            : List<dynamic>.from(json["Thiamin (B1)"].map((x) => x)),
        vitaminA: json["Vitamin A"] == null
            ? null
            : List<dynamic>.from(json["Vitamin A"].map((x) => x)),
        vitaminC: json["Vitamin C"] == null
            ? null
            : List<dynamic>.from(json["Vitamin C"].map((x) => x)),
        vitaminD: json["Vitamin D"] == null
            ? null
            : List<dynamic>.from(json["Vitamin D"].map((x) => x)),
        vitaminE: json["Vitamin E"] == null
            ? null
            : List<dynamic>.from(json["Vitamin E"].map((x) => x)),
        zincZn: json["Zinc (Zn)"] == null
            ? null
            : List<dynamic>.from(json["Zinc (Zn)"].map((x) => x)),
        calories: json["Calories"] == null
            ? null
            : List<dynamic>.from(json["Calories"].map((x) => x)),
      );

  Map<String, dynamic> toJson() => {
        "Calcium":
            calcium == null ? null : List<dynamic>.from(calcium.map((x) => x)),
        "Choline":
            choline == null ? null : List<dynamic>.from(choline.map((x) => x)),
        "Copper":
            copper == null ? null : List<dynamic>.from(copper.map((x) => x)),
        "Crude fat": crudeFat == null
            ? null
            : List<dynamic>.from(crudeFat.map((x) => x)),
        "Folate":
            folate == null ? null : List<dynamic>.from(folate.map((x) => x)),
        "Iodine":
            iodine == null ? null : List<dynamic>.from(iodine.map((x) => x)),
        "Iron": iron == null ? null : List<dynamic>.from(iron.map((x) => x)),
        "Magnesium": magnesium == null
            ? null
            : List<dynamic>.from(magnesium.map((x) => x)),
        "Manganese": manganese == null
            ? null
            : List<dynamic>.from(manganese.map((x) => x)),
        "Niacin (B3)": niacinB3 == null
            ? null
            : List<dynamic>.from(niacinB3.map((x) => x)),
        "Omega-3 excl. ALA and SDA": omega3ExclAlaAndSda == null
            ? null
            : List<dynamic>.from(omega3ExclAlaAndSda.map((x) => x)),
        "Omega-6":
            omega6 == null ? null : List<dynamic>.from(omega6.map((x) => x)),
        "Pantothenic acid (B5)": pantothenicAcidB5 == null
            ? null
            : List<dynamic>.from(pantothenicAcidB5.map((x) => x)),
        "Phosphorus": phosphorus == null
            ? null
            : List<dynamic>.from(phosphorus.map((x) => x)),
        "Potassium": potassium == null
            ? null
            : List<dynamic>.from(potassium.map((x) => x)),
        "Protein":
            protein == null ? null : List<dynamic>.from(protein.map((x) => x)),
        "Riboflavin (B2)": riboflavinB2 == null
            ? null
            : List<dynamic>.from(riboflavinB2.map((x) => x)),
        "Selenium": selenium == null
            ? null
            : List<dynamic>.from(selenium.map((x) => x)),
        "Sodium (Na)": sodiumNa == null
            ? null
            : List<dynamic>.from(sodiumNa.map((x) => x)),
        "Thiamin (B1)": thiaminB1 == null
            ? null
            : List<dynamic>.from(thiaminB1.map((x) => x)),
        "Vitamin A": vitaminA == null
            ? null
            : List<dynamic>.from(vitaminA.map((x) => x)),
        "Vitamin C": vitaminC == null
            ? null
            : List<dynamic>.from(vitaminC.map((x) => x)),
        "Vitamin D": vitaminD == null
            ? null
            : List<dynamic>.from(vitaminD.map((x) => x)),
        "Vitamin E": vitaminE == null
            ? null
            : List<dynamic>.from(vitaminE.map((x) => x)),
        "Zinc (Zn)":
            zincZn == null ? null : List<dynamic>.from(zincZn.map((x) => x)),
        "Calories": calories == null
            ? null
            : List<dynamic>.from(calories.map((x) => x)),
      };
}

class Suggestion {
  Suggestion({
    this.addFood,
    this.removeFood,
  });

  AddFood addFood;
  RemoveFood removeFood;

  factory Suggestion.fromJson(Map<String, dynamic> json) => Suggestion(
        addFood: AddFood.fromJson(json["add_food"]),
        removeFood: RemoveFood.fromJson(json["remove_food"]),
      );

  Map<String, dynamic> toJson() => {
        "add_food": addFood.toJson(),
        "remove_food": removeFood.toJson(),
      };
}

class AddFood {
  AddFood({
    this.yellow,
    this.red,
  });

  List<Yellow> yellow;
  List<Map<String, List<String>>> red;

  factory AddFood.fromJson(Map<String, dynamic> json) => AddFood(
        yellow:
            List<Yellow>.from(json["Yellow"].map((x) => Yellow.fromJson(x))),
        red: List<Map<String, List<String>>>.from(json["Red"].map((x) =>
            Map.from(x).map((k, v) => MapEntry<String, List<String>>(
                k, List<String>.from(v.map((x) => x)))))),
      );

  Map<String, dynamic> toJson() => {
        "Yellow": List<dynamic>.from(yellow.map((x) => x.toJson())),
        "Red": List<dynamic>.from(red.map((x) => Map.from(x).map((k, v) =>
            MapEntry<String, dynamic>(
                k, List<dynamic>.from(v.map((x) => x)))))),
      };
}

class Yellow {
  Yellow({
    this.calcium,
    this.phosphorus,
  });

  List<String> calcium;
  List<String> phosphorus;

  factory Yellow.fromJson(Map<String, dynamic> json) => Yellow(
        calcium: json["Calcium"] == null
            ? null
            : List<String>.from(json["Calcium"].map((x) => x)),
        phosphorus: json["Phosphorus"] == null
            ? null
            : List<String>.from(json["Phosphorus"].map((x) => x)),
      );

  Map<String, dynamic> toJson() => {
        "Calcium":
            calcium == null ? null : List<dynamic>.from(calcium.map((x) => x)),
        "Phosphorus": phosphorus == null
            ? null
            : List<dynamic>.from(phosphorus.map((x) => x)),
      };
}

class RemoveFood {
  RemoveFood({
    this.yellow,
    this.red,
  });

  List<dynamic> yellow;
  List<Red> red;

  factory RemoveFood.fromJson(Map<String, dynamic> json) => RemoveFood(
        yellow: List<dynamic>.from(json["Yellow"].map((x) => x)),
        red: List<Red>.from(json["Red"].map((x) => Red.fromJson(x))),
      );

  Map<String, dynamic> toJson() => {
        "Yellow": List<dynamic>.from(yellow.map((x) => x)),
        "Red": List<dynamic>.from(red.map((x) => x.toJson())),
      };
}

class Red {
  Red({
    this.magnesium,
    this.potassium,
    this.selenium,
  });

  List<String> magnesium;
  List<String> potassium;
  List<String> selenium;

  factory Red.fromJson(Map<String, dynamic> json) => Red(
        magnesium: json["Magnesium"] == null
            ? null
            : List<String>.from(json["Magnesium"].map((x) => x)),
        potassium: json["Potassium"] == null
            ? null
            : List<String>.from(json["Potassium"].map((x) => x)),
        selenium: json["Selenium"] == null
            ? null
            : List<String>.from(json["Selenium"].map((x) => x)),
      );

  Map<String, dynamic> toJson() => {
        "Magnesium": magnesium == null
            ? null
            : List<dynamic>.from(magnesium.map((x) => x)),
        "Potassium": potassium == null
            ? null
            : List<dynamic>.from(potassium.map((x) => x)),
        "Selenium": selenium == null
            ? null
            : List<dynamic>.from(selenium.map((x) => x)),
      };
}

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  Function _future;

  Future<List<AllMealPlanModel>> getAllMealPlanData(String item) async {
    String jsonString = '''
    [
  {
    "id": 7,
    "daily_allowance_actual_percentage": {
      "Bone": [
        0.01,
        "Red"
      ],
      "Muscle Meat": [
        46.15,
        "Red"
      ],
      "Fruit and Veg": [
        53.84,
        "Red"
      ]
    },
    "daily_calories_from_this_meal_plan": 823.25,
    "imperial_weight_of_one_meal": 5.732025,
    "meal_ingredients_would_make": 8,
    "meals_per_day": 2,
    "nutrient_value": [
      {
        "Calcium": [
          249.5,
          "mg",
          "Yellow",
          0.008800863,
          "ounce"
        ]
      },
      {
        "Choline": [
          203.65,
          "mg",
          "Green",
          0.0071835501,
          "ounce"
        ]
      },
      {
        "Copper": [
          1.33,
          "mg",
          "Green",
          0.00004691442,
          "ounce"
        ]
      },
      {
        "Crude fat": [
          29.75,
          "g",
          "Green",
          1.0494015,
          "ounce"
        ]
      },
      {
        "Folate": [
          469,
          "mcg",
          "Green",
          0.000016543506,
          "ounce"
        ]
      },
      {
        "Iodine": [
          2.1,
          "mcg",
          "Red",
          7.40754e-8,
          "ounce"
        ]
      },
      {
        "Iron": [
          11.77,
          "mg",
          "Green",
          0.00041517497999999997,
          "ounce"
        ]
      },
      {
        "Magnesium": [
          253,
          "mg",
          "Red",
          0.008924322,
          "ounce"
        ]
      },
      {
        "Manganese": [
          1.82,
          "mg",
          "Green",
          0.00006419868,
          "ounce"
        ]
      },
      {
        "Niacin (B3)": [
          11.88,
          "mg",
          "Green",
          0.00041905512,
          "ounce"
        ]
      },
      {
        "Omega-3 excl. ALA and SDA": [
          0.03,
          "g",
          "Green",
          0.00105822,
          "ounce"
        ]
      },
      {
        "Omega-6": [
          0.93,
          "g",
          "Green",
          0.03280482,
          "ounce"
        ]
      },
      {
        "Pantothenic acid (B5)": [
          1.7,
          "mg",
          "Green",
          0.000059965799999999994,
          "ounce"
        ]
      },
      {
        "Phosphorus": [
          800,
          "mg",
          "Yellow",
          0.0282192,
          "ounce"
        ]
      },
      {
        "Potassium": [
          2766.5,
          "mg",
          "Red",
          0.09758552100000001,
          "ounce"
        ]
      },
      {
        "Protein": [
          56.02,
          "g",
          "Green",
          1.9760494800000001,
          "ounce"
        ]
      },
      {
        "Riboflavin (B2)": [
          0.54,
          "mg",
          "Green",
          0.00001904796,
          "ounce"
        ]
      },
      {
        "Selenium": [
          39.05,
          "mcg",
          "Red",
          0.0000013774497,
          "ounce"
        ]
      },
      {
        "Sodium (Na)": [
          123,
          "mg",
          "Green",
          0.004338702,
          "ounce"
        ]
      },
      {
        "Thiamin (B1)": [
          0.78,
          "mg",
          "Green",
          0.00002751372,
          "ounce"
        ]
      },
      {
        "Vitamin A": [
          4.2,
          "mcg",
          "Red",
          1.481508e-7,
          "ounce"
        ]
      },
      {
        "Vitamin C": [
          1.75,
          "mg",
          "Green",
          0.0000617295,
          "ounce"
        ]
      },
      {
        "Vitamin D": [
          0.15,
          "mcg",
          "Red",
          5.2911000000000005e-9,
          "ounce"
        ]
      },
      {
        "Vitamin E": [
          1.03,
          "mg",
          "Red",
          0.000036332220000000006,
          "ounce"
        ]
      },
      {
        "Zinc (Zn)": [
          8.24,
          "mg",
          "Green",
          0.00029065776000000005,
          "ounce"
        ]
      },
      {
        "Calories": [
          823.25,
          "cal",
          null,
          "N/A",
          "ounce"
        ]
      }
    ],
    "pet_name": "grover",
    "show_weight_of_balanced_meal": false,
    "suggestion": {
      "add_food": {
        "Yellow": [
          {
            "Calcium": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Phosphorus": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          }
        ],
        "Red": [
          {
            "Iodine": [
              "Amaranth, grain, whole, uncooked",
              "Apricot, dried"
            ]
          },
          {
            "Vitamin A": [
              "Bean, edamame, from frozen, cooked",
              "Beef Brain"
            ]
          },
          {
            "Vitamin D": [
              "Beef kidney, raw",
              "Beef liver, raw"
            ]
          },
          {
            "Vitamin E": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Choline": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Copper": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Crude fat": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Folate": [
              "Amaranth, grain, whole, uncooked",
              "Apple, fuji, unpeeled, raw"
            ]
          },
          {
            "Iron": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Manganese": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Niacin (B3)": [
              "Apple, fuji, unpeeled, raw",
              "Apple, golden delicious, unpeeled, raw"
            ]
          },
          {
            "Omega-3 excl. ALA and SDA": [
              "Bass, fillet, raw",
              "Beef Brain"
            ]
          },
          {
            "Omega-6": [
              "Amaranth, grain, whole, uncooked",
              "Avocado, raw"
            ]
          },
          {
            "Pantothenic acid (B5)": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Protein": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Riboflavin (B2)": [
              "Amaranth, grain, whole, uncooked",
              "Apple, fuji, unpeeled, raw"
            ]
          },
          {
            "Sodium (Na)": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          },
          {
            "Thiamin (B1)": [
              "Amaranth, grain, whole, uncooked",
              "Apple, fuji, unpeeled, raw"
            ]
          },
          {
            "Zinc (Zn)": [
              "Amaranth, grain, whole, uncooked",
              "Apple, dried"
            ]
          }
        ]
      },
      "remove_food": {
        "Yellow": [],
        "Red": [
          {
            "Magnesium": [
              "Beef, all cuts, untrimmed, raw, no bone",
              "Apricot, dried"
            ]
          },
          {
            "Potassium": [
              "Beef, all cuts, untrimmed, raw, no bone",
              "Apricot, dried"
            ]
          },
          {
            "Selenium": [
              "Beef, all cuts, untrimmed, raw, no bone",
              "Apricot, dried"
            ]
          }
        ]
      }
    },
    "total_calories_in_a_meal_plan": 3293,
    "total_imperial_weight_of_a_meal_plan": 45.8562,
    "total_weight_of_a_meal_plan": 1300,
    "weight_of_one_meal": 162.5,
    "feeding_plan_details": [
      {
        "id": 23,
        "imperial_quantity": 14.1096,
        "quantity": 400,
        "food": {
          "id": 5,
          "bone_percentage": 0,
          "calcium_phosphorous_ratio": 0.14,
          "name": "Beef, all cuts, untrimmed, raw, no bone",
          "omega_ratio": 0,
          "omega_ratio_color": "Red",
          "calcium_phosphorous_ratio_color": "Red"
        }
      },
      {
        "id": 24,
        "imperial_quantity": 7.0548,
        "quantity": 200,
        "food": {
          "id": 45,
          "bone_percentage": 0,
          "calcium_phosphorous_ratio": 0.56,
          "name": "Apricot, dried",
          "omega_ratio": 0,
          "omega_ratio_color": "Red",
          "calcium_phosphorous_ratio_color": "Yellow"
        }
      },
      {
        "id": 25,
        "imperial_quantity": 17.637,
        "quantity": 500,
        "food": {
          "id": 222,
          "bone_percentage": 0,
          "calcium_phosphorous_ratio": 0.38,
          "name": "Bean, haricot, dried",
          "omega_ratio": 0,
          "omega_ratio_color": "Red",
          "calcium_phosphorous_ratio_color": "Red"
        }
      },
      {
        "id": 26,
        "imperial_quantity": 7.0548,
        "quantity": 200,
        "food": {
          "id": 294,
          "bone_percentage": 0,
          "calcium_phosphorous_ratio": 0.08,
          "name": "Pork, all cuts, lean, raw",
          "omega_ratio": 0.09,
          "omega_ratio_color": "Yellow",
          "calcium_phosphorous_ratio_color": "Red"
        }
      }
    ]
  }
]
    ''';

    http.Response response = http.Response(jsonString, 200);
    if (response.statusCode == 200) {
      return allMealPlanModelFromJson(response.body);
    }
  }

  @override
  void initState() {
    _future = getAllMealPlanData;
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: FutureBuilder(
            future: _future("your item"),
            builder: (context, AsyncSnapshot<List<AllMealPlanModel>> snapshot) {
              switch (snapshot.connectionState) {
                case ConnectionState.none:
                  return Text('none');
                case ConnectionState.waiting:
                  return Center(child: CircularProgressIndicator());
                case ConnectionState.active:
                  return Text('');
                case ConnectionState.done:
                  if (snapshot.hasError) {
                    return Text(
                      '${snapshot.error}',
                      style: TextStyle(color: Colors.red),
                    );
                  } else {
                    return ListView.separated(
                        separatorBuilder: (BuildContext context, int index) {
                          return SizedBox(
                            height: 10,
                          );
                        },
                        shrinkWrap: true,
                        itemCount: snapshot.data.length,
                        itemBuilder: (context, index) {
                          return Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: <Widget>[
                              Column(
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: <Widget>[
                                    Text(snapshot.data[index].id.toString()),
                                    Container(
                                      //height: 50,
                                      child: ListView.separated(
                                          separatorBuilder:
                                              (BuildContext context,
                                                  int index) {
                                            return SizedBox(
                                              width: 10,
                                            );
                                          },
                                          shrinkWrap: true,
                                          scrollDirection: Axis.vertical,
                                          itemCount: snapshot.data[index]
                                              .feedingPlanDetails.length,
                                          itemBuilder: (context, index1) {
                                            return Row(
                                              children: <Widget>[
                                                Text(
                                                    "food: ${snapshot.data[index].feedingPlanDetails[index1].food.name}"),
                                                SizedBox(
                                                  width: 10,
                                                ),
                                                Text(
                                                    "quantity: ${snapshot.data[index].feedingPlanDetails[index1].quantity.toString()}"),
                                              ],
                                            );
                                          }),
                                    )
                                  ])
                            ],
                          );
                        });
                  }
              }
            }));
  }
}

Convert json file to dataframe in python and FourSqaure API

copy iconCopydownload iconDownload
meta
response -> suggestedBounds
response -> groups -> items
df1 = pd.json_normalize(d['response'], record_path=['groups', 'items'], meta=[])
print(df1)
df2 = pd.json_normalize(d['response'])
print(df2)
df3 = pd.json_normalize(d['meta'])
print(df3)


                       referralId  reasons.count  ... venue.location.postalCode venue.venuePage.id
0  e-0-4bd461bc77b29c74a07d9282-0              0  ...                       NaN                NaN
1  e-0-4ad4c062f964a52011f820e3-1              0  ...                   M4E 0B8           75150878
2  e-0-4b8daea1f964a520480833e3-2              0  ...                   M4E 1R4                NaN
3  e-0-4df91c4bae60f95f82229ad5-3              0  ...                       NaN                NaN

[4 rows x 21 columns]
  headerLocation    headerFullLocation headerLocationGranularity  ...  suggestedBounds.ne.lng suggestedBounds.sw.lat  suggestedBounds.sw.lng
0    The Beaches  The Beaches, Toronto              neighborhood  ...              -79.286821              43.671857              -79.299241

[1 rows x 9 columns]
   code                 requestId
0   200  5eda4fb9aba297001b2f6207
-----------------------
meta
response -> suggestedBounds
response -> groups -> items
df1 = pd.json_normalize(d['response'], record_path=['groups', 'items'], meta=[])
print(df1)
df2 = pd.json_normalize(d['response'])
print(df2)
df3 = pd.json_normalize(d['meta'])
print(df3)


                       referralId  reasons.count  ... venue.location.postalCode venue.venuePage.id
0  e-0-4bd461bc77b29c74a07d9282-0              0  ...                       NaN                NaN
1  e-0-4ad4c062f964a52011f820e3-1              0  ...                   M4E 0B8           75150878
2  e-0-4b8daea1f964a520480833e3-2              0  ...                   M4E 1R4                NaN
3  e-0-4df91c4bae60f95f82229ad5-3              0  ...                       NaN                NaN

[4 rows x 21 columns]
  headerLocation    headerFullLocation headerLocationGranularity  ...  suggestedBounds.ne.lng suggestedBounds.sw.lat  suggestedBounds.sw.lng
0    The Beaches  The Beaches, Toronto              neighborhood  ...              -79.286821              43.671857              -79.299241

[1 rows x 9 columns]
   code                 requestId
0   200  5eda4fb9aba297001b2f6207

When scraping the desired webpages, the content of all the .txt files are the nodes I selected

copy iconCopydownload iconDownload
for (i in seq(nrow(sotu))) {
  sotu.text <- read_html(sotu$links[i]) %>%
    html_nodes(".col-sm-8") %>%
    html_text()
  filename <- paste0("State of the Union", " ", sotu$Year[i], " ", sotu$President[i], " ", sotu$Party[i], ".txt")
  cat(sotu.text, file=filename, sep = "\n")
}

Using json values in every class with Flutter?

copy iconCopydownload iconDownload
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      loadData();
    });
  }

  void loadData() async {
    payload = await getData();
    isLoading = false;
    setState(() {});
  }
  ...
  body: isLoading
          ? CircularProgressIndicator()
          : Center(
import 'dart:async';
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:http/http.dart' as http;
import 'package:flutter/material.dart';
// To parse this JSON data, do
//
//     final payload = payloadFromJson(jsonString);

import 'dart:convert';

Payload payloadFromJson(String str) => Payload.fromJson(json.decode(str));

String payloadToJson(Payload data) => json.encode(data.toJson());

class Payload {
  String moviecast;
  String moviedirectors;
  String moviegenre;
  String movieposterurl;
  String movierating;
  String movieruntime;
  String moviesummary;
  String movietitle;
  String moviewriters;
  String movieyear;

  Payload({
    this.moviecast,
    this.moviedirectors,
    this.moviegenre,
    this.movieposterurl,
    this.movierating,
    this.movieruntime,
    this.moviesummary,
    this.movietitle,
    this.moviewriters,
    this.movieyear,
  });

  factory Payload.fromJson(Map<String, dynamic> json) => Payload(
        moviecast: json["moviecast"],
        moviedirectors: json["moviedirectors"],
        moviegenre: json["moviegenre"],
        movieposterurl: json["movieposterurl"],
        movierating: json["movierating"],
        movieruntime: json["movieruntime"],
        moviesummary: json["moviesummary"],
        movietitle: json["movietitle"],
        moviewriters: json["moviewriters"],
        movieyear: json["movieyear"],
      );

  Map<String, dynamic> toJson() => {
        "moviecast": moviecast,
        "moviedirectors": moviedirectors,
        "moviegenre": moviegenre,
        "movieposterurl": movieposterurl,
        "movierating": movierating,
        "movieruntime": movieruntime,
        "moviesummary": moviesummary,
        "movietitle": movietitle,
        "moviewriters": moviewriters,
        "movieyear": movieyear,
      };
}

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Random Movie',
      theme: ThemeData(
        primarySwatch: Colors.grey,
      ),
      home: MyHomePage(title: "Data from json"),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

Payload payload;

class _MyHomePageState extends State<MyHomePage> {
  Modal modal = Modal();
  bool isLoading = true;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      loadData();
    });
  }

  void loadData() async {
    payload = await getData();
    isLoading = false;
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: isLoading
          ? Center(child: CircularProgressIndicator())
          : Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Text(' ${payload.moviecast}'),
                ],
              ),
            ),
      bottomNavigationBar: BottomAppBar(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            FlatButton(
              onPressed: () {
                modal.mainBottomSheet(context);
              },
              child: Text('Data from json'),
            ),
          ],
        ),
      ),
    );
  }
}

Future<Payload> getData() async {
  /*String myUrl = 'http://127.0.0.1/query?username=username';
  http.Response response = await http.get(myUrl);
  return json.decode(response.body);*/
  await Future.delayed(const Duration(seconds: 5), () {});

  String jsonString = '''
  {
  "moviecast": "Michael Shannon, Jessica Chastain, Tova Stewart, Shea Whigham, Katy Mixon, Natasha Randall, Ron Kennard, Scott Knisley, Robert Longstreet, Heather Caldwell, Sheila Hullihen, John Kloock, Marianna Alacchi, Jacque Jovic, Bob Maines, Charles Moore, Pete Ferry, Molly McGinnis, Angie Marino-Smith, Isabelle Smith, Tina Stump, Ken Strunk, Maryanne Nagel, Hailee Dickens, Kathy Baker, Guy Van Swearingen, LisaGay Hamilton, William Alexander, Joanna Tyler, Stuart Greer, Ray McKinnon, Jake Lockwood, Kim Hendrickson, Bart Flynn, Nick Koesters, Jeffrey Grover, Qenny O.T. Vitosha, Jason Botsford, Luis Orozco, Joe Zamora",
  "moviedirectors": "Jeff Nichols",
  "moviegenre": "Drama, Horror, Thriller",
  "movieposterurl": "https://m.media-amazon.com/images/M/MV5BNzgzODA5MTU3MF5BMl5BanBnXkFtZTcwODY4MDEwNg@@.jpg",
  "movierating": "7.4",
  "movieruntime": "121",
  "moviesummary": "Curtis, a father and husband, is starting to experience bad dreams and hallucinations. Assuming mental illness, he seeks medical help and counseling. However, fearing the worst, he starts building an elaborate and expensive storm shelter in their backyard. This storm shelter threatens to tear apart his family, threatens his sanity and his standing in the community, but he builds it to save his family's life.",
  "movietitle": "Take Shelter",
  "moviewriters": "Jeff Nichols",
  "movieyear": "2011"
}
  ''';

  return payloadFromJson(jsonString);
}

class Modal {
  mainBottomSheet(BuildContext context) {
    showModalBottomSheet(
        context: context,
        builder: (BuildContext context) {
          return Column(
            mainAxisSize: MainAxisSize.max,
            children: <Widget>[
              _createTile(
                  context, payload.moviedirectors, Icons.message, _action1),
              _createTile(
                  context, payload.movierating, Icons.camera_alt, _action2),
              _createTile(
                  context, payload.movietitle, Icons.photo_library, _action3),
            ],
          );
        });
  }

  ListTile _createTile(
      BuildContext context, String name, IconData icon, Function action) {
    return ListTile(
      leading: Icon(icon),
      title: Text(name),
      onTap: () {
        Navigator.pop(context);
        action();
      },
    );
  }

  _action1() {
    print('action 1');
  }

  _action2() {
    print('action 2');
  }

  _action3() {
    print('action 3');
  }
}
-----------------------
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      loadData();
    });
  }

  void loadData() async {
    payload = await getData();
    isLoading = false;
    setState(() {});
  }
  ...
  body: isLoading
          ? CircularProgressIndicator()
          : Center(
import 'dart:async';
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:http/http.dart' as http;
import 'package:flutter/material.dart';
// To parse this JSON data, do
//
//     final payload = payloadFromJson(jsonString);

import 'dart:convert';

Payload payloadFromJson(String str) => Payload.fromJson(json.decode(str));

String payloadToJson(Payload data) => json.encode(data.toJson());

class Payload {
  String moviecast;
  String moviedirectors;
  String moviegenre;
  String movieposterurl;
  String movierating;
  String movieruntime;
  String moviesummary;
  String movietitle;
  String moviewriters;
  String movieyear;

  Payload({
    this.moviecast,
    this.moviedirectors,
    this.moviegenre,
    this.movieposterurl,
    this.movierating,
    this.movieruntime,
    this.moviesummary,
    this.movietitle,
    this.moviewriters,
    this.movieyear,
  });

  factory Payload.fromJson(Map<String, dynamic> json) => Payload(
        moviecast: json["moviecast"],
        moviedirectors: json["moviedirectors"],
        moviegenre: json["moviegenre"],
        movieposterurl: json["movieposterurl"],
        movierating: json["movierating"],
        movieruntime: json["movieruntime"],
        moviesummary: json["moviesummary"],
        movietitle: json["movietitle"],
        moviewriters: json["moviewriters"],
        movieyear: json["movieyear"],
      );

  Map<String, dynamic> toJson() => {
        "moviecast": moviecast,
        "moviedirectors": moviedirectors,
        "moviegenre": moviegenre,
        "movieposterurl": movieposterurl,
        "movierating": movierating,
        "movieruntime": movieruntime,
        "moviesummary": moviesummary,
        "movietitle": movietitle,
        "moviewriters": moviewriters,
        "movieyear": movieyear,
      };
}

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Random Movie',
      theme: ThemeData(
        primarySwatch: Colors.grey,
      ),
      home: MyHomePage(title: "Data from json"),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

Payload payload;

class _MyHomePageState extends State<MyHomePage> {
  Modal modal = Modal();
  bool isLoading = true;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      loadData();
    });
  }

  void loadData() async {
    payload = await getData();
    isLoading = false;
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: isLoading
          ? Center(child: CircularProgressIndicator())
          : Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Text(' ${payload.moviecast}'),
                ],
              ),
            ),
      bottomNavigationBar: BottomAppBar(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            FlatButton(
              onPressed: () {
                modal.mainBottomSheet(context);
              },
              child: Text('Data from json'),
            ),
          ],
        ),
      ),
    );
  }
}

Future<Payload> getData() async {
  /*String myUrl = 'http://127.0.0.1/query?username=username';
  http.Response response = await http.get(myUrl);
  return json.decode(response.body);*/
  await Future.delayed(const Duration(seconds: 5), () {});

  String jsonString = '''
  {
  "moviecast": "Michael Shannon, Jessica Chastain, Tova Stewart, Shea Whigham, Katy Mixon, Natasha Randall, Ron Kennard, Scott Knisley, Robert Longstreet, Heather Caldwell, Sheila Hullihen, John Kloock, Marianna Alacchi, Jacque Jovic, Bob Maines, Charles Moore, Pete Ferry, Molly McGinnis, Angie Marino-Smith, Isabelle Smith, Tina Stump, Ken Strunk, Maryanne Nagel, Hailee Dickens, Kathy Baker, Guy Van Swearingen, LisaGay Hamilton, William Alexander, Joanna Tyler, Stuart Greer, Ray McKinnon, Jake Lockwood, Kim Hendrickson, Bart Flynn, Nick Koesters, Jeffrey Grover, Qenny O.T. Vitosha, Jason Botsford, Luis Orozco, Joe Zamora",
  "moviedirectors": "Jeff Nichols",
  "moviegenre": "Drama, Horror, Thriller",
  "movieposterurl": "https://m.media-amazon.com/images/M/MV5BNzgzODA5MTU3MF5BMl5BanBnXkFtZTcwODY4MDEwNg@@.jpg",
  "movierating": "7.4",
  "movieruntime": "121",
  "moviesummary": "Curtis, a father and husband, is starting to experience bad dreams and hallucinations. Assuming mental illness, he seeks medical help and counseling. However, fearing the worst, he starts building an elaborate and expensive storm shelter in their backyard. This storm shelter threatens to tear apart his family, threatens his sanity and his standing in the community, but he builds it to save his family's life.",
  "movietitle": "Take Shelter",
  "moviewriters": "Jeff Nichols",
  "movieyear": "2011"
}
  ''';

  return payloadFromJson(jsonString);
}

class Modal {
  mainBottomSheet(BuildContext context) {
    showModalBottomSheet(
        context: context,
        builder: (BuildContext context) {
          return Column(
            mainAxisSize: MainAxisSize.max,
            children: <Widget>[
              _createTile(
                  context, payload.moviedirectors, Icons.message, _action1),
              _createTile(
                  context, payload.movierating, Icons.camera_alt, _action2),
              _createTile(
                  context, payload.movietitle, Icons.photo_library, _action3),
            ],
          );
        });
  }

  ListTile _createTile(
      BuildContext context, String name, IconData icon, Function action) {
    return ListTile(
      leading: Icon(icon),
      title: Text(name),
      onTap: () {
        Navigator.pop(context);
        action();
      },
    );
  }

  _action1() {
    print('action 1');
  }

  _action2() {
    print('action 2');
  }

  _action3() {
    print('action 3');
  }
}

Regular Expression: Treat a group as optional if its not present but if present only capture the previous group before that

copy iconCopydownload iconDownload
(?i)^Link\s+to\s+(?<keyword>[a-z ]+) from (?<name>.*?)(?:\s+shared\s+(?<time>[a-z]+))?$

Replace a specific cell value based on what another cell starts with

copy iconCopydownload iconDownload
=IF(LEFT(A1;1)="a";"Yes";"No")
-----------------------
Option Explicit
Sub Example()


Dim wb As Workbook
Dim ws As Worksheet
Dim rng As Range, cell As Range
Dim str As String
Dim LastRow As Long

Set wb = ThisWorkbook
Set ws = wb.Sheets("Blad1")

LastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row

Set rng = ws.Range(ws.Cells(1, 1), ws.Cells(LastRow, 1))

For Each cell In rng
    If Asc(Left(cell.Value, 1)) >= 65 And Asc(Left(cell.Value, 1)) < 76 Then
        str = "Grover"
    ElseIf Asc(Left(cell.Value, 1)) >= 76 And Asc(Left(cell.Value, 1)) < 91 Then
        str = "Elmo"
    End If

    If ws.Cells(cell.Row, 19).Value = "Bert" Then
        ws.Cells(cell.Row, 19).Value = str
    End If
    If ws.Cells(cell.Row, 19).Value = "Grover" Then
        ws.Cells(cell.Row, 20).Value = "Example1"
    ElseIf ws.Cells(cell.Row, 19).Value = "Elmo" Then
        ws.Cells(cell.Row, 20).Value = "Example2"
    End If

Next cell


End Sub

How to create a newtype operation in Q#?

copy iconCopydownload iconDownload
newtype ModelOracle = (Apply: (Qubit[], Qubit[], Int[], Qubit) => Unit);

C# Setter and if statement

copy iconCopydownload iconDownload
if (value.Any(char.IsDigit))
{
  name = "No Name";
}
else{
  name = value;
}

Community Discussions

Trending Discussions on grover
  • Stylesheet renders in grover debug but not on downloaded pdf
  • w2ui combo input doesn't work inside a popup
  • Appending a key:value from one dictionary to another
  • Map List of objects from a Json response to a List in flutter
  • Effect of max sequence length on Grover
  • Convert json file to dataframe in python and FourSqaure API
  • When scraping the desired webpages, the content of all the .txt files are the nodes I selected
  • Using json values in every class with Flutter?
  • Regular Expression: Treat a group as optional if its not present but if present only capture the previous group before that
  • Replace a specific cell value based on what another cell starts with
Trending Discussions on grover

QUESTION

Stylesheet renders in grover debug but not on downloaded pdf

Asked 2021-Apr-21 at 04:22

I'm using Grover to render and download pdf copies of documents that are generated in my app and am having trouble applying css to it. When in grover's debug mode (and therefore exported and rendered in Chromium), the CSS renders exactly how I would expect. However, when I put it in headless mode and download as a pdf, it appears that my application.css is not being applied.

The PDF is being generated with the following method in a concern:

def purchase_order_gen(the_purchase_order, request_host_with_port)
  puts "generating pdf"
  puts "Generating PDF for PO " + the_purchase_order.id.to_s
  puts "Host is " + request_host_with_port

  html = render_to_string({
                              partial: '/purchase_orders/display_purchase_order',
                              layout: '/layouts/pdf_layout.html.erb',
                              locals: { po: the_purchase_order }
                              })
  puts "html"
  ap html

  the_display_url = 'http://' + request_host_with_port
  grover = Grover.new(html, {format: 'A4' , display_url: the_display_url})
  pdf = grover.to_pdf
  puts "Back From Grover!"

  return pdf
end

And I'm referencing the css with the following line, placed in the <head> of my layout.

<%= stylesheet_link_tag '/assets/stylesheets/application.css'%>

If I had to guess, I'd figure that I'm bungling the stylesheet_link_tag and that the debug version is able to pull from the asset pipeline, where the headless version is not.

Thanks in advance

ANSWER

Answered 2021-Apr-21 at 04:22

Turned out that grover requires a configuration for backgrounds to appear print_background: true. It just so happened that I had only set backgrounds before realizing that it wasn't working so setting that parameter to true in our grover initializers did the trick.

Source https://stackoverflow.com/questions/65526266

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install grover

NOTE: If you just care about making your own RealNews dataset, you will need to set up your environment separately just for that, using an AWS machine (see realnews/.).
Generation mode (inference). This requires a GPU because I wasn't able to get top-p sampling, or caching of transformer hidden states, to work on a TPU.
LM Validation mode (perplexity). This could be run on a GPU or a TPU, but I've only tested this with TPU inference.
LM Training mode. This requires a large TPU pod.
Discrimination mode (training). This requires a TPU pod.
Discrimination mode (inference). This could be run on a GPU or a TPU, but I've only tested this with TPU inference.
If you have a lot of projects on your machine, you might want to use an anaconda environment to handle them all. Use conda create -n grover python=3.6 to create an environment named grover. To enter the environment use source activate grover. To leave use source deactivate.
I'm using tensorflow 1.13.1 which requires Cuda 10.0. You'll need to install that from the nvidia website. I usually install it into /usr/local/cuda-10.0/, so you will need to run export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64 so tensorflow knows where to find it.
I always have my pythonpath as the root directory. While in the grover directory, run export PYTHONPATH=$(pwd) to set it.
Congrats! You can view the generations, conditioned on the domain/headline/date/authors, in april2019_set_mini_out.jsonl.
Set up your environment. Here's the easy way, assuming anaconda is installed: conda create -y -n grover python=3.6 && source activate grover && pip install -r requirements-gpu.txt
Download the model using python download_model.py base
Now generate: PYTHONPATH=$(pwd) python sample/contextual_generate.py -model_config_fn lm/configs/base.json -model_ckpt models/base/model.ckpt -metadata_fn sample/april2019_set_mini.jsonl -out_fn april2019_set_mini_out.jsonl

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Share this Page

share link
Reuse Pre-built Kits with grover
Compare Machine Learning Libraries with Highest Support
Compare Machine Learning Libraries with Highest Quality
Compare Machine Learning Libraries with Highest Security
Compare Machine Learning Libraries with Permissive License
Compare Machine Learning Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.