Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to display the data using flutter?

I can display while mapping the data (using flutter)

main.dart

//Im looping on it using map
List<Quote> quotes = [
Quote(
    author: 'Oscar Wilde',
    text: 'Be yourself, everyone else is already taken'),
Quote(
    author: 'Oscar Wilde',
    text: 'I have nothing to declare except my genius'),
Quote(
    author: 'Oscar Wilde',
    text: 'The truth is rarely pure and never simple'),
];

// Im using map then not display on the screen
body: Column(
      children: quotes.map((quote) => Text(quote)).toList(),
),

Thank you very much

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

>Solution :

To add card, add do this:

@override
  Widget build(BuildContext context) {
    return Column(
      children: List<Widget>.generate(
        quotes.length,
        (index) {
          return Card(
                   shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(40), // if you need this
                      side: BorderSide(
                         color: Colors.grey.withOpacity(0.2),
                         width: 1,
                      ),
                   ),
                child: Container(
                   color: Colors.white,
                   width: 200,
                   height: 200,
                   child: Text('${quotes[index].author}'),
                ),
            );
        },
      ),
    );
  }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading