Reputation: 2872
I'm completely new to Dart and Flutter, and I've been absorbing as much info as possible from docs and tutorials. While Dart itself doesn't trouble me much, Flutter has been difficult so far. For example, I can't seem to wrap my head around this syntax from the Hello World app:
Scaffold(
appBar: AppBar(
title: Text('Welcome to Flutter'),
),
// ...
),
);
I can't find syntax like it in Dart docs. Is it a constructor, like ClassName(prop1:val1, prop2:val2)
?
Upvotes: 1
Views: 106
Reputation: 89965
You're observing Dart's optional named parameters. It's not Flutter-specific.
Upvotes: 1
Reputation: 88
Your intuition is correct. Scafford()
is instantiating a Widget (class) constructor, which you can see defined here in the docs.
Flutter UI is a lot of nested constructors like this. Many of the arguments to a Widget's constructor are just, themselves, Widgets.
In your Hello World example the Scaffold
Widget's appBar
parameter takes an AppBar
Widget. The AppBar
itself has a parameter named Title
which takes a Text
Widget.
Upvotes: 2