Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Flutter introduction

Flutter introduction

In April 2023, I gave an online workshop on Flutter development in collaboration with 7 GDSC groups during Flutter Forward Extended with BCE Patna. Over 80 university students attended the workshop where I covered topics like synchronous and asynchronous programming in Dart, understanding REST API calls and integrating one response to a basic UI.

Code samples: https://github.com/flutter-uae/flutter-intro-movie-app
Event link: https://gdsc.community.dev/events/details/developer-student-clubs-bakhtiyarpur-college-of-engineering-patna-presents-advanced-concepts-in-flutter/

gerfalcon

April 02, 2023
Tweet

More Decks by gerfalcon

Other Decks in Technology

Transcript

  1. Introduc)on to Flu-er Senior Software Engineer @talabat , Delivery Hero

    Lecturer @Budapest University of Technology and Economics Co-organizer @Flutter Abu Dhabi & Dubai Csongor Vogel gerfalcon GerfalconVogel
  2. Senior Software Engineer, talabat About me Lecturer, Budapest University of

    Technology and Economics Organizer, Flutter Abu Dhabi & Dubai
  3. Widgets Stateless Widgets Stateful Widgets • Immutable • Cannot change

    its state • Ex: Icon, Text • Mutable • Can change state • setState() function • Ex: Checkbox, TextField
  4. In the previous episode What is Flutter? History of Flutter

    Advantages of Flutter Flutter Architecture Everything is a Widget Stateless vs Stateful Widgets Hot reload & Hot restart Live coding: Building Movie app UI
  5. Agenda Understanding some advanced widget & UI components Synchronous &

    Asynchronous programming Pubspec & package integration Understanding REST API calls Handling JSON responses Connecting Movie app UI with APIs Resources for Advance Flutter
  6. List UI @override Widget build(BuildContext context) { return Column( children:

    [ MovieListItem(!!...), MovieListItem(!!...) MovieListItem(!!...), !!/// (!!...) MovieListItem(!!...), ], ); }
  7. List UI @override Widget build(BuildContext context) { return SingleChildScrollView( child:

    Column( children: [ MovieListItem(!!...), MovieListItem(!!...), MovieListItem(!!...), !!/// (!!...) MovieListItem(!!...), ], ), ); }
  8. List UI @override Widget build(BuildContext context) { return SingleChildScrollView( child:

    Column( children: [ MovieListItem(...), MovieListItem(...), MovieListItem(...), /// (...) MovieListItem(...), ], ), ); } 60 FPS
  9. List UI @override Widget build(BuildContext context) { return SingleChildScrollView( child:

    Column( children: [ MovieListItem(!!...), MovieListItem(!!...), MovieListItem(!!...), !!/// (!!...) MovieListItem(!!...), ], ), ); } 60 FPS ❌
  10. List UI @override Widget build(BuildContext context) { return ListView( children:

    [ MovieListItem(...), MovieListItem(...), MovieListItem(...), /// (...) MovieListItem(...), ], ), ); }
  11. List UI @override Widget build(BuildContext context) { return ListView.builder( itemCount:

    100, itemBuilder: (context, index) { return MoviesListItem(!!...); }, ); }
  12. Refers to code that executes in a linear, step-by-step manner

    Synchronous programming void main() { functionA(); functionB(); functionC(); }
  13. Refers to code that executes in a linear, step-by-step manner

    Synchronous programming void main() { functionA(); longestFunctionEver(); functionC(); }
  14. Allows code to execute independently of the main program flow

    Asynchronous programming Multi-threading
  15. Allows code to execute independently of the main program flow

    Asynchronous programming Mul=-threading Dart’s single thread with Event Loop
  16. Allows code to execute independently of the main program flow

    Asynchronous programming Multi-threading Dart’s single thread with Event Loop
  17. A Future is an object in Dart and FluEer that

    represents a value that may not be available yet. Future
  18. A Future is an object in Dart and FluEer that

    represents a value that may not be available yet. Future asyncFetchData() async { !!/// (…) }
  19. A Future is an object in Dart and FluEer that

    represents a value that may not be available yet. Future Future<T> asyncFetchData() async { /// (…) } Returns with Future<T>
  20. A Future is an object in Dart and Flutter that

    represents a value that may not be available yet. Future Future<String> asyncFetchMovie() async { !!/// Long task await Future.delayed(Duration(…)); return 'Movie title'; } Returns with Future<T>
  21. A Future is an object in Dart and Flutter that

    represents a value that may not be available yet. Future Returns with Future<T> Can be used with the FutureBuilder widget @override Widget build(BuildContext context) { return FutureBuilder( future: future, builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasData) { return widgetToBuild; } else if (snapshot.hasError) { return Icon(Icons.error_outline); } else { return CircularProgressIndicator(); } }); }
  22. A Future is an object in Dart and FluEer that

    represents a value that may not be available yet. Future Returns with Future<T> Can be used with the FutureBuilder widget
  23. Wai=ng for User interac=on Time consuming tasks File I/O –

    reading & wri=ng files Bluetooth communica=on Image processing Complex computa=ons (3D rendering) Network requests ⏳💬 💾📂 📶🤝 🖼🔍 🧮🌟 🌐🚀
  24. REST (Representational State Transfer) is an architectural style for web

    services Understanding REST API calls HTTP methods like: • POST (Create) • GET (Read), • PUT (Update), • DELETE (Delete). 📱 🌐 REST
  25. JSON (JavaScript Object Notation) is a lightweight data interchange format

    Handling JSON responses Built-in support for JSON parsing with the dart:convert library Reflec=on -> Code genera=on 📱 🌐 JSON 📦
  26. What’s Next? Fancy custom scrolling - Slivers Asynchronous programming –

    Generators, Streams, error handling Animations - tween/physics-based State management - Provider, BLoC or Riverpod Networking - Authentication, headers and interceptors Persistent data - path, key-value data, SQLite Testing - unit, widget and integration tests Platform-specific APIs - Platform Channels
  27. Senior SoGware Engineer, talabat - Delivery Hero Lecturer, Budapest University

    of Technology and Economics Co-organizer, FluHer Abu Dhabi & Dubai Csongor Vogel Thank you! @GerfalconVogel In/csongorvogel @gerfalcon