6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Dart2 で new や const が省略できる

Last updated at Posted at 2018-01-24

らしい

ということは、Flutterのコードがすっきりする。

これが

Widget build(BuildContext context) {
  return new Container(
    height: 56.0,
    padding: const EdgeInsets.symmetric(horizontal: 8.0),
    decoration: new BoxDecoration(color: Colors.blue[500]),
    child: new IconButton(
      icon: new Icon(Icons.menu),
      tooltip: 'Navigation menu',
    ),
  );
}

こうなる。

Widget build(BuildContext context) {
  return Container(
    height: 56.0,
    padding: const EdgeInsets.symmetric(horizontal: 8.0),
    decoration: BoxDecoration(color: Colors.blue[500]),
    child: IconButton(
      icon: const Icon(Icons.menu),
      tooltip: 'Navigation menu',
    ),
  );
}

※ ただし const は省略しないで書いておいたほうがよい

6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?