Help Instance Help

Example App

Application may grow over time, and you may split the ownership of different bounded contexts into different teams. Of course the teams may run the main app, but what when they want just to run their developed widgets in an example app for developing purposes to avoid any dependencies to other teams?

Setup example app

Developers can setup the example app just by following Getting Started - New App from Scratch. There is also another way to setup the app, and they are familiar with by writing integration tests.

Withing the package run the following command if the example app should not exist already.

flutter create example

This will create the example app in the subdirectory example.

import 'package:example/config/config_refresh.dart'; import 'package:example/config/config_transactions.dart'; import 'package:example/model/m8ty_config.dart'; import 'package:example/model/serializers.dart'; import 'package:example/provider.dart'; import 'package:flutter/material.dart'; import 'package:m8ty_banking_accounts/config.dart'; import 'package:m8ty_banking_transactions/m8ty_banking_transactions.dart'; import 'package:m8ty_business_components/dashboard/dashboard_widget_config.dart'; import 'package:m8ty_test/m8ty_test.dart'; Future<void> main() async { Widget appWidget = await TestConfig() .withDashboardWidgets(transactionsDashboardWidgets) .withNavigation(navigationBankingTransactions) .withOverrides(getProviderOverrides) .withWidgetPlacement(WidgetPlacement.home) .withSerializers(exampleSerializers) .withBaseUrlProvider(_loadConfig) .withMockConfig(_loadConfig) .withModuleConfigs((ref) => [ BankingTransactionsModuleConfig(TransactionsConfigParam()), ]) .withInitializers([ BankingAccountsModuleConfig.init, BankingTransactionsModuleConfig.init, ]).withConfigurators([ configureRefresh, ]).build(); return runApp(appWidget); } Future<M8tyConfigModel> _loadConfig() async { return loadFromJson<M8tyConfigModel>('assets/config/configuration.json'); }

m8ty_test is setting up already all the common dependencies out of the box and this reduces the complexity a lot.

name: example description: A new Flutter project. # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 # followed by an optional build number separated by a +. # Both the version and the builder number may be overridden in flutter # build by specifying --build-name and --build-number, respectively. # In Android, build-name is used as versionName while build-number used as versionCode. # Read more about Android versioning at https://developer.android.com/studio/publish/versioning # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. version: 1.0.0+1 environment: sdk: '>=3.0.6 <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions # consider running `flutter pub upgrade --major-versions`. Alternatively, # dependencies can be manually updated by changing the version numbers below to # the latest version available on pub.dev. To see which dependencies have newer # versions available, run `flutter pub outdated`. dependencies: flutter: sdk: flutter m8ty_banking_transactions: path: ../ m8ty_test: git: url: git@gitlab.m8ty.eu:app-framework/m8ty_test.git m8ty_basic_components: git: url: git@gitlab.m8ty.eu:app-framework/m8ty_basic_components.git m8ty_business_components: git: url: git@gitlab.m8ty.eu:app-framework/m8ty_business_components.git m8ty_app: git: url: git@gitlab.m8ty.eu:app-framework/m8ty_app.git m8ty_banking_accounts: git: url: git@gitlab.m8ty.eu:app-framework/m8ty_banking_accounts.git m8ty_security: git: url: git@gitlab.m8ty.eu:app-framework/m8ty_security.git m8ty_theme: git: url: git@gitlab.m8ty.eu:app-framework/m8ty_theme.git get_it: ^7.6.0 flutter_riverpod: ^2.3.6 shared_preferences: ^2.2.0 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.5 dev_dependencies: build_runner: any built_value_generator: ^8.6.1 flutter_test: sdk: flutter integration_test: sdk: flutter # The "flutter_lints" package below contains a set of recommended lints to # encourage good coding practices. The lint set provided by the package is # activated in the `analysis_options.yaml` file located at the root of your # package. See that file for information about deactivating specific lint # rules and activating additional ones. flutter_lints: ^2.0.2 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter packages. flutter: # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true # To add assets to your application, add an assets section, like this: assets: - assets/config/configuration.json

Code reference

We are referencing the package just by path in the example app

m8ty_banking_transactions: path: ../

Overrides

There are use cases in which developers want to work on several packages at the same time, but do not want to refer to the source code only temporarily.

This can be achieved by cloning the package locally and adding it to the following dependency_overrides section:

dependency_overrides: m8ty_app: path: ../../m8ty_app/
Last modified: 02 January 2025