Slide 1

Slide 1 text

Getting started with Flutter Speaker: Yujiro Kisu GDSC Tokyo Metropolitan University @yuyu_lab_tmu

Slide 2

Slide 2 text

Agenda Speaker: Yujiro Kisu GDSC Tokyo Metropolitan University @yuyu_lab_tmu ● What is Flutter? ○ What is widget? ● Basic app setting ● Lecture ● Break (10 min.) ● Add detail designs (More if we have time)

Slide 3

Slide 3 text

Flutter ● What is Flutter? ○ Tool for UI development (SDK) ○ Uses Dart language ○ Made by Google ○ Multi-platform framework ● Uses in this event ○ Framework for an app ○ Experience robust/quick app development ○ Requirement in this hackathon

Slide 4

Slide 4 text

What we make today

Slide 5

Slide 5 text

What is widget? ● Unit for app UI ● There are different types/functionalities ● Customizable one by one ● Widget can be nested in another widget nested in another widget nested in an.. ● Widgets can send information to each other

Slide 6

Slide 6 text

Image: https://codelabs.developers.google.com/codelabs/flutter-codelab-first?hl=ja#0 Widgets

Slide 7

Slide 7 text

Join at slido.com #1712352 ⓘ Click Present with Slido or install our Chrome extension to display joining instructions for participants while presenting. https://app.sli.do/event/cTMXFAX8S7Jt3notKhBeD6

Slide 8

Slide 8 text

Flutter ‘environment’ setting ● Name of the app ● Flutter version ● Locations of ○ Assets ○ Fonts ○ Dependencies pubspec.yaml ⬅copy code from here More info: Change it to yours!

Slide 9

Slide 9 text

Flutter ‘proofreading’ setting ‘true’ makes it strict analysis_options.yaml ⬅copy code from here More info:

Slide 10

Slide 10 text

Flutter main ‘canvas’ ● Main entry of a Flutter app ● Write code here (this workshop) lib/main.dart ⬅copy code from here

Slide 11

Slide 11 text

F5 Checkpoint: Wait until everyone is finished

Slide 12

Slide 12 text

Import each package/file to use in ‘main.dart’ This is called when ‘main.dart’ is executed ‘runApp()’ runs ‘MyApp()’ Explanations 🚚

Slide 13

Slide 13 text

Explanations ‘extends’ creates a ‘copy’ from a ‘template’

Slide 14

Slide 14 text

Explanations MyApp ChangeNotifierProvider MyAppState MyAppState

Slide 15

Slide 15 text

Explanations MyApp ChangeNotifierProvider MyAppState MyHomePage Scafold Column Text Text

Slide 16

Slide 16 text

Let its super class (‘template’) know MyApp()’s identification Explanations Create a widget with a context MyApp MyHomePage MyApp MyHomePage

Slide 17

Slide 17 text

10 min. Break ~18:43

Slide 18

Slide 18 text

ElevatedButton( onPressed: () { appState.getNext(); }, child: Text('Next'), ), Copy code from here ⬇ and where should we put?? Checkpoint: Wait until everyone is finished

Slide 19

Slide 19 text

void getNext() { current = WordPair.random(); notifyListeners(); } } Checkpoint: Wait until everyone is finished Copy code from here ⬇ and where should we put?? MyAppState

Slide 20

Slide 20 text

Wanna refactor this … ??

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Checkpoint: Wait until everyone is finished Padding + Widget (Card)

Slide 23

Slide 23 text

Checkpoint: Wait until everyone is finished @override Widget build(BuildContext context) { final theme = Theme.of(context); // ← Add this. return Card( color: theme.colorScheme.primary, // ← And also this. child: Padding( padding: const EdgeInsets.all(20), child: Text(pair.asLowerCase), ), ); }

Slide 24

Slide 24 text

Checkpoint: Wait until everyone is finished @override Widget build(BuildContext context) { final theme = Theme.of(context); // ↓ Add this. final style = theme.textTheme.displayMedium!.copyWith( color: theme.colorScheme.onPrimary, ); return Card( color: theme.colorScheme.primary, child: Padding( padding: const EdgeInsets.all(20), // ↓ Change this line. child: Text(pair.asLowerCase, style: style), ), ); }

Slide 25

Slide 25 text

Checkpoint: Wait until everyone is finished mainAxisAlignment: MainAxisAlignment.center, ‘Center’ the ‘Column’ +

Slide 26

Slide 26 text

Let’s do More on Codelabs! Click here to go to Codelabs

Slide 27

Slide 27 text

お疲れさまでした!

Slide 28

Slide 28 text

Next up … Day4 Flutter & Firebase