Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mravn-google
Last active July 5, 2018 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mravn-google/5962e261ee61c82d8f298fd2fe03fd29 to your computer and use it in GitHub Desktop.
Save mravn-google/5962e261ee61c82d8f298fd2fe03fd29 to your computer and use it in GitHub Desktop.
Widget composition
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,
);
}
}
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