-- Body takes only one widget so we cant add another widget sperating it by comma.
-- For that we need to understand that there are different types of widgets in flutter.
-- we have visible widgets which are related to user input and outputting data things like a RaisedButton(), Text(), Card()
. these are widgets that drawn on the screen users see.
-- but equally crucial are invisible widgets that help us with layout and with controlling how our widget tree behaves and how it looks like there we get things like, row, column, listview
and so on.
-- we dont see them ourself but helps us with structuring our content, so these widgets give our app structure and control how visible widgets are drawn on the screen.
-- it also ships with flutter. which belongs to the both category (visible and invisible widgets).
-- by default its invisible but we can also give it some styling so we can see it.
body:Column()
-- if we want to render widgets in column(above each other) we can use column widget. if we want to render widgets next to each other we would have used Row()
.
body:Column(children:<Widget>[
Text('Question1'),
RaisedButton(child:Text('Answer 1'),onPressed:null)
])
-- Column
has children
named argument which actually takes a list of widgets.
var questions = ['question1','question2']
-- About []
- dart or other programming languages have concept of lists
. lists are another type of data basically its a group of data so you can have list of strings like variable questions
.
-- About <Widget>[]
- this is so-called generic-type
we can also drop it because of type-inference, this tells dart that this list holds here list of widgets. generic type is an annotation which you can have on some types this allows dart to tell that this is not the list of anything but list of some specific data type. because of type-inference we can remove that as soon we start adding widgets.
-- RaisedButton()
is a button with background-color and a little hover effect. but with flutter v-2 RaisedButton() is deprecated. Alternatively u can use ElevatedButton()
.
-- onPressed()
it would be a function that will be executed when we click on this button. if we set null value then that button will be disabled.