Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


project04 - The fourth knockdown 👊

Stateful and Stateless Widgets in Flutter

This app focuses on describing/making Stateful/Stateless Widgets and making a fresh Dart class by following these steps:

project04 > lib > src > app.dart

  1. class App extends StatelessWidget We create a new Dart class named App which extends (carries properties of) StatelessWidget class. A StatelessWidget is used when we don't want to save any data in our app. Since, we don't have anything to save right now, therefore we don't use the StatefulWidget.

  2. Widget build(context) Here we're returning a Widget, because, this is exactly what Flutter is all about! Also, we're using StatelessWidget, that's why. Next, we call the build() method which takes in the context.

  3. return MaterialApp Now, inside the Widget, we return the entire MaterialApp widget, exactly what we coded earlier in main.dart .

project04 > lib > main.dart

  1. runApp(App()); We change the runApp() method and call the App class which's inside the app.dart file making the project modularised.

  2. import 'src/app.dart'; Using App in the main class will not work as by default Flutter looks into lib folder of the project directory to run the app. Hence, we need to import the app.dart class.