Created
August 4, 2019 10:59
-
-
Save Eng-MFQ/04f63c77891851295dd236f79e97cced to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'DessertList.dart'; | |
Dessert dessert; | |
class DessertDetails extends StatelessWidget { | |
static final routeName = '/DessertDetails'; | |
@override | |
Widget build(BuildContext context) { | |
/// you should call this in the main widget the one that has a Material App | |
/// to get the passed arguments | |
dessert = ModalRoute.of(context).settings.arguments; | |
print(dessert); | |
return MaterialApp( | |
home: MyApp(), | |
); | |
} | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(), | |
body: Container( | |
color: Colors.blue, | |
child: Column( | |
mainAxisSize: MainAxisSize.min, | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: <Widget>[ | |
Image.network( | |
'${dessert.imgUrl}', | |
fit: BoxFit.cover, | |
), | |
Padding( | |
padding: const EdgeInsets.all(16.0), | |
child: Text( | |
'${dessert?.name}', | |
style: TextStyle(fontSize: 50, fontWeight: FontWeight.w900), | |
), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment