Flutter ਵਿੱਚ, ਸਭ ਕੁਝ ਇੱਕ widget ਹੈ — UI ਤੱਤ (ਬਟਨ, ਟੈਕਸਟ, ਚਿੱਤਰ), ਲੇਆਉਟ ਢਾਂਚੇ (ਕਤਾਰਾਂ, ਕਾਲਮ, ਪੈਡਿੰਗ), ਅਤੇ ਐਪ ਆਪ ਹੀ ਸਭ widgets ਹਨ। Widgets ਅਟੱਲ ਨਿਰਮਾਣ ਬਲਾਕ ਹਨ ਜੋ ਪੂਰੇ ਯੂਜ਼ਰ ਇੰਟਰਫੇਸ ਨੂੰ ਬਣਾਉਂਦੇ ਹਨ।
ਸਭ ਕੁਝ ਇੱਕ widget ਹੈ
Widgets describe the UI. EVERYTHING is a widget:
→ visible elements: Text, Image, Icon, Button, etc.
→ layout: Row, Column, Container, Padding, Center, Stack, etc.
→ structure: Scaffold (page structure), AppBar, etc.
→ even the app itself (MaterialApp) and abstract things (Padding, Theme)
→ You build UI by COMPOSING widgets into a tree (widgets contain other widgets).
Widgets ਨੂੰ ਇੱਕ ਰੁੱਖ ਵਿੱਚ ਕੰਪੋਜ਼ ਕਰਨਾ
// build a UI by NESTING widgets (composition)
Scaffold( // page structure
appBar: AppBar(title: Text('Home')), // app bar with text
body: Center( // centers its child
child: Column( // vertical layout
children: [
Text('Hello'), // text widget
ElevatedButton( // a button
onPressed: () {},
child: Text('Click'),
),
],
),
),
)
// → a WIDGET TREE: Scaffold > Center > Column > [Text, Button]
