Isaias Awate

Isaias Awate

1603993860

Flutter Control is complex library to maintain App and State management

Flutter Control is complex library to maintain App and State management.
Library merges multiple functionality under one hood. This approach helps to tidily bound separated logic into complex solution.

import 'package:flutter_control/core.dart';
  • App State Management - Managing application state, localization, theme and other global App changes.
  • Widget State Management - UI / Logic separation. Controlling State and UI updates.
  • Dependency Injection - Factory, Singleton, Lazy initialization and Service Locator.
  • Navigation and Routing - Routes, transitions and passing arguments to other pages and Models.
  • Localization - Json based localization with basic formatting.
  • Event System - Global event/data stream to easily notify app events.

Simplified structure of core classes in Flutter Control. Full diagram is at bottom of this page.
Control with ControlFactory is main gate and bounds everything together.
ControlWidget holds UI and ControlModel solves Business Logic. Structure

Flutter Control Core

  • Control Main static class. Initializes ControlFactory and provides easy access to most of core [Control] objects like BaseLocalization, RouteStore, ControlBroadcast, etc…
  • ControlFactory Initializes and can store Controls, Models and other Objects. Works as Service Locator and Storage.
    Factory has own Storage. Objects in this storage are accessible via custom key or Type. Best practice is to use Type as a key.
    Factory is one and only Singleton in this Library.
    Core objects of Flutter Control are stored in Factory’s Storage by default (Control.initControl) and are accessible by their Type or via Providers.

Structure

    Control.initControl(
      localization: LocalizationConfig(
        defaultLocale: 'en',
        locales: LocalizationAsset.build(locales: ['en_US', 'es_ES']),
      ),
      entries: {
        CounterListControl: CounterListControl(),
      },
      initializers: {
        CounterModel: (_) => CounterModel(),
        CounterDetailControl: (args) => CounterDetailControl(model: Parse.getArg<CounterModel>(args)),
      },
      routes: [
        ControlRoute.build<DetailPage>(builder: (_) => DetailPage()),
      ],
      initAsync: () async {
        loadPreAppConfig();
      },
    );
  • ControlRoot Wraps [AppWidgets] and initializes [Control]. It’s just shortcut to start with Flutter Control. Via ControlScope is possible to maintain State of this root widget and control whole app state (localization, theme, etc.).
    Additionally offers App State management - home screen, localization and theme changes.
    ControlRoot(
      localization: LocalizationConfig(locales: [...]),
      theme: ThemeConfig<MyThemne>(
        builder: (context) => MyTheme(context),
        themes: {...},
      ),
      entries: {...},
      initializers: {...},
      routes: [...],
      states: [
        AppState.init.build(builder: (_) => LoadingPage()),
        AppState.main.build(
          builder: (_) => DashboardPage(),
          transition: TransitionToDashboard(),
        ),
      ],
      app: (setup, home) => MaterialApp(
        key: setup.key,
        title: setup.title('app_name', 'Example App'),
        theme: setup.theme,
        home: home,
        locale: setup.locale,
        supportedLocales: setup.supportedLocales,
        localizationsDelegates: [
          ...
        ],        
      ),
    );

  • ControlWidget is base abstract class (StatefulWidget) to maintain larger UI parts of App (Pages or complex Widgets). Widget is created with default ControlState to correctly reflect lifecycle of Widget to Models. So there is no need to create custom [State].
    Widget will init all containing Models and pass arguments to them.
    ControlWidget is immutable so all logic parts (even UI logic and animations) must be controlled from outside. This helps truly separate all code from pure UI (also helps to reuse this code).

  • SingleControlWidget is focused to single ControlModel. But still can handle multiple Controls.

  • StateboundWidget - Subscribes to just one StateControl - a mixin class typically used with [ControlModel] - [BaseControl] or [BaseModel].
    Whenever state of [StateControl] is changed, this Widget is rebuild.

    These Widgets comes with few mixin classes:

    • RouteControl to abstract navigation and easily pass arguments to Routes and init other Pages.
    • TickerControl and SingleTickerControl to create [State] with Ticker and provide access to vsync.
  • ControlModel is base class to maintain Business Logic parts.
    BaseControl is extended version of [ControlModel] with more functionality. Mainly used for Pages or complex Widgets and also to separate robust Logic parts.
    BaseModel is extended but lightweight version of [ControlModel]. Mainly used to control smaller Widgets like Items in dynamic List or to separate/reuse Logic parts.
    This Controls comes with few mixin classes to extend base functionality:

    • RouteControlProvider to provide Navigation outside of Widget.
    • StateControl to control State and notify Widget about changes.
    • TickerComponent passes Ticker to Model and enables to control animations outside of Widget.

Structure

  • ActionControl is one type of Observable used in this Library. It’s quite lightweight and is used to notify Widgets and to provide events about value changes.
    Has two variants - Single (just one listener), Broadcast (multiple listeners).
    On the Widget side is ActionBuilder to dynamically build Widgets. It’s also possible to use ControlBuilderGroup to group values of multiple Observables.
    ActionControlSub provides read-only version of [ActionControl].
    Upon dismiss of [ActionControl], every ControlSubscription is closed.
    final counter = ActionControl.broadcast<int>(0);

    ActionBuilder<int>(
      control: counter,
      builder: (context, value) => Text(value.toString()),
    );
  • FieldControl is more robust Observable solution around Stream and StreamController. Primarily is used to notify Widgets and to provide events about value changes.
    Can listen Stream, Future or subscribe to another [FieldControl] with possibility to filter and convert values.
    [FieldControl] comes with pre-build primitive variants as StringControl, DoubleControl, etc., where is possible to use validation, regex or value clamping. And also ListControl to work with Iterables.
    On the Widget side is FieldBuilder to dynamically build Widgets. Also ControlBuilderGroup for use with multiple Observables. It’s also possible to use standard StreamBuilder.
    FieldControlSub provides read-only version of [FieldControl]. And FieldSink or FieldSinkConverter provides Sink of [FieldControl].
    Upon dismiss of [FieldControl], every FieldSubscription is closed.
    final counter = FieldControl<int>(0);

    FieldBuilder<int>(
      control: counter,
      builder: (context, value) => Text(value.toString()),
    );

Check Counter Example and TODO List Example at Git repository.

Structure below shows how data and events flows between UI and Controls. ControlWidget can use multiple ControlModels with multiple Models, Streams and Observables… Structure

Localization

  • BaseLocalization Json based localization, that supports simple strings, plurals and dynamic structures.
    Easy access via LocalizationProvider mixin. Localization object is stored in [ControlFactory], so is accessible without context and can be used even in Models, Entities, etc. via Control.localization()
    Localization is initialized and loaded in Control by default.
    And by default ControlWidget uses this localization via mixin.
    Control.initControl(
      localization: LocalizationConfig(
        defaultLocale: 'en',
        locales: LocalizationAsset.build(locales: ['en_US', 'es_ES']),
      ),
    );
    ControlRoot(
      localization: LocalizationConfig(
        locales: {
          'en': 'assets/localization/en.json',
          'es': 'assets/localization/es.json',
        },
      ),
    );

Check Localization Example and Localization Delegate Example at Git repository.

Global Event System

  • ControlBroadcast Event stream across whole App. Default broadcaster is part of ControlFactory and is stored there.
    Every subscription is bound to it’s key and Type so notification to Listeners arrives only for expected data.
    With BroadcastProvider is possible to subscribe to any stream and send data or events from one end of App to the another, even to Widgets and their States. Also custom broadcaster can be created to separate events from global/default stream.

Structure

  BroadcastProvider.subscribe<int>('on_count_changed', (value) => updateCount(value));
  BraodcastProvider.broadcast('on_count_changed', 10);

Navigation and Routing

  • ControlRoute Specifies Route with Transition and [WidgetBuilder] settings for RouteHandler. Handler then solves navigation and passes args to Widgets and Models.
    Use RouteControl mixin to enable this navigation with [ControlWidget] and RouteControlProvider mixin with [ControlModel]. Routes can be stored in RouteStore and Route builder is accessible statically via ControlRoute.of.
    Control.initControl(
      routes: [
        ControlRoute.build<DetailPage>(builder: (_) => DetailPage()),
        ControlRoute.build(key: 'detail_super', builder: (_) => DetailPage()).path('super').viaTransition(_transitionBuilder),
      ],
    );

    class ListPage extends ControlWidget with RouteControl {
      Widget build(BuildContext context){
        ...
        routeOf<DetailPage>().openRoute();
        routeOf<DetailPage>().viaTransition(_transitionBuilder).openRoute();
        routeOf(key: 'detail_super').openRoute();
      };
    }

Check Navigation Example and Navigation Stack Example at Git repository.

Other classes

  • ControlTheme and ThemeProvider Wraps [ThemeData], [MediaQuery] and asset path helper.

  • InputField Wrapper of [TextField] to provide more functionality and control via InputControl.

  • DisposeHandler - mixin for any class, helps with object disposing.

  • PrefsProvider - mixin for any class, helps to store user preferences - based on shared_preferences.

  • Parse Helps to parse json primitives and Iterables. Also helps to look up Lists and Maps for objects.

  • FutureBlock Retriggerable delay.

  • DelayBlock Delay to wrap a block of code to prevent ‘super fast’ completion and UI jiggles.

  • WidgetInitializer Helps to initialize Widgets with init data.

  • UnitId Unique Id generator based on Time, Index or just Random.

  • and more…


Check set of Flutter Control Examples at Git repository for more complex solutions and how to use this library.


Core Structure

Structure

Download Details:

Author: RomanBase

Source Code: https://github.com/RomanBase/flutter_control

#flutter #dart #mobile-apps

What is GEEK

Buddha Community

Flutter Control is complex library to maintain App and State management

Google's Flutter 1.20 stable announced with new features - Navoki

Flutter Google cross-platform UI framework has released a new version 1.20 stable.

Flutter is Google’s UI framework to make apps for Android, iOS, Web, Windows, Mac, Linux, and Fuchsia OS. Since the last 2 years, the flutter Framework has already achieved popularity among mobile developers to develop Android and iOS apps. In the last few releases, Flutter also added the support of making web applications and desktop applications.

Last month they introduced the support of the Linux desktop app that can be distributed through Canonical Snap Store(Snapcraft), this enables the developers to publish there Linux desktop app for their users and publish on Snap Store.  If you want to learn how to Publish Flutter Desktop app in Snap Store that here is the tutorial.

Flutter 1.20 Framework is built on Google’s made Dart programming language that is a cross-platform language providing native performance, new UI widgets, and other more features for the developer usage.

Here are the few key points of this release:

Performance improvements for Flutter and Dart

In this release, they have got multiple performance improvements in the Dart language itself. A new improvement is to reduce the app size in the release versions of the app. Another performance improvement is to reduce junk in the display of app animation by using the warm-up phase.

sksl_warm-up

If your app is junk information during the first run then the Skia Shading Language shader provides for pre-compilation as part of your app’s build. This can speed it up by more than 2x.

Added a better support of mouse cursors for web and desktop flutter app,. Now many widgets will show cursor on top of them or you can specify the type of supported cursor you want.

Autofill for mobile text fields

Autofill was already supported in native applications now its been added to the Flutter SDK. Now prefilled information stored by your OS can be used for autofill in the application. This feature will be available soon on the flutter web.

flutter_autofill

A new widget for interaction

InteractiveViewer is a new widget design for common interactions in your app like pan, zoom drag and drop for resizing the widget. Informations on this you can check more on this API documentation where you can try this widget on the DartPad. In this release, drag-drop has more features added like you can know precisely where the drop happened and get the position.

Updated Material Slider, RangeSlider, TimePicker, and DatePicker

In this new release, there are many pre-existing widgets that were updated to match the latest material guidelines, these updates include better interaction with Slider and RangeSliderDatePicker with support for date range and time picker with the new style.

flutter_DatePicker

New pubspec.yaml format

Other than these widget updates there is some update within the project also like in pubspec.yaml file format. If you are a flutter plugin publisher then your old pubspec.yaml  is no longer supported to publish a plugin as the older format does not specify for which platform plugin you are making. All existing plugin will continue to work with flutter apps but you should make a plugin update as soon as possible.

Preview of embedded Dart DevTools in Visual Studio Code

Visual Studio code flutter extension got an update in this release. You get a preview of new features where you can analyze that Dev tools in your coding workspace. Enable this feature in your vs code by _dart.previewEmbeddedDevTools_setting. Dart DevTools menu you can choose your favorite page embed on your code workspace.

Network tracking

The updated the Dev tools comes with the network page that enables network profiling. You can track the timings and other information like status and content type of your** network calls** within your app. You can also monitor gRPC traffic.

Generate type-safe platform channels for platform interop

Pigeon is a command-line tool that will generate types of safe platform channels without adding additional dependencies. With this instead of manually matching method strings on platform channel and serializing arguments, you can invoke native class and pass nonprimitive data objects by directly calling the Dartmethod.

There is still a long list of updates in the new version of Flutter 1.2 that we cannot cover in this blog. You can get more details you can visit the official site to know more. Also, you can subscribe to the Navoki newsletter to get updates on these features and upcoming new updates and lessons. In upcoming new versions, we might see more new features and improvements.

You can get more free Flutter tutorials you can follow these courses:

#dart #developers #flutter #app developed #dart devtools in visual studio code #firebase local emulator suite in flutter #flutter autofill #flutter date picker #flutter desktop linux app build and publish on snapcraft store #flutter pigeon #flutter range slider #flutter slider #flutter time picker #flutter tutorial #flutter widget #google flutter #linux #navoki #pubspec format #setup flutter desktop on windows

Hire Dedicated Flutter App Developer USA| Flutter App Developers

Hire Flutter App Developers: WebClues Infotech is a Flutter App Development company. Our Flutter mobile app development team can create cross-platform apps for different industry verticals. Our Flutter developers will help you extend your business’s scope by developing enhanced functionality and a feature-rich app. To provide a rich user experience to your users, hire dedicated Flutter app developers from WebClues Infotech today!

#hire flutter app developers #hire dedicated flutter app developer usa #hire flutter app developer usa #hire dedicated flutter app developer #hire flutter developer #flutter app development company

Best Flutter App Development Company

Are you looking for the best flutter app development company? Then AppClues Infotech is the leading flutter app development company in USA offering the best service worldwide. We focused on developing hybrid mobile apps on Android & iOS and assures our end-user about exceptional and functionally-rich mobile apps.

For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910

#top flutter app development company in usa #best flutter app development service #best flutter app development company #hire flutter app developers #flutter app development company #expert flutter app development company

Best Flutter App Development Company in USA & India

AppClues Infotech is one of the best flutter app development company in USA & India. Our diverse and experienced team of developers can help you sketch the smartest and quickest solution for your mobile app development projects with the most superior technology.

For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910

#top flutter app development company in usa #best flutter app development service #best flutter app development company #hire flutter app developers #flutter app development company in usa & india #custom flutter app development service

Best Flutter App Development Services in USA

Looking for the best-in-class Flutter app development services in USA? We at AppClues Infotech offer next-generation mobile app development services using Google’s powerful framework, Flutter.

Our extremely trustworthy and exceptional Flutter app developers help enterprises and businesses to design high-quality native interfaces on cross-platform.

If you have any project ideas, hiring our Flutter app development services helps you get multi-platform applications with seamless animations, appealing UI, and excellent performance.

Flutter Mobile App Development Services
• Flutter Custom App Development
• Flutter App UI/UX Design
• Flutter Widget Development
• Flutter App QA Testing & Maintenance
• Flutter App Updations & Migration
• Flutter for Embedded Devices
• Flutter Development Consultation

For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910

#top flutter app development company in usa #best flutter app development service in usa #best flutter app development company usa #hire flutter app developers in usa #best flutter app development services in usa #custom flutter app development services in usa