mydomain
No ADS
No ADS

FlutterArtist AppConfiguration

  1. registerShelves()
  2. registerActivities()
  3. projectionFamilies()
  4. coreFeaturesAdapter
As mentioned in the introduction, FlutterArtist aims to organize the application systematically, much like arranging shelves in a well-structured warehouse. To achieve that orderliness, we need a centralized blueprint called AppConfiguration. This is where you declare the core components: from storage structures (Shelves), business logic (Activities) to technical adapters. Below is an illustrative example of how to set up this configuration class:
MyDemoAppConfiguration
class MyDemoAppConfiguration extends AppConfiguration {
  @override
  String get appName => "FlutterArtist Demo";

  @override
  List<ProjectionFamily> projectionFamilies() {
    return [
      ProjectionFamily<int>(
        familyName: 'supplier-projections',
        members: {SupplierInfo, SupplierData},
      ),
      ProjectionFamily<int>(
        familyName: 'album-projections',
        members: {AlbumInfo, AlbumData}, 
      ),
    ];
  }

  @override
  void registerActivities() {
    FlutterArtist.storage.registerActivity(() => AppLoginActivity());
  }

  @override
  void registerShelves() {
    FlutterArtist.storage.registerShelf(() => Currency01aShelf());
    FlutterArtist.storage.registerShelf(() => Song02aShelf()); 
    // Other codes...
  }

  @override
  List<FaTheme> additionalThemes() {
    return FlutterArtistVibeThemeKit.supportedThemes;
  }

  @override
  void overrideColorResolvers() {
    //
  }

  @override
  Future<void> showDebugNetworkInspector(BuildContext context) async {
    bool isSystemUser = FlutterArtist.loggedInUser?.isSystemUser ?? false;
    await DebugNetworkInspectorDialog.show(
      context,
      showJson: isSystemUser,
      showToken: isSystemUser,
    );
  }

  @override
  FlutterArtistCoreFeaturesAdapter get coreFeaturesAdapter =>
      MaterialFlutterArtistCoreFeaturesAdapter();

  @override
  FlutterArtistGlobalDataAdapter<IGlobalData> get globalDataAdapter =>
      GlobalDataAdapterImpl();

  @override
  FlutterArtistLocaleAdapter get localeAdapter => FlutterArtistLocaleAdapter(
    updateLocale: (Locale locale) async {
      // ...
    },
  );

  @override
  FlutterArtistLoginLogoutAdapter<ILoggedInUser> get loginLogoutAdapter =>
      LoginLogoutAdapterImpl();

  @override
  FlutterArtistNotificationAdapter? get notificationAdapter {
    // NotificationAdapterImpl
    return MyFirebaseNotificationAdapter();
  }
}
Starting the application is now more explicit through the FlutterArtist.start() method in main.dart.
main.dart (*)
await FlutterArtist.start(
  appConfiguration: MyDemoAppConfiguration(),
  ...
);
No ADS
To support the development process, you can utilize the Debug App Inspector. This tool helps you inspect the actual structure of the AppConfiguration, monitor the status of Shelf(s), and visually check data in real-time while the app is running. This centralized registration model may require initial meticulousness, but it helps maintain a Single Source of Truth. This minimizes data conflict errors and provides better control for large-scale projects. The combination of AppConfiguration's discipline and Debug App Inspector's transparency will make state management simpler and more professional.
  • Giới thiệu về FlutterArtist

1. registerShelves()

The registerShelves() method allows you to register Shelf(s). Imagine having shelves that need to be placed in the correct positions within the warehouse before they can be used.
registerShelves()
@override
void registerShelves() { 
   FlutterArtist.storage.registerShelf(() => Country61aShelf()); 
   FlutterArtist.storage.registerShelf(() => FootballPlayer86aShelf());
   FlutterArtist.storage.registerShelf(() => ProjectContributor98aShelf());
} 
Anywhere in the application, you can access any shelf by searching for it within the storage.
FootballPlayer86aShelf shelf = FlutterArtist.storage.findShelf();
If a Shelf is not registered, a runtime error will occur when you attempt to access it. A bright red error screen will appear to alert you.

2. registerActivities()

The registerActivities() method allows you to register Activity(s) — a data model and controller that simulates specific activities or functions. Essentially, an Activity is designed to handle complex logic that Block and Scalar do not cover, such as AppLoginActivity for authentication.
Note: Currently, the Activity design is in its early stages. Its scope is limited, and significant changes are expected in future versions to optimize its capabilities.
No ADS
registerActivities()
@override
void registerActivities() {
  FlutterArtist.storage.registerActivity(() => AppLoginActivity());
}
Similar to a Shelf, accessing an unregistered Activity will trigger a red screen error.
findActivity()
AppLoginActivity loginActivity = FlutterArtist.storage.findActivity();

3. projectionFamilies()

The projectionFamilies() method allows you to define ProjectionFamily(s). This is a core concept that helps manage different data versions of the same entity.
  • FlutterArtist Projections (***)
projectionFamilies()
@override
List<ProjectionFamily> projectionFamilies() {
  return [
    ProjectionFamily<int>(
      familyName: 'supplier-projections',
      members: {SupplierInfo, SupplierData},
    ),
    ProjectionFamily<int>(
      familyName: 'album-projections',
      members: {AlbumInfo, AlbumData},
    ),
    ProjectionFamily<int>(
      familyName: 'company-projections',
      members: {CompanyInfo, CompanyData, CompanyTreeItem, CompanyTree},
    ), 
    // ...
  ];
} 

4. coreFeaturesAdapter

FlutterArtist was initially built upon the accessible features provided by GetX, such as Global BuildContext, Overlay, and SnackBar. Among these, the Overlay is a nearly transparent layer covering the entire screen, used to temporarily prevent user interaction with underlying widgets until an asynchronous task is completed.
No ADS

FlutterArtist

Show More
No ADS