When I try to generate more texts than my page can display I get this error enter image description here
Is there a way to make the content be scrollable instead? I followed some general instructions and all work fine as long as I write text manually by using Text(), sadly this doesn't fit what I'm looking for, since I need data to be generated automatically.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
debugShowCheckedModeBanner: false,
home: QuoteList(),
));
class QuoteList extends StatefulWidget {
@override
_QuoteListState createState() => _QuoteListState();
}
class _QuoteListState extends State<QuoteList> {
List<Quote> quotes = [
Quote(author: 'aaa', text: 'aaa'),
Quote(author: 'aaa', text: 'aaa'),
Quote(author: 'aaa', text: 'aaa'),
Quote(author: 'aaa', text: 'aaa'),
Quote(author: 'aaa', text: 'aaa'),
Quote(author: 'aaa', text: 'aaa'),
Quote(author: 'aaa', text: 'aaa'),
Quote(author: 'aaa', text: 'aaa'),
Quote(author: 'aaa', text: 'aaa'),
Quote(author: 'aaa', text: 'aaa'),
Quote(author: 'aaa', text: 'aaa'),
Quote(author: 'aaa', text: 'aaa'),
Quote(author: 'aaa', text: 'aaa'),
Quote(author: 'aaa', text: 'aaa'),
Quote(author: 'aaa', text: 'aaa'),
Quote(author: 'aaa', text: 'aaa'),
Quote(author: 'aaa', text: 'aaa'),
Quote(author: 'aaa', text: 'aaa'),
];
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[300],
body: Container(
width: double.infinity,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Colors.black,
Colors.black,
]),
),
child: Padding(
padding: EdgeInsets.fromLTRB(0.0, 3.0, 0.0, 3.0),
child: Column(
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: quotes
.map((quote) => QuoteCard(
quote: quote,
delete: () {
setState(() {
quotes.remove(quote);
});
}))
.toList(),
)
],
),
)));
}
}
class QuoteCard extends StatelessWidget {
final Quote quote;
final Function delete;
QuoteCard({this.quote, this.delete});
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.fromLTRB(0.0, 3.0, 0.0, 3.0),
child: Container(
child: Card(
color: Colors.grey[800],
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
SizedBox(
width: 20.0,
),
Text(
'${quote.text}',
style: TextStyle(
fontSize: 18.0,
color: Colors.white,
letterSpacing: 3.0,
),
),
]),
),
ListTile(
title: Row(
children: <Widget>[
Expanded(
child: RaisedButton(
child: Text("delete"),
onPressed: delete,
color: Colors.grey[900],
textColor: Colors.white,
padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0),
)),
SizedBox(
width: 20.0,
),
],
),
)
]),
),
));
}
}
class Quote {
String text;
String author;
Quote({String this.text, String this.author});
}