Zum Inhalt springen

Beispiel-App

Eine Anwendung kann mit der Zeit wachsen, und Sie können die Verantwortung für verschiedene Bounded Contexts auf unterschiedliche Teams aufteilen. Natürlich können die Teams die Haupt-App ausführen – aber was, wenn sie zu Entwicklungszwecken nur ihre selbst entwickelten Widgets in einer Beispiel-App ausführen möchten, um Abhängigkeiten zu anderen Teams zu vermeiden?

Entwickler können die Beispiel-App einrichten, indem sie einfach Erste Schritte – Neue App von Grund auf folgen. Es gibt noch eine weitere Möglichkeit, die App einzurichten, die ihnen vom Schreiben von Integrationstests bereits vertraut ist.

Führen Sie innerhalb des Pakets den folgenden Befehl aus, falls die Beispiel-App noch nicht existiert.

Terminal-Fenster
flutter create example

Dadurch wird die Beispiel-App im Unterverzeichnis example erstellt.

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 richtet bereits alle gängigen Abhängigkeiten direkt ein, was die Komplexität erheblich reduziert.

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-Referenz

Wir referenzieren das Paket in der Beispiel-App einfach über den Pfad

m8ty_banking_transactions:
path: ../

Es gibt Anwendungsfälle, in denen Entwickler gleichzeitig an mehreren Paketen arbeiten möchten, den Quellcode aber nur vorübergehend referenzieren wollen.

Dies erreichen Sie, indem Sie das Paket lokal klonen und es dem folgenden Abschnitt dependency_overrides hinzufügen:

dependency_overrides:
m8ty_app:
path: ../../m8ty_app/