|
1 | | -# Flutter TodoList Tutorial |
2 | | - |
3 | | -Create a simple todolist Flutter application |
4 | | -<div align="center"> |
5 | | - <img src="https://user-images.githubusercontent.com/6057298/109024720-f4041b00-76b5-11eb-9221-ad8660315a0b.gif" height="600"> |
6 | | -</div> |
7 | | - |
8 | | -To run the project on your machine: |
9 | | -- make sure you have Dart and Flutter installed: https://flutter.dev/docs/get-started/install |
10 | | -- clone this repository with `git clone [email protected]:dwyl/flutter-todo-list-tutorial.git` |
11 | | -- Before running the application check that all the tests are passing with `flutter test` |
12 | | - |
13 | | -The application contains the following main folders: |
14 | | - |
15 | | -- `lib/models` Contains the `task` and `todolist` models |
16 | | -- `lib/screens` Contains the different screens of the application. Currently only the tasks screen exists. |
17 | | - In the tasks folder you can find the task, tasks and todolist widgets which define the UI of this screen. |
18 | | -- `lib/widgets` This folder is used to store widgets used on multiple screen, currently this folder is empty |
19 | | -- `test` This contains the unit, widget and integration tests. |
20 | | - |
21 | | -The application is using [Provider](https://pub.dev/packages/provider) to manage the states. |
22 | | -Providers allow us to notify the UI of the application when a state change. For example when a |
23 | | -task is toggled the `notifyListener` function is called which let the application knows that a refresh of the |
24 | | -task's UI is required: |
25 | | - |
26 | | -```dart |
27 | | - void toggle() { |
28 | | - completed = !completed; |
29 | | - notifyListeners(); |
30 | | - } |
31 | | -``` |
| 1 | +# Flutter Todo App Tutorial |
32 | 2 |
|
33 | | -## Flutter concepts |
| 3 | +Quickly learn how to setup |
| 4 | +a Todo list management app |
| 5 | +using `Flutter` and `Riverpod` |
| 6 | +for app state management. |
34 | 7 |
|
35 | | -### Widgets |
| 8 | +# What? 💡 |
36 | 9 |
|
37 | | -Flutter is using Widgets to create the applications' UI. |
38 | | -Widgets let you declare how and what to render on the screen. |
| 10 | +This is a simple **Todo list application** |
| 11 | +that allows you to track todo items that you |
| 12 | +create and edit. |
| 13 | +You can check your current active todo items, |
| 14 | +check the completed ones and |
| 15 | +also have an overview of every task you've created. |
| 16 | +Oh! And it's also fully tested! 😃 |
39 | 17 |
|
40 | | -Widgets can be composed to create more complex UI, creating a widgets tree, |
41 | | -similar to the [Document Object Model](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction) |
42 | | -which is used to represent html pages. |
| 18 | +This app connects to an API |
| 19 | +implemented with [`Phoenix`](https://github.com/dwyl/learn-phoenix-framework) |
| 20 | +to persist the todo list items. |
43 | 21 |
|
44 | | -For example a todo list app could be represented with the follownig wireframe: |
| 22 | +# Why? 🤷 |
45 | 23 |
|
46 | | - |
| 24 | +As we are focused on building our [`mvp`](https://github.com/dwyl/mvp), |
| 25 | +we are looking to have the frontend counterpart |
| 26 | +that is **cross-platform** and fastly *iterable*. |
| 27 | +Setting this walkthrough will help *you* |
| 28 | +understand better the fundamentals of having |
| 29 | +an app with a robust state management library |
| 30 | +that can be used in **real-world applications**. |
47 | 31 |
|
48 | | -From there we can start to have an idea of the widgets tree structure: |
| 32 | +It also helps *us* to have a detailed guide |
| 33 | +of a fully tested app that is documented |
| 34 | +and is something we can go back to. 😊 |
| 35 | + |
| 36 | +# How? 💻 |
| 37 | + |
| 38 | +## 0. Prerequisites and preview |
| 39 | + |
| 40 | +It's advisable to have a basic understanding |
| 41 | +of the `Dart`-lang and of `Flutter`. |
| 42 | +If this is your first tutorial with Flutter, |
| 43 | +we *highly* advise you to check our |
| 44 | +learning repositories to get started! |
| 45 | + |
| 46 | +https://github.com/dwyl/learn-dart |
| 47 | + |
| 48 | +https://github.com/dwyl/learn-flutter |
49 | 49 |
|
50 | | - |
51 | 50 |
|
52 | | -see also: |
| 51 | +Before building this app, |
| 52 | +let's check out the final result! |
| 53 | +After cloning this repository |
| 54 | +and traveling to the directory you cloned the repo in, |
| 55 | +run the following command to install the dependencies. |
53 | 56 |
|
54 | | -- Introduction to widgets: <https://flutter.dev/docs/development/ui/widgets-intro> |
55 | | -- Widget catalog: <https://flutter.dev/docs/development/ui/widgets> |
56 | | -- widget index: <https://flutter.dev/docs/reference/widgets> |
57 | | -- widget of the week on Youtube: <https://www.youtube.com/watch?v=b_sQ9bMltGU&list=PLjxrf2q8roU23XGwz3Km7sQZFTdB996iG> |
| 57 | +```sh |
| 58 | +flutter pub get |
| 59 | +``` |
58 | 60 |
|
59 | | -### Create a new Flutter application |
| 61 | +To run the app, plug your phone |
| 62 | +or start the emulator and run the following. |
60 | 63 |
|
61 | | -#### A quick CLI tour |
| 64 | +```sh |
| 65 | +flutter devices |
| 66 | +``` |
62 | 67 |
|
63 | | -You can create a new Flutter project with the following command line: |
| 68 | +If you find the wanted device, run: |
64 | 69 |
|
65 | 70 | ```sh |
66 | | -flutter create --org com.dwyl --project-name todolist . |
| 71 | +flutter run |
67 | 72 | ``` |
68 | 73 |
|
69 | | -This will create the project `todolist` in the current folder `.`. |
70 | | -The `--org` flag uses the [reverse domain name notation](https://en.wikipedia.org/wiki/Reverse_domain_name_notation) to identify your application. |
| 74 | +And you should get your app running! |
71 | 75 |
|
72 | | -You can then run the application with `flutter run` and run the tests with `flutter test`. |
| 76 | +If you want a more in-depth guide |
| 77 | +of how to get a Flutter app running |
| 78 | +on a real device or emulator, |
| 79 | +check our [`learn-flutter`](https://github.com/dwyl/learn-flutter) |
| 80 | +tutorial. |
| 81 | +We will get you sorted in no time! |
73 | 82 |
|
74 | | -For the list of command type `flutter help`. |
75 | | -For more details about a specific command, for example `create`, run `flutter create --help` |
| 83 | +If you open the app, |
| 84 | +you should be able to see the following. |
76 | 85 |
|
77 | | -#### Material Design |
| 86 | + |
78 | 87 |
|
79 | | -[Material Design](https://material.io/design/introduction) is a guideline to create user interface. |
80 | | -Flutter implements the guideline with the [material components widgets](https://flutter.dev/docs/development/ui/widgets/material). |
81 | | -This list of widgest allow us to create rapdly a UI folling the best practices from material design. |
82 | | -To use these widgets you need first to import the `material` Dart package with `import 'package:flutter/material.dart';` |
83 | | -You can then browse all the material widgets and select the ones required for your application <https://api.flutter.dev/flutter/material/material-library.html> |
84 | 88 |
|
85 | | -You have also the possiblity to create an IOs look by using the [Cupertino widgets package](https://flutter.dev/docs/development/ui/widgets/cupertino) |
| 89 | +All the tests should also pass. |
| 90 | +If you want to check this, |
| 91 | +you can run `flutter test`. |
86 | 92 |
|
87 | | -#### Main Widgets used |
| 93 | +This app uses [`Riverpod`](https://riverpod.dev/) |
| 94 | +for state management inside the widget tree. |
| 95 | +This library will allow us to declare |
| 96 | +and use shared state from anywhere |
| 97 | +and have a greater control on |
| 98 | +UI rebuilds. |
88 | 99 |
|
89 | | -- [Scaffold](https://api.flutter.dev/flutter/material/Scaffold-class.html) |
90 | | -- [AppBar](https://api.flutter.dev/flutter/material/AppBar-class.html) |
91 | | -- [CheckboxListTile](https://api.flutter.dev/flutter/material/CheckboxListTile-class.html) |
92 | | -- [ListView](https://api.flutter.dev/flutter/widgets/ListView-class.html) |
93 | | -- [TextField](https://api.flutter.dev/flutter/material/TextField-class.html) |
94 | | -- [Column](https://api.flutter.dev/flutter/widgets/Column-class.html) |
95 | | -- [Expanded](https://api.flutter.dev/flutter/widgets/Expanded-class.html) |
96 | 100 |
|
97 | | -Note that the `Column` and `Exapanded` widgets are "space" widgets. |
| 101 | +Here is how our widget tree |
| 102 | +will look like. |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | +## 1. Project setup |
98 | 107 |
|
99 | | -Flutter provide a widget inspector where you can see the full tree |
100 | | -of the application: |
101 | 108 |
|
102 | | - |
|
0 commit comments