Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

140
Vistas
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 Respuestas
Responde la pregunta

0

Works perfect on DartPad.

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

about 4 years ago · Juan Pablo Isaza Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda