1. Flutter - App Basics
Everything in a flutter app is a widget.
Everything is a widget within a widget.
The root widget is the core and expanding under it are everything else just like a tree. A widget tree.
Widgets always need properties to define them.
Creating Project
1. Create a folder
2. Open CMD
3. "flutter create projectname"
project names with spaces are typed with _
no dashes or whitespace
Ex: Project_Name
Hot Reload with VSCODE.
1. Open CMD in a flutter project.
2. flutter run
3. Controls:
r = hot reload
shift+r = full reload
ctrl+c = quit
App needs to run by initialing a root widget in main:
void main() => runApp(ROOTWIDGETNAMEHERE);
// can put any widget between parenthesis.
Basic Start of an App using MaterialApp() widget as the root:
void main() => runApp(const MaterialApp(
home: Text("HELLO"),
));
// home property will have a text widget. specifies what will be on home screen when app loads.
App using a scaffold (basic starter root widget):
void main() => runApp(MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("TITLE"),
centerTitle: true,
),
),
));
void main() => runApp(MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("TITLE"),
centerTitle: true,
),
body: Center(
child: Text("HELLO WORLD"),
),
floatingActionButton: FloatingActionButton(
onPressed: (){},
child: Text('TAP'),
),
),
));
Comments
Post a Comment