Skip to content

Instantly share code, notes, and snippets.

@timsneath
Created May 4, 2018 20:28
Show Gist options
  • Save timsneath/054f8d800bb9c01e369dc04de9ec12f2 to your computer and use it in GitHub Desktop.
Save timsneath/054f8d800bb9c01e369dc04de9ec12f2 to your computer and use it in GitHub Desktop.
Simple example of a Widget build method without new keyword in Dart 2.
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: Text(widget.title),
actions: <Widget>[
IconButton(
icon: Icon(Icons.info),
onPressed: _aboutAction,
),
IconButton(
icon: Icon(Icons.share),
onPressed: _shareAction,
)
],
),
body: Center(
child: _body(),
),
floatingActionButton: FloatingActionButton(
onPressed: _refresh,
tooltip: 'Refresh',
child: Icon(Icons.refresh),
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment