Skip to content

Commit

Permalink
Fix OWASP-BLT#12: Convert issue card to stateless
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparsh1212 committed Apr 5, 2021
1 parent 686cb04 commit 3f7b029
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 71 deletions.
72 changes: 72 additions & 0 deletions lib/pages/components/issue_intro_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import 'package:flutter/material.dart';

class IssueCard extends StatelessWidget {
final String description;
final String imageSrc;

IssueCard({required this.description, required this.imageSrc});

@override
Widget build(BuildContext context) {
return Column(
children: [
Card(
margin: EdgeInsets.all(10),
elevation: 0,
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(15.0),
bottomRight: Radius.circular(15.0))),
child: Container(
height: 130,
padding: const EdgeInsets.all(0),
child: Row(
children: <Widget>[
Container(
width: 200,
height: 130,
child: Hero(
tag: imageSrc,
child: DecoratedBox(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(imageSrc),
fit: BoxFit.cover,
),
),
),
),
),
Flexible(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10,
),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Flexible(
child: Text(
description,
overflow: TextOverflow.fade,
softWrap: true,
style: TextStyle(
fontWeight: FontWeight.w600, fontSize: 12),
),
),
],
),
],
),
),
)
],
),
),
)
],
);
}
}
79 changes: 8 additions & 71 deletions lib/pages/issues.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './components/issue_intro_card.dart';
import 'package:flutter/material.dart';
import '../pages/issue_detail.dart';

Expand Down Expand Up @@ -119,77 +120,13 @@ class PaginatedClassState extends State<PaginatedClass>
),
)
},
child: Column(
children: [
Card(
margin: EdgeInsets.all(10),
elevation: 0,
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(15.0),
bottomRight: Radius.circular(15.0))),
child: Container(
height: 130,
padding: const EdgeInsets.all(0),
child: Row(
children: <Widget>[
Container(
width: 200,
height: 130,
child: Hero(
tag: (snapshot.data! as DataModel)
.results[index]
.screenshot,
child: DecoratedBox(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
(snapshot.data! as DataModel)
.results[index]
.screenshot,
),
fit: BoxFit.cover,
),
),
),
),
),
Flexible(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10,
),
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Flexible(
child: Text(
(snapshot.data!
as DataModel)
.results[index]
.description,
overflow:
TextOverflow.fade,
softWrap: true,
style: TextStyle(
fontWeight:
FontWeight.w600,
fontSize: 12),
),
),
],
),
],
),
),
)
],
),
),
)
],
child: IssueCard(
description: (snapshot.data! as DataModel)
.results[index]
.description,
imageSrc: (snapshot.data! as DataModel)
.results[index]
.screenshot,
),
);
});
Expand Down

0 comments on commit 3f7b029

Please sign in to comment.