@@ -9,6 +9,10 @@ import '../retro_button.dart';
99
1010// ignore: must_be_immutable
1111class ProductPage extends StatefulWidget {
12+ final Product product;
13+
14+ const ProductPage ({this .product});
15+
1216 @override
1317 _ProductPageState createState () => _ProductPageState ();
1418}
@@ -36,7 +40,7 @@ class _ProductPageState extends State<ProductPage> {
3640
3741 @override
3842 Widget build (BuildContext context) {
39- final Product args = ModalRoute . of (context).settings.arguments as Product ;
43+
4044 final double height = MediaQuery .of (context).size.height;
4145 final double width = MediaQuery .of (context).size.width;
4246 return Scaffold (
@@ -103,7 +107,7 @@ class _ProductPageState extends State<ProductPage> {
103107 mainAxisSize: MainAxisSize .min,
104108 crossAxisAlignment: CrossAxisAlignment .start,
105109 children: < Widget > [
106- for (String s in args .text.split (' ' ))
110+ for (String s in widget.product .text.split (' ' ))
107111 Text (
108112 s,
109113 style: const TextStyle (
@@ -135,7 +139,7 @@ class _ProductPageState extends State<ProductPage> {
135139 ],
136140 ),
137141 Text (
138- args .owner,
142+ widget.product .owner,
139143 style: const TextStyle (
140144 fontWeight: FontWeight .bold, color: Colors .white),
141145 ),
@@ -159,7 +163,7 @@ class _ProductPageState extends State<ProductPage> {
159163 fontSize: 11 ),
160164 ),
161165 Text (
162- args .height.toString (),
166+ widget.product .height.toString (),
163167 overflow: TextOverflow .ellipsis,
164168 style: const TextStyle (
165169 fontWeight: FontWeight .bold,
@@ -180,7 +184,7 @@ class _ProductPageState extends State<ProductPage> {
180184 fontSize: 11 ),
181185 ),
182186 Text (
183- args .seller,
187+ widget.product .seller,
184188 overflow: TextOverflow .ellipsis,
185189 style: const TextStyle (
186190 fontWeight: FontWeight .bold,
@@ -204,7 +208,7 @@ class _ProductPageState extends State<ProductPage> {
204208 borderColor: Colors .white,
205209 child: Center (
206210 child: Text (
207- args .amount,
211+ widget.product .amount,
208212 style: const TextStyle (
209213 fontWeight: FontWeight .bold,
210214 color: RelicColors .primaryColor,
@@ -292,7 +296,7 @@ class _ProductPageState extends State<ProductPage> {
292296 Transform .translate (
293297 offset: const Offset (120 , - 180 ),
294298 child: Image .asset (
295- args .image,
299+ widget.product .image,
296300 width: 300 ,
297301 height: 300 ,
298302 ),
0 commit comments