-
-
Save mravn-google/5962e261ee61c82d8f298fd2fe03fd29 to your computer and use it in GitHub Desktop.
Widget composition
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 'src/widgets.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
final Widget imageSection = ... | |
final Widget titles = ... | |
final Widget titleSection = ... | |
final Widget actionSection = Container( | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | |
children: <Widget>[ | |
Action(label: 'CALL', icon: Icons.call), | |
Action(label: 'ROUTE', icon: Icons.near_me), | |
Action(label: 'SHARE', icon: Icons.share), | |
], | |
), | |
); | |
final Widget textSection = ... | |
final Widget scaffold = ... | |
return MaterialApp( | |
title: 'Flutter Demo', | |
home: scaffold, | |
); | |
} | |
} |
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'; | |
class Action extends StatelessWidget { | |
Action({Key key, this.label, this.icon}) : super(key: key); | |
final String label; | |
final IconData icon; | |
@override | |
Widget build(BuildContext context) { | |
final Color color = Theme.of(context).primaryColor; | |
return Column( | |
mainAxisSize: MainAxisSize.min, | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
Icon(icon, color: color), | |
Container( | |
margin: const EdgeInsets.only(top: 8.0), | |
child: Text( | |
label, | |
style: TextStyle( | |
fontSize: 12.0, | |
fontWeight: FontWeight.w400, | |
color: color, | |
), | |
), | |
), | |
], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment