Let's start by running the app. You should see a blank canvas to play with:
- Add some text to the DeepTree class:
class DeepTree extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Text('Its all widgets!'),
);
}
}
- Compile and run the code. You'll get the following result:
- We can see that in the preceding screenshot, the text is in the top corner and it can barely be seen. How about we wrap it in a Center widget?
- Move your cursor over the Text constructor and type the following:
- In Android Studio: Ctrl + Enter (or Command + Enter on a Mac)
- In Visual Studio Code (VS Code): Ctrl + . (or Command + . on a Mac)
to bring up the intentions dialog. Then, select Center widget / Wrap with Center.
- Perform a hot reload, and the text will move to the center of the screen:
- That looks slightly better, but how about we change that single widget to a Column...