Slide 1

Slide 1 text

Enzo Lizama Paredes GDG Open @enzoftware Flutter Flavors Flavors / Schemes for Flutter apps.

Slide 2

Slide 2 text

What is Flutter? Again?

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Let's get started!

Slide 7

Slide 7 text

https://kinbiko.com/software-engineering/why-how-what/

Slide 8

Slide 8 text

What the #@&% is a flavor? No, it is not food!

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Why I should use flavors? It could save your life.

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

● We can bring order into testing environments. Sometimes, our application use API, and it has different versions. Thanks to multi flavor apps, we can have separate builds for each server, so any team member can always download correct files and start testing ● We can offer version of application with no ads inside for premium users Why Multi Flavor Apps

Slide 13

Slide 13 text

How to implement flavors? As easy as it could be.

Slide 14

Slide 14 text

// Build types buildTypes { debug { applicationIdSuffix ".debug" debuggable true minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }

Slide 15

Slide 15 text

// Flavors android { flavorDimensions "version" productFlavors { freeVersion { //select the dimension of flavor dimension "version" //configure applicationId for app published to Play store applicationId "com.pcc.flavors.free" //Configure this flavor specific app name published in Play Store resValue "string", "flavored_app_name", "Free Great App" } paidVersion { dimension "version" applicationId "com.pcc.flavors.paid" resValue "string", "flavored_app_name", "Paid Great App" } } }

Slide 16

Slide 16 text

iOS Schemas

Slide 17

Slide 17 text

Flutter build modes Debug: flutter run Profile: flutter run --profile Release: flutter run --release / flutter build

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

// flavor_config.dart enum Flavor { DEV, QA, PRODUCTION, DEMO, }

Slide 20

Slide 20 text

// flavor_config.dart class FlavorConfig { final Flavor flavor; final String name; final Color color; final FlavorValues values; static FlavorConfig _instance; }

Slide 21

Slide 21 text

//main_dev.dart void main() { FlavorConfig( flavor: Flavor.DEV, color: Colors.green, values: FlavorValues( apiUrl: '/bins/k0p5n', ), ); runApp(MyApp()); }

Slide 22

Slide 22 text

// repository.dart final String _url = FlavorConfig.instance.values.apiUrl; final String _baseUrl = FlavorConfig.isProduction() ? 'jsonplaceholder.typicode.com' : 'api.myjson.com';

Slide 23

Slide 23 text

// app.dart body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'You are in :', ), Text( '${FlavorConfig.instance.name} flavor', style: Theme.of(context).textTheme.display1, ), Text('Api url : ${FlavorConfig.instance.values.apiUrl}'), ], ), ),

Slide 24

Slide 24 text

How to run flavors Run dev flavor : flutter run -t lib/main_dev.dart Run qa flavor : flutter run -t lib/main_qa.dart Run demo flavor : flutter run -t lib/main_demo.dart Run production flavor : flutter run -t lib/main_prod.dart

Slide 25

Slide 25 text

Live Demo enzoftware/flutter_flavors

Slide 26

Slide 26 text

https://github.com/enzoftware/flutter_flavors

Slide 27

Slide 27 text

How to go further with Flutter? Always be curious.

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

Enzo Lizama Paredes GDG Open @enzoftware Thank You!