Skip to content

Commit

Permalink
lesson-20
Browse files Browse the repository at this point in the history
  • Loading branch information
iamshaunjp committed Aug 15, 2019
1 parent c4035fc commit 3207f27
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 30 deletions.
34 changes: 4 additions & 30 deletions quotes/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'quote.dart';
import 'quote_card.dart';

void main() => runApp(MaterialApp(
home: QuoteList()
Expand All @@ -18,35 +19,6 @@ class _QuoteListState extends State<QuoteList> {
Quote(author: 'Oscar Wilde', text: 'The truth is rarely pure and never simple')
];

Widget quoteTemplate(quote) {
return Card(
margin: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 0),
child: Padding(

This comment has been minimized.

Copy link
@Murtadha240

Murtadha240 Mar 6, 2021

qq

This comment has been minimized.

Copy link
@njengathegeek

njengathegeek Mar 20, 2021

Thanks Flutter Ninja

padding: const EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(
quote.text,
style: TextStyle(
fontSize: 18.0,
color: Colors.grey[600],
),
),
SizedBox(height: 6.0),
Text(
quote.author,
style: TextStyle(
fontSize: 14.0,
color: Colors.grey[800],
),
),
],
),
)
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -57,11 +29,13 @@ class _QuoteListState extends State<QuoteList> {
backgroundColor: Colors.redAccent,
),
body: Column(
children: quotes.map((quote) => quoteTemplate(quote)).toList(),
children: quotes.map((quote) => QuoteCard(quote: quote)).toList(),
),
);
}
}





38 changes: 38 additions & 0 deletions quotes/lib/quote_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:flutter/material.dart';
import 'quote.dart';

class QuoteCard extends StatelessWidget {

final Quote quote;
QuoteCard({ this.quote });

@override
Widget build(BuildContext context) {
return Card(
margin: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 0),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(
quote.text,
style: TextStyle(
fontSize: 18.0,
color: Colors.grey[600],
),
),
SizedBox(height: 6.0),
Text(
quote.author,
style: TextStyle(
fontSize: 14.0,
color: Colors.grey[800],
),
),
],
),
)
);
}
}

0 comments on commit 3207f27

Please sign in to comment.