Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
List of data in Flutter is not showing

I have a list of quotes (three quotes) and am using the map function to map through the list of quotes to create a small widget for each one. But the quotes doesn't display on the app.

import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: QuoteList(),
  ));
}

class QuoteList extends StatefulWidget {
  const QuoteList({ Key? key }) : super(key: key);

  @override
  State<QuoteList> createState() => _QuoteListState();
}

class _QuoteListState extends State<QuoteList> {

  List<String> quotes = [
    "There are three constants in life.. change, choice and principles.",
    "In three words I can sum up everything Ive learned about life: it goes on.",
    "Guests, like fish, begin to smell after three days."
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.grey[200],
      appBar: AppBar(
        title: Text('Awesome Quotes'),
        centerTitle: true,
        backgroundColor: Colors.redAccent,
      ),
      body: Column(
        children: quotes.map((e) => Text(e)).toList(),
      ),
    );
  }
}
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Works perfect on DartPad.

Try to run "flutter clean" and then "flutter run "

about 4 years ago · Juan Pablo Isaza Report

0

try this instead of column

ListView.builder(
        itemCount: 5,
        itemBuilder: (BuildContext context,int index){
      return Text(quotes[index]);
        }
        ),
    );
about 4 years ago · Juan Pablo Isaza Report

0

Move the quotes variable initialization inside the build method.

class _QuoteListState extends State<QuoteList> {
  @override
  Widget build(BuildContext context) {
    var quotes = [
      "There are three constants in life.. change, choice and principles.",
      "In three words I can sum up everything Ive learned about life: it goes on.",
      "Guests, like fish, begin to smell after three days."
    ];

    return Scaffold(
      backgroundColor: Colors.grey[200],
      appBar: AppBar(
        title: Text('Awesome Quotes'),
        centerTitle: true,
        backgroundColor: Colors.redAccent,
      ),
      body: Column(
        children: quotes.map((e) => Text(e)).toList(),
      ),
    );
  }
}

Also you can use type inference and use var instead of clarifying List<String>.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!