Tengo una lista de comillas (tres comillas) y estoy usando la función de mapa para trazar un mapa a través de la lista de comillas para crear un pequeño widget para cada una. Pero las comillas no se muestran en la aplicación.
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(), ), ); } }Funciona perfecto en DartPad.
Intente ejecutar "flutter clean" y luego "flutter run"
prueba esto en lugar de la columna
ListView.builder( itemCount: 5, itemBuilder: (BuildContext context,int index){ return Text(quotes[index]); } ), );Mueva la inicialización de la variable de comillas dentro del método de build .
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(), ), ); } } También puede usar la inferencia de tipo y usar var en lugar de aclarar List<String> .