Last active
November 13, 2015 04:09
-
-
Save cilphex/6a35a47b8ac841ea37ba 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
class LandingPage extends StatefulComponent { | |
LandingPage(); | |
LandingPageState createState() => new LandingPageState(); | |
} | |
class LandingPageState extends State<LandingPage> { | |
void _showDrawer() { | |
... | |
} | |
// Approach 1 | |
Widget _buildToolBar() { | |
return new ToolBar( | |
left: new IconButton( | |
icon: 'navigation/menu', | |
onPressed: _showDrawer | |
), | |
center: new Text('Fitzgerald'), | |
right: [ new IconButton(icon: 'action/search') ] | |
); | |
} | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
toolBar: _buildToolBar(), | |
body: _buildBody() | |
); | |
} | |
// Approach 2 | |
// Atom highlights `_showDrawer` with: | |
// "Only static members can be accessed in initializers" | |
var toolbar = new ToolBar( | |
left: new IconButton( | |
icon: 'navigation/menu', | |
onPressed: _showDrawer | |
), | |
center: new Text('Fitzgerald'), | |
right: [ new IconButton(icon: 'action/search') ] | |
); | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
toolBar: toolbar, | |
body: _buildBody() | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment