SlideShare a Scribd company logo
1 of 46
Download to read offline
BUILDING APPS WITH
FLUTTER
HILLEL COREN
A BIT ABOUT ME…
2
APP STORE RATING
3
“FLUTTER IS
AWESOME!”
–Most developers who have tried it
4
5
6
7
Source: https://www.dizzain.com/blog/insights/flutter/
DECLARATIVE UI
8
STATE MANAGEMENT
▸ setState
▸ Provider
▸ BLoC
▸ MobX
▸ Redux
9
*https://blog.novoda.com/introduction-to-redux-in-flutter/
10
REDUX PERFORMANCE
▸ Rebuilding BLoC vs Redux
▸ Importance of memoization
▸ Set distinct on the view model
▸ Keep number of layers to a minimum
11
REDUX SAMPLE
▸ Always use Built Value
▸ Avoid using a StoreBuilder in main.dart
▸ Pass view model to the view/avoid mapping
▸ Restructure to group by feature
▸ Only need flutter_redux and redux_logging
12
13
14
PERSISTENCE
▸ Separate AppState in to data, ui and auth
▸ Persist each section separately
▸ Use PersistUI and PersistData interfaces
▸ Use similar approach to track loading
▸ Clear state if app version is different
15
abstract class AppState
implements Built<AppState, AppStateBuilder> {
bool get isLoading;
bool get isSaving;
AuthState get authState;
DataState get dataState;
UIState get uiState;
}
16
class StopLoading {}
class PersistUI {}
class PersistData {}
// Client actions
class LoadClientRequest implements StartLoading {}
class LoadClientSuccess implements StopLoading,
PersistData {
17
class StopLoading {}
class PersistUI {}
class PersistData {}
// Client actions
class LoadClientRequest implements StartLoading {}
class LoadClientSuccess implements StopLoading,
PersistData {
18
class StopLoading {}
class PersistUI {}
class PersistData {}
// Client actions
class LoadClientRequest implements StartLoading {}
class LoadClientSuccess implements StopLoading,
PersistData {
19
EntityUIState productReducer(ProductState state, dynamic action) {
return state.rebuild((b) => b
..editing = editingReducer(state.editing, action).toBuilder());
}
EntityUIState productReducer(ProductState state, dynamic action) {
return state.rebuild((b) => b
..editing.replace(editingReducer(state.editing, action)));
} Error: A value of type ‘…’ can't be assigned
to a variable of type ‘…Builder’.
EntityUIState productReducer(ProductState state, dynamic action) {
return state.rebuild((b) => b
..editing = editingReducer(state.editing, action).toBuilder());
}
EntityUIState productReducer(ProductState state, dynamic action) {
return state.rebuild((b) => b
..editing.replace(editingReducer(state.editing, action)));
} Error: A value of type ‘…’ can't be assigned
to a variable of type ‘…Builder’.
DATA CACHING
▸ All data is cached to the device
▸ Last updated timestamp is stored in the state
▸ Pass the timestamp when requesting new data
▸ Pull to refresh or auto-refresh after 15 minutes
▸ Autoload after certain events. ie, saving an invoice
22
int get lastUpdated;
BuiltMap<int, ProductEntity> get map;
bool get isLoaded => lastUpdated > 0;
bool get isStale {
if (! isLoaded) {
return true;
}
return DateTime.now().millisecondsSinceEpoch
23
int get lastUpdated;
BuiltMap<int, ProductEntity> get map;
bool get isLoaded => lastUpdated > 0;
bool get isStale {
if (! isLoaded) {
return true;
}
return DateTime.now().millisecondsSinceEpoch
24
int get lastUpdated;
BuiltMap<int, ProductEntity> get map;
bool get isLoaded => lastUpdated > 0;
bool get isStale {
if (! isLoaded) {
return true;
}
return DateTime.now().millisecondsSinceEpoch
25
VIEW MODELS
▸ View code should be UI/layout focused
▸ Nested view models
▸ Options to pass data to views
▸ Pass AppState as property on view model
▸ Pass field as property on view model
▸ Access AppState in view using context
26
MEMOIZATION
▸ Keep build method fast
▸ Simple Dart package available: memoize
▸ memoX where X is the number of parameters
27
List<int> activeClientsSelector(
BuiltMap<int, ClientEntity> clientMap,
BuiltList<int> clientList) {
return clientList.where((clientId) =>
clientMap[clientId].isActive).toList();
}
final memoizedActiveClients = memo2((
BuiltMap<int, ClientEntity> clientMap,
BuiltList<int> clientList) =>
List<int> activeClientsSelector(
BuiltMap<int, ClientEntity> clientMap,
BuiltList<int> clientList) {
return clientList.where((clientId) =>
clientMap[clientId].isActive).toList();
}
final memoizedActiveClients = memo2((
BuiltMap<int, ClientEntity> clientMap,
BuiltList<int> clientList) =>
FORMS
▸ Built Value enables change tracking
▸ Prefer didChangeDependencies() over
iniState()
▸ Avoid @nullable, set default value in
constructor
▸ Static negative counter for new ids
▸ Use completers in view models
30
NAVIGATION
▸ Handle navigation in middleware
▸ Pass context in actions
▸ Use completers for wrap up code
▸ Use pop() to pass back value
▸ snackbarCompleter and popCompleter
31
final Completer<Null> completer = Completer<Null>();
completer.future.then((_) {
Scaffold.of(context)
.showSnackBar(SnackBar(content: SnackBarRow(message: message)));
}).catchError((Object error) {
showDialog<ErrorDialog>(
context: context,
builder: (BuildContext context) => ErrorDialog(error));
});
return completer;
final Completer<Null> completer = Completer<Null>();
completer.future.then((_) {
Scaffold.of(context)
.showSnackBar(SnackBar(content: SnackBarRow(message: message)));
}).catchError((Object error) {
showDialog<ErrorDialog>(
context: context,
builder: (BuildContext context) => ErrorDialog(error));
});
return completer;
final Completer<Null> completer = Completer<Null>();
completer.future.then((_) {
Scaffold.of(context)
.showSnackBar(SnackBar(content: SnackBarRow(message: message)));
}).catchError((Object error) {
showDialog<ErrorDialog>(
context: context,
builder: (BuildContext context) => ErrorDialog(error));
});
return completer;
switch (action) {
case EntityAction.archive:
store.dispatch(ArchiveInvoiceRequest(
snackBarCompleter(context, localization.archivedInvoice),
invoice.id));
break;
...
}
CODE GENERATOR
▸ Reduces need for a lot of copy/replace
▸ Two main commands:
▸ Init: Update code with your app info
▸ Make: Generate individual module
▸ Creates a large amount of code
▸ Important to get it right at the beginning
36
BEST PRACTICES
▸ analysis_options.yaml
▸ sentry.io or Crashlytics
▸ Built Value
▸ Create lots of widgets, ie. IconText
▸ Read the flutter_redux code
37
APP STORE RATING
38
APP STORE RATING
39
PLATFORMS: CURRENT
40
Mobile
PLATFORMS: NEXT
41
Mobile
Desktop
PLATFORMS: FUTURE
42
Mobile
Desktop
Web
FLUTTER WEB DEMO [BETA]
https://demo.invoicing.co
43
WHO TO FOLLOW
▸ Tim Sneath - @timsneath
▸ Eric Seidel - @_eseidel
▸ Martin Aguinis - @MartinAguinis
▸ Nilay Yener - @nlycskn
▸ Andrew Brogdon - @RedBrogdon
▸ Emily Fortuna - @bouncingsheep
▸ Filip Hráček - @filiphracek
44
IT’S ALL WIDGETS!
45
HILLEL.DEV
@HILLELCOREN

More Related Content

Similar to Building Apps with Flutter - Hillel Coren, Invoice Ninja

Provisioning & Migration with p2: Case study - The Good, the Bad and the Ugly
Provisioning & Migration with p2: Case study - The Good, the Bad and the UglyProvisioning & Migration with p2: Case study - The Good, the Bad and the Ugly
Provisioning & Migration with p2: Case study - The Good, the Bad and the Uglychristianbourgeois
 
The evolution of redux action creators
The evolution of redux action creatorsThe evolution of redux action creators
The evolution of redux action creatorsGeorge Bukhanov
 
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinGet the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinXamarin
 
Calculator Week2.DS_Store__MACOSXCalculator Week2._.DS_St.docx
Calculator Week2.DS_Store__MACOSXCalculator Week2._.DS_St.docxCalculator Week2.DS_Store__MACOSXCalculator Week2._.DS_St.docx
Calculator Week2.DS_Store__MACOSXCalculator Week2._.DS_St.docxRAHUL126667
 
Workshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & ReduxWorkshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & ReduxVisual Engineering
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Mahmoud Hamed Mahmoud
 
Redux. From twitter hype to production
Redux. From twitter hype to productionRedux. From twitter hype to production
Redux. From twitter hype to productionFDConf
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best PracticesYekmer Simsek
 
Developing AIR for Android with Flash Professional
Developing AIR for Android with Flash ProfessionalDeveloping AIR for Android with Flash Professional
Developing AIR for Android with Flash ProfessionalChris Griffith
 
Redux. From twitter hype to production
Redux. From twitter hype to productionRedux. From twitter hype to production
Redux. From twitter hype to productionJenya Terpil
 
Battle of React State Managers in frontend applications
Battle of React State Managers in frontend applicationsBattle of React State Managers in frontend applications
Battle of React State Managers in frontend applicationsEvangelia Mitsopoulou
 
ASP.NET MVC Internals
ASP.NET MVC InternalsASP.NET MVC Internals
ASP.NET MVC InternalsVitaly Baum
 
Converting Your Mobile App to the Mobile Cloud
Converting Your Mobile App to the Mobile CloudConverting Your Mobile App to the Mobile Cloud
Converting Your Mobile App to the Mobile CloudRoger Brinkley
 
Building cross-platform mobile apps with React Native (Jfokus 2017)
Building cross-platform mobile apps with React Native (Jfokus 2017)Building cross-platform mobile apps with React Native (Jfokus 2017)
Building cross-platform mobile apps with React Native (Jfokus 2017)Maarten Mulders
 
Improving android experience for both users and developers
Improving android experience for both users and developersImproving android experience for both users and developers
Improving android experience for both users and developersPavel Lahoda
 
Droidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon Berlin
 
What's new in iOS 7
What's new in iOS 7What's new in iOS 7
What's new in iOS 7barcelonaio
 
Redux for ReactJS Programmers
Redux for ReactJS ProgrammersRedux for ReactJS Programmers
Redux for ReactJS ProgrammersDavid Rodenas
 
Web Components Everywhere
Web Components EverywhereWeb Components Everywhere
Web Components EverywhereIlia Idakiev
 

Similar to Building Apps with Flutter - Hillel Coren, Invoice Ninja (20)

I os 11
I os 11I os 11
I os 11
 
Provisioning & Migration with p2: Case study - The Good, the Bad and the Ugly
Provisioning & Migration with p2: Case study - The Good, the Bad and the UglyProvisioning & Migration with p2: Case study - The Good, the Bad and the Ugly
Provisioning & Migration with p2: Case study - The Good, the Bad and the Ugly
 
The evolution of redux action creators
The evolution of redux action creatorsThe evolution of redux action creators
The evolution of redux action creators
 
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinGet the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
 
Calculator Week2.DS_Store__MACOSXCalculator Week2._.DS_St.docx
Calculator Week2.DS_Store__MACOSXCalculator Week2._.DS_St.docxCalculator Week2.DS_Store__MACOSXCalculator Week2._.DS_St.docx
Calculator Week2.DS_Store__MACOSXCalculator Week2._.DS_St.docx
 
Workshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & ReduxWorkshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & Redux
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development
 
Redux. From twitter hype to production
Redux. From twitter hype to productionRedux. From twitter hype to production
Redux. From twitter hype to production
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
Developing AIR for Android with Flash Professional
Developing AIR for Android with Flash ProfessionalDeveloping AIR for Android with Flash Professional
Developing AIR for Android with Flash Professional
 
Redux. From twitter hype to production
Redux. From twitter hype to productionRedux. From twitter hype to production
Redux. From twitter hype to production
 
Battle of React State Managers in frontend applications
Battle of React State Managers in frontend applicationsBattle of React State Managers in frontend applications
Battle of React State Managers in frontend applications
 
ASP.NET MVC Internals
ASP.NET MVC InternalsASP.NET MVC Internals
ASP.NET MVC Internals
 
Converting Your Mobile App to the Mobile Cloud
Converting Your Mobile App to the Mobile CloudConverting Your Mobile App to the Mobile Cloud
Converting Your Mobile App to the Mobile Cloud
 
Building cross-platform mobile apps with React Native (Jfokus 2017)
Building cross-platform mobile apps with React Native (Jfokus 2017)Building cross-platform mobile apps with React Native (Jfokus 2017)
Building cross-platform mobile apps with React Native (Jfokus 2017)
 
Improving android experience for both users and developers
Improving android experience for both users and developersImproving android experience for both users and developers
Improving android experience for both users and developers
 
Droidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon2013 android experience lahoda
Droidcon2013 android experience lahoda
 
What's new in iOS 7
What's new in iOS 7What's new in iOS 7
What's new in iOS 7
 
Redux for ReactJS Programmers
Redux for ReactJS ProgrammersRedux for ReactJS Programmers
Redux for ReactJS Programmers
 
Web Components Everywhere
Web Components EverywhereWeb Components Everywhere
Web Components Everywhere
 

More from DroidConTLV

Mobile Development in the Information Age - Yossi Elkrief, Nike
Mobile Development in the Information Age - Yossi Elkrief, NikeMobile Development in the Information Age - Yossi Elkrief, Nike
Mobile Development in the Information Age - Yossi Elkrief, NikeDroidConTLV
 
Doing work in the background - Darryn Campbell, Zebra Technologies
Doing work in the background - Darryn Campbell, Zebra TechnologiesDoing work in the background - Darryn Campbell, Zebra Technologies
Doing work in the background - Darryn Campbell, Zebra TechnologiesDroidConTLV
 
No more video loss - Alex Rivkin, Motorola Solutions
No more video loss - Alex Rivkin, Motorola SolutionsNo more video loss - Alex Rivkin, Motorola Solutions
No more video loss - Alex Rivkin, Motorola SolutionsDroidConTLV
 
Mobile at Scale: from startup to a big company - Dor Samet, Booking.com
Mobile at Scale: from startup to a big company - Dor Samet, Booking.comMobile at Scale: from startup to a big company - Dor Samet, Booking.com
Mobile at Scale: from startup to a big company - Dor Samet, Booking.comDroidConTLV
 
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, Climacell
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, ClimacellLiveData on Steroids - Giora Shevach + Shahar Ben Moshe, Climacell
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, ClimacellDroidConTLV
 
MVVM In real life - Lea Cohen Tannoudji, Lightricks
MVVM In real life - Lea Cohen Tannoudji, LightricksMVVM In real life - Lea Cohen Tannoudji, Lightricks
MVVM In real life - Lea Cohen Tannoudji, LightricksDroidConTLV
 
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)DroidConTLV
 
New Android Project: The Most Important Decisions - Vasiliy Zukanov
New Android Project: The Most Important Decisions - Vasiliy ZukanovNew Android Project: The Most Important Decisions - Vasiliy Zukanov
New Android Project: The Most Important Decisions - Vasiliy ZukanovDroidConTLV
 
Designing a Design System - Shai Mishali, Gett
Designing a Design System - Shai Mishali, GettDesigning a Design System - Shai Mishali, Gett
Designing a Design System - Shai Mishali, GettDroidConTLV
 
The Mighty Power of the Accessibility Service - Guy Griv, Pepper
The Mighty Power of the Accessibility Service - Guy Griv, PepperThe Mighty Power of the Accessibility Service - Guy Griv, Pepper
The Mighty Power of the Accessibility Service - Guy Griv, PepperDroidConTLV
 
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDevKotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDevDroidConTLV
 
Flutter State Management - Moti Bartov, Tikal
Flutter State Management - Moti Bartov, TikalFlutter State Management - Moti Bartov, Tikal
Flutter State Management - Moti Bartov, TikalDroidConTLV
 
Reactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bisReactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bisDroidConTLV
 
Fun with flutter animations - Divyanshu Bhargava, GoHighLevel
Fun with flutter animations - Divyanshu Bhargava, GoHighLevelFun with flutter animations - Divyanshu Bhargava, GoHighLevel
Fun with flutter animations - Divyanshu Bhargava, GoHighLevelDroidConTLV
 
DroidconTLV 2019
DroidconTLV 2019DroidconTLV 2019
DroidconTLV 2019DroidConTLV
 
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, Monday
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, MondayOk google, it's time to bot! - Hadar Franco, Albert + Stav Levi, Monday
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, MondayDroidConTLV
 
Introduction to React Native - Lev Vidrak, Wix
Introduction to React Native - Lev Vidrak, WixIntroduction to React Native - Lev Vidrak, Wix
Introduction to React Native - Lev Vidrak, WixDroidConTLV
 
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneBang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneDroidConTLV
 
Educating your app – adding ML edge to your apps - Maoz Tamir
Educating your app – adding ML edge to your apps - Maoz TamirEducating your app – adding ML edge to your apps - Maoz Tamir
Educating your app – adding ML edge to your apps - Maoz TamirDroidConTLV
 
Constraint-ly motion - making your app dance - John Hoford, Google
Constraint-ly motion - making your app dance - John Hoford, GoogleConstraint-ly motion - making your app dance - John Hoford, Google
Constraint-ly motion - making your app dance - John Hoford, GoogleDroidConTLV
 

More from DroidConTLV (20)

Mobile Development in the Information Age - Yossi Elkrief, Nike
Mobile Development in the Information Age - Yossi Elkrief, NikeMobile Development in the Information Age - Yossi Elkrief, Nike
Mobile Development in the Information Age - Yossi Elkrief, Nike
 
Doing work in the background - Darryn Campbell, Zebra Technologies
Doing work in the background - Darryn Campbell, Zebra TechnologiesDoing work in the background - Darryn Campbell, Zebra Technologies
Doing work in the background - Darryn Campbell, Zebra Technologies
 
No more video loss - Alex Rivkin, Motorola Solutions
No more video loss - Alex Rivkin, Motorola SolutionsNo more video loss - Alex Rivkin, Motorola Solutions
No more video loss - Alex Rivkin, Motorola Solutions
 
Mobile at Scale: from startup to a big company - Dor Samet, Booking.com
Mobile at Scale: from startup to a big company - Dor Samet, Booking.comMobile at Scale: from startup to a big company - Dor Samet, Booking.com
Mobile at Scale: from startup to a big company - Dor Samet, Booking.com
 
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, Climacell
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, ClimacellLiveData on Steroids - Giora Shevach + Shahar Ben Moshe, Climacell
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, Climacell
 
MVVM In real life - Lea Cohen Tannoudji, Lightricks
MVVM In real life - Lea Cohen Tannoudji, LightricksMVVM In real life - Lea Cohen Tannoudji, Lightricks
MVVM In real life - Lea Cohen Tannoudji, Lightricks
 
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
 
New Android Project: The Most Important Decisions - Vasiliy Zukanov
New Android Project: The Most Important Decisions - Vasiliy ZukanovNew Android Project: The Most Important Decisions - Vasiliy Zukanov
New Android Project: The Most Important Decisions - Vasiliy Zukanov
 
Designing a Design System - Shai Mishali, Gett
Designing a Design System - Shai Mishali, GettDesigning a Design System - Shai Mishali, Gett
Designing a Design System - Shai Mishali, Gett
 
The Mighty Power of the Accessibility Service - Guy Griv, Pepper
The Mighty Power of the Accessibility Service - Guy Griv, PepperThe Mighty Power of the Accessibility Service - Guy Griv, Pepper
The Mighty Power of the Accessibility Service - Guy Griv, Pepper
 
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDevKotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
 
Flutter State Management - Moti Bartov, Tikal
Flutter State Management - Moti Bartov, TikalFlutter State Management - Moti Bartov, Tikal
Flutter State Management - Moti Bartov, Tikal
 
Reactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bisReactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bis
 
Fun with flutter animations - Divyanshu Bhargava, GoHighLevel
Fun with flutter animations - Divyanshu Bhargava, GoHighLevelFun with flutter animations - Divyanshu Bhargava, GoHighLevel
Fun with flutter animations - Divyanshu Bhargava, GoHighLevel
 
DroidconTLV 2019
DroidconTLV 2019DroidconTLV 2019
DroidconTLV 2019
 
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, Monday
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, MondayOk google, it's time to bot! - Hadar Franco, Albert + Stav Levi, Monday
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, Monday
 
Introduction to React Native - Lev Vidrak, Wix
Introduction to React Native - Lev Vidrak, WixIntroduction to React Native - Lev Vidrak, Wix
Introduction to React Native - Lev Vidrak, Wix
 
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneBang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
 
Educating your app – adding ML edge to your apps - Maoz Tamir
Educating your app – adding ML edge to your apps - Maoz TamirEducating your app – adding ML edge to your apps - Maoz Tamir
Educating your app – adding ML edge to your apps - Maoz Tamir
 
Constraint-ly motion - making your app dance - John Hoford, Google
Constraint-ly motion - making your app dance - John Hoford, GoogleConstraint-ly motion - making your app dance - John Hoford, Google
Constraint-ly motion - making your app dance - John Hoford, Google
 

Recently uploaded

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 

Recently uploaded (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 

Building Apps with Flutter - Hillel Coren, Invoice Ninja

  • 2. A BIT ABOUT ME… 2
  • 5. 5
  • 6. 6
  • 9. STATE MANAGEMENT ▸ setState ▸ Provider ▸ BLoC ▸ MobX ▸ Redux 9
  • 11. REDUX PERFORMANCE ▸ Rebuilding BLoC vs Redux ▸ Importance of memoization ▸ Set distinct on the view model ▸ Keep number of layers to a minimum 11
  • 12. REDUX SAMPLE ▸ Always use Built Value ▸ Avoid using a StoreBuilder in main.dart ▸ Pass view model to the view/avoid mapping ▸ Restructure to group by feature ▸ Only need flutter_redux and redux_logging 12
  • 13. 13
  • 14. 14
  • 15. PERSISTENCE ▸ Separate AppState in to data, ui and auth ▸ Persist each section separately ▸ Use PersistUI and PersistData interfaces ▸ Use similar approach to track loading ▸ Clear state if app version is different 15
  • 16. abstract class AppState implements Built<AppState, AppStateBuilder> { bool get isLoading; bool get isSaving; AuthState get authState; DataState get dataState; UIState get uiState; } 16
  • 17. class StopLoading {} class PersistUI {} class PersistData {} // Client actions class LoadClientRequest implements StartLoading {} class LoadClientSuccess implements StopLoading, PersistData { 17
  • 18. class StopLoading {} class PersistUI {} class PersistData {} // Client actions class LoadClientRequest implements StartLoading {} class LoadClientSuccess implements StopLoading, PersistData { 18
  • 19. class StopLoading {} class PersistUI {} class PersistData {} // Client actions class LoadClientRequest implements StartLoading {} class LoadClientSuccess implements StopLoading, PersistData { 19
  • 20. EntityUIState productReducer(ProductState state, dynamic action) { return state.rebuild((b) => b ..editing = editingReducer(state.editing, action).toBuilder()); } EntityUIState productReducer(ProductState state, dynamic action) { return state.rebuild((b) => b ..editing.replace(editingReducer(state.editing, action))); } Error: A value of type ‘…’ can't be assigned to a variable of type ‘…Builder’.
  • 21. EntityUIState productReducer(ProductState state, dynamic action) { return state.rebuild((b) => b ..editing = editingReducer(state.editing, action).toBuilder()); } EntityUIState productReducer(ProductState state, dynamic action) { return state.rebuild((b) => b ..editing.replace(editingReducer(state.editing, action))); } Error: A value of type ‘…’ can't be assigned to a variable of type ‘…Builder’.
  • 22. DATA CACHING ▸ All data is cached to the device ▸ Last updated timestamp is stored in the state ▸ Pass the timestamp when requesting new data ▸ Pull to refresh or auto-refresh after 15 minutes ▸ Autoload after certain events. ie, saving an invoice 22
  • 23. int get lastUpdated; BuiltMap<int, ProductEntity> get map; bool get isLoaded => lastUpdated > 0; bool get isStale { if (! isLoaded) { return true; } return DateTime.now().millisecondsSinceEpoch 23
  • 24. int get lastUpdated; BuiltMap<int, ProductEntity> get map; bool get isLoaded => lastUpdated > 0; bool get isStale { if (! isLoaded) { return true; } return DateTime.now().millisecondsSinceEpoch 24
  • 25. int get lastUpdated; BuiltMap<int, ProductEntity> get map; bool get isLoaded => lastUpdated > 0; bool get isStale { if (! isLoaded) { return true; } return DateTime.now().millisecondsSinceEpoch 25
  • 26. VIEW MODELS ▸ View code should be UI/layout focused ▸ Nested view models ▸ Options to pass data to views ▸ Pass AppState as property on view model ▸ Pass field as property on view model ▸ Access AppState in view using context 26
  • 27. MEMOIZATION ▸ Keep build method fast ▸ Simple Dart package available: memoize ▸ memoX where X is the number of parameters 27
  • 28. List<int> activeClientsSelector( BuiltMap<int, ClientEntity> clientMap, BuiltList<int> clientList) { return clientList.where((clientId) => clientMap[clientId].isActive).toList(); } final memoizedActiveClients = memo2(( BuiltMap<int, ClientEntity> clientMap, BuiltList<int> clientList) =>
  • 29. List<int> activeClientsSelector( BuiltMap<int, ClientEntity> clientMap, BuiltList<int> clientList) { return clientList.where((clientId) => clientMap[clientId].isActive).toList(); } final memoizedActiveClients = memo2(( BuiltMap<int, ClientEntity> clientMap, BuiltList<int> clientList) =>
  • 30. FORMS ▸ Built Value enables change tracking ▸ Prefer didChangeDependencies() over iniState() ▸ Avoid @nullable, set default value in constructor ▸ Static negative counter for new ids ▸ Use completers in view models 30
  • 31. NAVIGATION ▸ Handle navigation in middleware ▸ Pass context in actions ▸ Use completers for wrap up code ▸ Use pop() to pass back value ▸ snackbarCompleter and popCompleter 31
  • 32. final Completer<Null> completer = Completer<Null>(); completer.future.then((_) { Scaffold.of(context) .showSnackBar(SnackBar(content: SnackBarRow(message: message))); }).catchError((Object error) { showDialog<ErrorDialog>( context: context, builder: (BuildContext context) => ErrorDialog(error)); }); return completer;
  • 33. final Completer<Null> completer = Completer<Null>(); completer.future.then((_) { Scaffold.of(context) .showSnackBar(SnackBar(content: SnackBarRow(message: message))); }).catchError((Object error) { showDialog<ErrorDialog>( context: context, builder: (BuildContext context) => ErrorDialog(error)); }); return completer;
  • 34. final Completer<Null> completer = Completer<Null>(); completer.future.then((_) { Scaffold.of(context) .showSnackBar(SnackBar(content: SnackBarRow(message: message))); }).catchError((Object error) { showDialog<ErrorDialog>( context: context, builder: (BuildContext context) => ErrorDialog(error)); }); return completer;
  • 35. switch (action) { case EntityAction.archive: store.dispatch(ArchiveInvoiceRequest( snackBarCompleter(context, localization.archivedInvoice), invoice.id)); break; ... }
  • 36. CODE GENERATOR ▸ Reduces need for a lot of copy/replace ▸ Two main commands: ▸ Init: Update code with your app info ▸ Make: Generate individual module ▸ Creates a large amount of code ▸ Important to get it right at the beginning 36
  • 37. BEST PRACTICES ▸ analysis_options.yaml ▸ sentry.io or Crashlytics ▸ Built Value ▸ Create lots of widgets, ie. IconText ▸ Read the flutter_redux code 37
  • 43. FLUTTER WEB DEMO [BETA] https://demo.invoicing.co 43
  • 44. WHO TO FOLLOW ▸ Tim Sneath - @timsneath ▸ Eric Seidel - @_eseidel ▸ Martin Aguinis - @MartinAguinis ▸ Nilay Yener - @nlycskn ▸ Andrew Brogdon - @RedBrogdon ▸ Emily Fortuna - @bouncingsheep ▸ Filip Hráček - @filiphracek 44