Flutter Dev

Flutter Dev

1583810568

Flutter Firebase & DDD Course [1] – Domain-Driven Design Principles

Firebase 🔥 allows developers to get their apps working quickly. Flutter 💙 does the same thing. But, as it goes in life, trade-offs are everywhere. Sure, you can hack something together in a dash of enthusiasm but this initial excitement will fade away as soon as you get totally lost in your own code.

Flutter apps need structure that is easy to orient yourself in, testable and maintainable. It also wouldn’t hurt if the way you architect your Flutter apps allows for adding new features without a headache. Especially with a client-centric service such as Firebase Firestore, it’s extremely important to keep your code clean. Let’s do it by following the principles of Domain-Driven Design.

The project we will build

We’re going to build a fairly complex note taking application featuring things such as

  • Real-time Firestore data Streams
  • Extensive data validation for a rich user experience
  • Google & email + password authentication
  • Reorderable todo lists and much more

Domain-Driven Design - the big picture

You have surely seen or built Flutter apps using Firebase Auth and **Firestore **and I’m sure you didn’t put the Firebase calls into your widget code. In other words, you used some sort of an architecture.

You may have even watched my Clean Architecture course where we worked with a simple REST API. Over there, the class dependency flow together with the file and folder structure were neatly outlined for you and it’s possible to use it with Firebase too. How is Domain-Driven Design (DDD) different then?

Simply said, it’s better on every level. We still have a good separation into layers which brings beautiful traits ease of navigation and testability. So no, we still don’t put all of our code into the UI or state management.

We will go over everything in more detail later but for now just know that the diagram below outlines the key architectural layers present in a DDD Flutter app. We’re going to use BLoC in this series but, as usual, I didn’t forget about all of you who have declared BLoC a sworn enemy. If you don’t want to use it in your apps, feel free to use a view model of your choice, whether it be ChangeNotifier, MobX Store, or even the new StateNotifier. More on that later.

There are a few things that I couldn’t fit on the diagram. Namely:

  • Arrows represent the flow of data. This can be either uni-directional or bi-directional.
  • The domain layer is completely independent of all the other layers. Just pure business logic & data.
    If you’re familiar with my Clean Architecture course, the above diagram feels somewhat familiar. If you aren’t, no worries. It’s not a prerequisite for this tutorial series. Note that classes such as Firestore or FirebaseAuth are ready-made data sources, so we will write code from repositories upwards.

Before we go ahead and take a closer look at what are the roles of all the layers and their classes, let’s first tackle the age old question of folder structure.

Folder structure

I’m the first to admit that the folder structure outlined in the Clean Architecture course is a pain to deal with. With DDD, we’re going to take a different approach.

Layers will hold features, not the other way around. This will still keep the code readable but, most importantly, it will ensure that adding more features and sub-features is going to be a pure bliss!

Let’s take a look at the **notes **feature. While the main **notes **folder is present inside every layer (application, domain, infrastructure, presentation), its subfolders are different!

What does this mean? Well, we can have both a good folder structure and a separation into architectural layers at the same time 🎉🥳

It’s also worth noting that some features don’t even have to necessarily be represented in all layers. Notice that **splash **folder in the presentation layer? There is no inherent “splash screen logic”, so it doesn’t make sense to put it into other layers.

All in all, we can mix and match the dependencies in between features as long as we keep true to the dependency flow outlined in the diagram above (domain layer has to have ZERO dependencies on other layers).
Flutter Firebase & DDD

Architectural Layers

Unlike with the spaghetti architecture 🍝, you will always know where to put a certain class when you’re following the Domain-Driven Design principles. Each one of the layers has a clear-cut responsibility. As you can see on the folder structure picture above, every architectural layer contains **features **and possibly a core folder which holds classes common to all the features in that layer (helpers, abstract classes, …).

Presentation

This layer is all Widgets 💙 and also the state of the Widgets. I already mentioned that we’re going to use BLoC in this series. If you’re not familiar with this state management pattern, I’d recommend you to check out this tutorial. The main difference from something like a ChangeNotifier is that BLoCs are separated into 3 core components:

  • States - Their sole purpose is to deliver values (variables) to the widgets.
  • Events - Equivalent to methods inside a ChangeNotifier. These trigger logic inside the BLoC and can optionally carry some raw data (e.g. String from a TextField) to the BLoC.
  • **BLoC **- NOT A PART OF THE PRESENTATION LAYER!!! But it executes logic based on the incoming events and then it outputs states.

So, if you’re not using BLoC, just replace the State and Event classes with a single View Model class of your choice.

With Domain-Driven Design, UI is dumbest part of the app. That’s because it’s at the boundary of our code and it’s totally dependent on the Flutter framework. Its logic is limited to creating “eye candy” for the user. So while animation code does belong into this layer, even things like form validation are NOT done inside the presentation layer.

Application

This layer is away from all of the outside interfaces of an app. **You aren’t going to find any UI code, network code, or database code here. **Application layer has only one job - orchestrating all of the other layers. No matter where the data originates (user input, real-time Firestore Stream, device location), its first destination is going to be the application layer.

The arrow are Events which are sent from the presentation layer

The role of the application layer is to decide “what to do next” with the data. It doesn’t perform any complex business logic, instead, it mostly just makes sure that the user input is validated (by calling things in the **domain layer) **or it manages subscriptions to infrastructure data Streams (not directly, but by utilizing the dependency inversion principle, more on that later).

Domain

The domain layer is the pristine center of an app. It is fully self contained and it _doesn’t _depend on any other layers. Domain is not concerned with anything but doing its own job well.

This is the part of an app which doesn’t care if you switch from Firebase to a REST API or if you change your mind and you migrate from the Hive database to Moor. Because domain doesn’t depend on anything external, changes to such implementation details don’t affect it. On the other hand, all the other layers do depend on domain.

So, what exactly goes on inside the domain layer? This is where your business logic lives. We are going to get to everything in detail in the next parts of this series, but everything which is not Flutter/server/device dependent goes into domain. This includes:

  • Validating data and keeping it valid with ValueObjects. For example, instead of using a plain String for the body of a Note, we’re going to have a separate class called NoteBody. It will encapsulate a String value and make sure that it’s no more than 1000 characters long and that it’s not empty.

This kind of validation is usually reserved for the UI. We’re, however, going to take advantage of the Dart type system to its full extent. For example, although both EmailAddress and Password encapsulate a String, it will be impossible to pass an EmailAddress to a method expecting a Password argument and vice versa.

  • Transforming data (e.g. make any color fully opaque).
  • Grouping and uniquely identifying data that belongs together through Entity classes (e.g. User or Note entities)
  • Performing complex business logic - this is not necessarily always the case in client Flutter apps, since you should leave complex logic to the server. Although, if you’re building a truly serverless 😉 app, this is where you’d put that logic.

The domain layer is the core of you app. Changes in the other layers don’t affect it. However, changes to the domain affect every other layer. This makes sense - you’re probably not changing the business logic on a daily basis.
In addition to all this, the domain layer is also the home of Failures. Handling exceptions is a 💩 experience. They’re flying left and right across multiple layers of code. You have to check documentation (even your own one) a million times to know which method throws which exception. Even then, if you come back to your code in a few months, you’re going to be again unsure if you handled all exceptional cases.

We want to mitigate this pain with union types! Instead of using the return keyword for “correct” data and the throw keyword when something goes wrong, we’re going to have Failure unions. This will also ensure that we’ll know about a method’s possible failures without checking the documentation. Again, we’re going to get to the details in the next parts.

Infrastructure

Much like presentation, this layer is also at the boundary of our app. Although, of course, it’s at the “opposite end” and instead of dealing with the user input and visual output, it deals with APIs, Firebase libraries, databases and device sensors.

The infrastructure layer is composed of two parts - low-level data sources and high level repositories. Additionally, this layer holds data transfer objects (DTOs). Let’s break it down!

DTOs are classes whose sole purpose is to convert data between entities and value objects from the domain layer and the plain data of the outside world. As you know, only dumb data like String or int can be stored inside Firestore but we don’t want this kind of unvalidated data throughout our app. That’s precisely why we’ll use ValueObjects described above everywhere, except for the infractructure layer. DTOs can also be serialized and deserialized.

Data sources operate at the lowest level. Remote data sources fit JSON response strings gotten from a server into DTOs, and also perform server requests with DTOs converted to JSON. Similarly, local data sources fetch data from a local database or from the device sensors.

Firebase client libraries like **cloud_firestore **and firebase_auth do the heavy lifting of data sources for us. That’s why we won’t create any data sources in this course.

Repositories perform an important task of being the boundary between the domain and application layers and the ugly outside world. It’s their job to take DTOs and unruly Exceptions from data sources as their input, and return nice Either<Failure, Entity> as their output.

If this is the first time you hear about Either, you’ll find out more about it in the next parts. Another option is to read this Kotlin documentation if you are impatient 😄

If you don’t use Firebase Firestore, you’ll probably need to cache data locally yourself. In that case, it’s the job of the **repository **to perform the caching logic and orchestrate putting data from the remote data source to the local one.

Code is coming

If you made it through this information-packed article, I salute you. Although we’d all like to immediately start coding, this tendency is precisely what causes spaghetti code and spaghetti architecture to rise 🍝. Having at least this preliminary information in mind when we start coding in the next part (after setting up Firebase), I’ll then guide you through the intricate details as we go. One may say that AOT learning will be complemented by JIT explanations. Yes, I know I should get some fresh air… See you in the next part!

#flutter #firebases #webdev

What is GEEK

Buddha Community

Flutter Firebase & DDD Course [1] – Domain-Driven Design Principles

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

A Wrapper for Sembast and SQFlite to Enable Easy

FHIR_DB

This is really just a wrapper around Sembast_SQFLite - so all of the heavy lifting was done by Alex Tekartik. I highly recommend that if you have any questions about working with this package that you take a look at Sembast. He's also just a super nice guy, and even answered a question for me when I was deciding which sembast version to use. As usual, ResoCoder also has a good tutorial.

I have an interest in low-resource settings and thus a specific reason to be able to store data offline. To encourage this use, there are a number of other packages I have created based around the data format FHIR. FHIR® is the registered trademark of HL7 and is used with the permission of HL7. Use of the FHIR trademark does not constitute endorsement of this product by HL7.

Using the Db

So, while not absolutely necessary, I highly recommend that you use some sort of interface class. This adds the benefit of more easily handling errors, plus if you change to a different database in the future, you don't have to change the rest of your app, just the interface.

I've used something like this in my projects:

class IFhirDb {
  IFhirDb();
  final ResourceDao resourceDao = ResourceDao();

  Future<Either<DbFailure, Resource>> save(Resource resource) async {
    Resource resultResource;
    try {
      resultResource = await resourceDao.save(resource);
    } catch (error) {
      return left(DbFailure.unableToSave(error: error.toString()));
    }
    return right(resultResource);
  }

  Future<Either<DbFailure, List<Resource>>> returnListOfSingleResourceType(
      String resourceType) async {
    List<Resource> resultList;
    try {
      resultList =
          await resourceDao.getAllSortedById(resourceType: resourceType);
    } catch (error) {
      return left(DbFailure.unableToObtainList(error: error.toString()));
    }
    return right(resultList);
  }

  Future<Either<DbFailure, List<Resource>>> searchFunction(
      String resourceType, String searchString, String reference) async {
    List<Resource> resultList;
    try {
      resultList =
          await resourceDao.searchFor(resourceType, searchString, reference);
    } catch (error) {
      return left(DbFailure.unableToObtainList(error: error.toString()));
    }
    return right(resultList);
  }
}

I like this because in case there's an i/o error or something, it won't crash your app. Then, you can call this interface in your app like the following:

final patient = Patient(
    resourceType: 'Patient',
    name: [HumanName(text: 'New Patient Name')],
    birthDate: Date(DateTime.now()),
);

final saveResult = await IFhirDb().save(patient);

This will save your newly created patient to the locally embedded database.

IMPORTANT: this database will expect that all previously created resources have an id. When you save a resource, it will check to see if that resource type has already been stored. (Each resource type is saved in it's own store in the database). It will then check if there is an ID. If there's no ID, it will create a new one for that resource (along with metadata on version number and creation time). It will save it, and return the resource. If it already has an ID, it will copy the the old version of the resource into a _history store. It will then update the metadata of the new resource and save that version into the appropriate store for that resource. If, for instance, we have a previously created patient:

{
    "resourceType": "Patient",
    "id": "fhirfli-294057507-6811107",
    "meta": {
        "versionId": "1",
        "lastUpdated": "2020-10-16T19:41:28.054369Z"
    },
    "name": [
        {
            "given": ["New"],
            "family": "Patient"
        }
    ],
    "birthDate": "2020-10-16"
}

And we update the last name to 'Provider'. The above version of the patient will be kept in _history, while in the 'Patient' store in the db, we will have the updated version:

{
    "resourceType": "Patient",
    "id": "fhirfli-294057507-6811107",
    "meta": {
        "versionId": "2",
        "lastUpdated": "2020-10-16T19:45:07.316698Z"
    },
    "name": [
        {
            "given": ["New"],
            "family": "Provider"
        }
    ],
    "birthDate": "2020-10-16"
}

This way we can keep track of all previous version of all resources (which is obviously important in medicine).

For most of the interactions (saving, deleting, etc), they work the way you'd expect. The only difference is search. Because Sembast is NoSQL, we can search on any of the fields in a resource. If in our interface class, we have the following function:

  Future<Either<DbFailure, List<Resource>>> searchFunction(
      String resourceType, String searchString, String reference) async {
    List<Resource> resultList;
    try {
      resultList =
          await resourceDao.searchFor(resourceType, searchString, reference);
    } catch (error) {
      return left(DbFailure.unableToObtainList(error: error.toString()));
    }
    return right(resultList);
  }

You can search for all immunizations of a certain patient:

searchFunction(
        'Immunization', 'patient.reference', 'Patient/$patientId');

This function will search through all entries in the 'Immunization' store. It will look at all 'patient.reference' fields, and return any that match 'Patient/$patientId'.

The last thing I'll mention is that this is a password protected db, using AES-256 encryption (although it can also use Salsa20). Anytime you use the db, you have the option of using a password for encryption/decryption. Remember, if you setup the database using encryption, you will only be able to access it using that same password. When you're ready to change the password, you will need to call the update password function. If we again assume we created a change password method in our interface, it might look something like this:

class IFhirDb {
  IFhirDb();
  final ResourceDao resourceDao = ResourceDao();
  ...
    Future<Either<DbFailure, Unit>> updatePassword(String oldPassword, String newPassword) async {
    try {
      await resourceDao.updatePw(oldPassword, newPassword);
    } catch (error) {
      return left(DbFailure.unableToUpdatePassword(error: error.toString()));
    }
    return right(Unit);
  }

You don't have to use a password, and in that case, it will save the db file as plain text. If you want to add a password later, it will encrypt it at that time.

General Store

After using this for a while in an app, I've realized that it needs to be able to store data apart from just FHIR resources, at least on occasion. For this, I've added a second class for all versions of the database called GeneralDao. This is similar to the ResourceDao, but fewer options. So, in order to save something, it would look like this:

await GeneralDao().save('password', {'new':'map'});
await GeneralDao().save('password', {'new':'map'}, 'key');

The difference between these two options is that the first one will generate a key for the map being stored, while the second will store the map using the key provided. Both will return the key after successfully storing the map.

Other functions available include:

// deletes everything in the general store
await GeneralDao().deleteAllGeneral('password'); 

// delete specific entry
await GeneralDao().delete('password','key'); 

// returns map with that key
await GeneralDao().find('password', 'key'); 

FHIR® is a registered trademark of Health Level Seven International (HL7) and its use does not constitute an endorsement of products by HL7®

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add fhir_db

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  fhir_db: ^0.4.3

Alternatively, your editor might support or flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:fhir_db/dstu2.dart';
import 'package:fhir_db/dstu2/fhir_db.dart';
import 'package:fhir_db/dstu2/general_dao.dart';
import 'package:fhir_db/dstu2/resource_dao.dart';
import 'package:fhir_db/encrypt/aes.dart';
import 'package:fhir_db/encrypt/salsa.dart';
import 'package:fhir_db/r4.dart';
import 'package:fhir_db/r4/fhir_db.dart';
import 'package:fhir_db/r4/general_dao.dart';
import 'package:fhir_db/r4/resource_dao.dart';
import 'package:fhir_db/r5.dart';
import 'package:fhir_db/r5/fhir_db.dart';
import 'package:fhir_db/r5/general_dao.dart';
import 'package:fhir_db/r5/resource_dao.dart';
import 'package:fhir_db/stu3.dart';
import 'package:fhir_db/stu3/fhir_db.dart';
import 'package:fhir_db/stu3/general_dao.dart';
import 'package:fhir_db/stu3/resource_dao.dart'; 

example/lib/main.dart

import 'package:fhir/r4.dart';
import 'package:fhir_db/r4.dart';
import 'package:flutter/material.dart';
import 'package:test/test.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final resourceDao = ResourceDao();

  // await resourceDao.updatePw('newPw', null);
  await resourceDao.deleteAllResources(null);

  group('Playing with passwords', () {
    test('Playing with Passwords', () async {
      final patient = Patient(id: Id('1'));

      final saved = await resourceDao.save(null, patient);

      await resourceDao.updatePw(null, 'newPw');
      final search1 = await resourceDao.find('newPw',
          resourceType: R4ResourceType.Patient, id: Id('1'));
      expect(saved, search1[0]);

      await resourceDao.updatePw('newPw', 'newerPw');
      final search2 = await resourceDao.find('newerPw',
          resourceType: R4ResourceType.Patient, id: Id('1'));
      expect(saved, search2[0]);

      await resourceDao.updatePw('newerPw', null);
      final search3 = await resourceDao.find(null,
          resourceType: R4ResourceType.Patient, id: Id('1'));
      expect(saved, search3[0]);

      await resourceDao.deleteAllResources(null);
    });
  });

  final id = Id('12345');
  group('Saving Things:', () {
    test('Save Patient', () async {
      final humanName = HumanName(family: 'Atreides', given: ['Duke']);
      final patient = Patient(id: id, name: [humanName]);
      final saved = await resourceDao.save(null, patient);

      expect(saved.id, id);

      expect((saved as Patient).name?[0], humanName);
    });

    test('Save Organization', () async {
      final organization = Organization(id: id, name: 'FhirFli');
      final saved = await resourceDao.save(null, organization);

      expect(saved.id, id);

      expect((saved as Organization).name, 'FhirFli');
    });

    test('Save Observation1', () async {
      final observation1 = Observation(
        id: Id('obs1'),
        code: CodeableConcept(text: 'Observation #1'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save(null, observation1);

      expect(saved.id, Id('obs1'));

      expect((saved as Observation).code.text, 'Observation #1');
    });

    test('Save Observation1 Again', () async {
      final observation1 = Observation(
          id: Id('obs1'),
          code: CodeableConcept(text: 'Observation #1 - Updated'));
      final saved = await resourceDao.save(null, observation1);

      expect(saved.id, Id('obs1'));

      expect((saved as Observation).code.text, 'Observation #1 - Updated');

      expect(saved.meta?.versionId, Id('2'));
    });

    test('Save Observation2', () async {
      final observation2 = Observation(
        id: Id('obs2'),
        code: CodeableConcept(text: 'Observation #2'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save(null, observation2);

      expect(saved.id, Id('obs2'));

      expect((saved as Observation).code.text, 'Observation #2');
    });

    test('Save Observation3', () async {
      final observation3 = Observation(
        id: Id('obs3'),
        code: CodeableConcept(text: 'Observation #3'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save(null, observation3);

      expect(saved.id, Id('obs3'));

      expect((saved as Observation).code.text, 'Observation #3');
    });
  });

  group('Finding Things:', () {
    test('Find 1st Patient', () async {
      final search = await resourceDao.find(null,
          resourceType: R4ResourceType.Patient, id: id);
      final humanName = HumanName(family: 'Atreides', given: ['Duke']);

      expect(search.length, 1);

      expect((search[0] as Patient).name?[0], humanName);
    });

    test('Find 3rd Observation', () async {
      final search = await resourceDao.find(null,
          resourceType: R4ResourceType.Observation, id: Id('obs3'));

      expect(search.length, 1);

      expect(search[0].id, Id('obs3'));

      expect((search[0] as Observation).code.text, 'Observation #3');
    });

    test('Find All Observations', () async {
      final search = await resourceDao.getResourceType(
        null,
        resourceTypes: [R4ResourceType.Observation],
      );

      expect(search.length, 3);

      final idList = [];
      for (final obs in search) {
        idList.add(obs.id.toString());
      }

      expect(idList.contains('obs1'), true);

      expect(idList.contains('obs2'), true);

      expect(idList.contains('obs3'), true);
    });

    test('Find All (non-historical) Resources', () async {
      final search = await resourceDao.getAll(null);

      expect(search.length, 5);
      final patList = search.toList();
      final orgList = search.toList();
      final obsList = search.toList();
      patList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Patient);
      orgList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Organization);
      obsList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Observation);

      expect(patList.length, 1);

      expect(orgList.length, 1);

      expect(obsList.length, 3);
    });
  });

  group('Deleting Things:', () {
    test('Delete 2nd Observation', () async {
      await resourceDao.delete(
          null, null, R4ResourceType.Observation, Id('obs2'), null, null);

      final search = await resourceDao.getResourceType(
        null,
        resourceTypes: [R4ResourceType.Observation],
      );

      expect(search.length, 2);

      final idList = [];
      for (final obs in search) {
        idList.add(obs.id.toString());
      }

      expect(idList.contains('obs1'), true);

      expect(idList.contains('obs2'), false);

      expect(idList.contains('obs3'), true);
    });

    test('Delete All Observations', () async {
      await resourceDao.deleteSingleType(null,
          resourceType: R4ResourceType.Observation);

      final search = await resourceDao.getAll(null);

      expect(search.length, 2);

      final patList = search.toList();
      final orgList = search.toList();
      patList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Patient);
      orgList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Organization);

      expect(patList.length, 1);

      expect(patList.length, 1);
    });

    test('Delete All Resources', () async {
      await resourceDao.deleteAllResources(null);

      final search = await resourceDao.getAll(null);

      expect(search.length, 0);
    });
  });

  group('Password - Saving Things:', () {
    test('Save Patient', () async {
      await resourceDao.updatePw(null, 'newPw');
      final humanName = HumanName(family: 'Atreides', given: ['Duke']);
      final patient = Patient(id: id, name: [humanName]);
      final saved = await resourceDao.save('newPw', patient);

      expect(saved.id, id);

      expect((saved as Patient).name?[0], humanName);
    });

    test('Save Organization', () async {
      final organization = Organization(id: id, name: 'FhirFli');
      final saved = await resourceDao.save('newPw', organization);

      expect(saved.id, id);

      expect((saved as Organization).name, 'FhirFli');
    });

    test('Save Observation1', () async {
      final observation1 = Observation(
        id: Id('obs1'),
        code: CodeableConcept(text: 'Observation #1'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save('newPw', observation1);

      expect(saved.id, Id('obs1'));

      expect((saved as Observation).code.text, 'Observation #1');
    });

    test('Save Observation1 Again', () async {
      final observation1 = Observation(
          id: Id('obs1'),
          code: CodeableConcept(text: 'Observation #1 - Updated'));
      final saved = await resourceDao.save('newPw', observation1);

      expect(saved.id, Id('obs1'));

      expect((saved as Observation).code.text, 'Observation #1 - Updated');

      expect(saved.meta?.versionId, Id('2'));
    });

    test('Save Observation2', () async {
      final observation2 = Observation(
        id: Id('obs2'),
        code: CodeableConcept(text: 'Observation #2'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save('newPw', observation2);

      expect(saved.id, Id('obs2'));

      expect((saved as Observation).code.text, 'Observation #2');
    });

    test('Save Observation3', () async {
      final observation3 = Observation(
        id: Id('obs3'),
        code: CodeableConcept(text: 'Observation #3'),
        effectiveDateTime: FhirDateTime(DateTime(1981, 09, 18)),
      );
      final saved = await resourceDao.save('newPw', observation3);

      expect(saved.id, Id('obs3'));

      expect((saved as Observation).code.text, 'Observation #3');
    });
  });

  group('Password - Finding Things:', () {
    test('Find 1st Patient', () async {
      final search = await resourceDao.find('newPw',
          resourceType: R4ResourceType.Patient, id: id);
      final humanName = HumanName(family: 'Atreides', given: ['Duke']);

      expect(search.length, 1);

      expect((search[0] as Patient).name?[0], humanName);
    });

    test('Find 3rd Observation', () async {
      final search = await resourceDao.find('newPw',
          resourceType: R4ResourceType.Observation, id: Id('obs3'));

      expect(search.length, 1);

      expect(search[0].id, Id('obs3'));

      expect((search[0] as Observation).code.text, 'Observation #3');
    });

    test('Find All Observations', () async {
      final search = await resourceDao.getResourceType(
        'newPw',
        resourceTypes: [R4ResourceType.Observation],
      );

      expect(search.length, 3);

      final idList = [];
      for (final obs in search) {
        idList.add(obs.id.toString());
      }

      expect(idList.contains('obs1'), true);

      expect(idList.contains('obs2'), true);

      expect(idList.contains('obs3'), true);
    });

    test('Find All (non-historical) Resources', () async {
      final search = await resourceDao.getAll('newPw');

      expect(search.length, 5);
      final patList = search.toList();
      final orgList = search.toList();
      final obsList = search.toList();
      patList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Patient);
      orgList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Organization);
      obsList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Observation);

      expect(patList.length, 1);

      expect(orgList.length, 1);

      expect(obsList.length, 3);
    });
  });

  group('Password - Deleting Things:', () {
    test('Delete 2nd Observation', () async {
      await resourceDao.delete(
          'newPw', null, R4ResourceType.Observation, Id('obs2'), null, null);

      final search = await resourceDao.getResourceType(
        'newPw',
        resourceTypes: [R4ResourceType.Observation],
      );

      expect(search.length, 2);

      final idList = [];
      for (final obs in search) {
        idList.add(obs.id.toString());
      }

      expect(idList.contains('obs1'), true);

      expect(idList.contains('obs2'), false);

      expect(idList.contains('obs3'), true);
    });

    test('Delete All Observations', () async {
      await resourceDao.deleteSingleType('newPw',
          resourceType: R4ResourceType.Observation);

      final search = await resourceDao.getAll('newPw');

      expect(search.length, 2);

      final patList = search.toList();
      final orgList = search.toList();
      patList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Patient);
      orgList.retainWhere(
          (resource) => resource.resourceType == R4ResourceType.Organization);

      expect(patList.length, 1);

      expect(patList.length, 1);
    });

    test('Delete All Resources', () async {
      await resourceDao.deleteAllResources('newPw');

      final search = await resourceDao.getAll('newPw');

      expect(search.length, 0);

      await resourceDao.updatePw('newPw', null);
    });
  });
} 

Download Details:

Author: MayJuun

Source Code: https://github.com/MayJuun/fhir/tree/main/fhir_db

#sqflite  #dart  #flutter 

Terry  Tremblay

Terry Tremblay

1598396940

What is Flutter and why you should learn it?

Flutter is an open-source UI toolkit for mobile developers, so they can use it to build native-looking** Android and iOS** applications from the same code base for both platforms. Flutter is also working to make Flutter apps for Web, PWA (progressive Web-App) and Desktop platform (Windows,macOS,Linux).

flutter-mobile-desktop-web-embedded_min

Flutter was officially released in December 2018. Since then, it has gone a much stronger flutter community.

There has been much increase in flutter developers, flutter packages, youtube tutorials, blogs, flutter examples apps, official and private events, and more. Flutter is now on top software repos based and trending on GitHub.

Flutter meaning?

What is Flutter? this question comes to many new developer’s mind.

humming_bird_dart_flutter

Flutter means flying wings quickly, and lightly but obviously, this doesn’t apply in our SDK.

So Flutter was one of the companies that were acquired by **Google **for around $40 million. That company was based on providing gesture detection and recognition from a standard webcam. But later when the Flutter was going to release in alpha version for developer it’s name was Sky, but since Google already owned Flutter name, so they rename it to Flutter.

Where Flutter is used?

Flutter is used in many startup companies nowadays, and even some MNCs are also adopting Flutter as a mobile development framework. Many top famous companies are using their apps in Flutter. Some of them here are

Dream11

Dream11

NuBank

NuBank

Reflectly app

Reflectly app

Abbey Road Studios

Abbey Road Studios

and many more other apps. Mobile development companies also adopted Flutter as a service for their clients. Even I was one of them who developed flutter apps as a freelancer and later as an IT company for mobile apps.

Flutter as a service

#dart #flutter #uncategorized #flutter framework #flutter jobs #flutter language #flutter meaning #flutter meaning in hindi #google flutter #how does flutter work #what is flutter

Best Review

1629825646

Design Beast Review & OTO Link

Design Beast Review & OTOs + $20k Bonuses

CHECK BONUSES & GRAB IT AT: https://bit.ly/3yhtcqi

Welcome to my Design Beast Review A Very warm welcome to my DesignBeast Review Here You Will Find Honest Opinion About The Design Beast Whether It is A Right Fit For You or not also I Have Covered All Working processes of DesignBeast, Live Video Demo, features Pros & Cons & All Design Beast OTO details.

Govind Rana Here Stay Till the End Of This Review I Have included $20k Bonuses At the end Of DesignBeast Review

DesignBeast Review – World finest graphic designing & animation software that will come into existence in some days. If you are searching for DesignBeast Review then this is the right platform to get in-depth information and the truth for Design Beast Review. An AI-based designing software that enables the 3D designing technology to you.

I am pretty much excited to share my point of view about the design beast. and this is because I want to meet you to the high technology graphics software.

This software is going to launch on 26 Aug. 2021 by the very famous vendor Paul Ponna and this time he is launching is 2 years of efforts on this amazing app. So do believe me without any doubt, here I only share the actual facts for Designbeast Review.

At this time the limited information is available on the web so I have included the creator of DesignBeast, Paul Ponna’s previous launches, what is DesignBeast, features & benefits, examples, who will best fit for this app, pros & cons, included with a huge bonuses.

Discount will be rolling out from 26th August

(fingers crossed till its launch because it is the launch beyond expectations)

Design Beast Review – Overview

  • Creator: Paul Ponna
  • Product Name: DesignBeast
  • Launch Date – 2021-Aug-24
  • Launch Timing – 11:00 EDT
  • Pricing – $67
  • Official Website – Visit
  • Money-Back Guarantee- Information Not Available
  • Category – Graphic Designing
  • Training – Yes, Available
  • Bonuses – Techevoke Special Bonuses Available

About Paul Ponna the vendor & Creator of DesignBeast

Paul Ponna is an entrepreneur and a digital geek in the internet marketing niche. His previous launches were hit the market products and were evergreen. No comparison of his products because he knows what is a need in today’s market and how online marketers will get benefited from online technologies.

So let’s have a look at Paul Ponna’s previous hits in the saas industry.

  1. DoodleMaker – This is the doodle video maker and the popular software on JVZoo that is the biggest launch in the history of internet marketing software. With a doodle maker, you can create studio-quality doodle videos with this application.
  2. VideoCreator – A readymade video editing app that is more authentic than existing video editing software. No more templates creation is required and no extra efforts to make and you can make exciting effects with videocreator.
  3. There is more software that has been launched by Paul Ponna…
  • DoodleMaker
  • Avatar Builder
  • VideoCreator
  • DesignBeast (available on 26th Aug)

Paul Ponna is a tech entrepreneur and he was started his journey from his 18 and with a website and hosting spending only $20. And he is a millionaire and frequently launches products that are really amazing and useful.

So not further delays let come to the designbeast review and let’s talk about what will be this software and how can you get benefited from this.

What is Design Beast?

Design beast is a software that comes with 6 world-class designing technology, and with those 6 modules, you can fulfill your graphics needs in just 1 price tag.

DesignBeast is a software that is responsible for multipurpose designs and better technology including these below-mentioned modules.

  1. Design Automation App #1– All in One Design and Mockup Engine
  2. Design Automation App #1– 3D Live Motion Photos
  3. Design Automation App #1– Magic Object Remover
  4. Design Automation App #1– 1-Click Background Removal
  5. Design Automation App #1– Slick Image Editor
  6. Design Automation App #1– AI Logo Creator

This is app bundle is fully loaded with advanced graphics features that are essential for making high-quality posts, infographics, motion pictures, 3D banners, and more.

Here are all modules explanations of DesignBeast

So this is clear this app has various technologies that are responsible for advanced editing and professional graphical designs. So here is the module’s explanation.

  1. All in One Design and mockup Engine

This is a designs library, not an ordinary image or premade design library. All elements are customizable and you can create any of your imagination with this design and mockup engine.

7000+ ready-to-use customizable designs and mockups are available in this module. Just head over to the DesignBeast software and you will get the professional DFY designs and mockups for your graphics need.

There are for all social apps, means available in various sizes.

2. 3D Live Motion Photos

Now you can convert a still, boring photo to a live, 3D effect photo with the A.I. technology of DesignBeast. With this effect, you can engage with your audience in a more effective manner.

And you all know that a moving object with a visual effect is 10x more engaging than an ordinary graphical image. with this technology, you can grab the attention of your customers and get more clicks on your sales platform.

3. Magic Object Removal Tool

Most of the time we need to remove some object or any person from any of the selected images and this module will give you access to select the required object or person and the remove that thing is just one click.

The feature Paul Ponna offers in his software is rarely available on any other software. With only one click the magic happens and the object will be removed.

4. 1-Click Background Removal

Because the software has technology that is based on AI and Machine Learning. So it auto-detects the edges and objects in your photos and automatically erases the background from any photo.

You don’t need to make extra effects just select the 1 click background removal option and click on the image background and it will vanish within seconds.

5. Slick Image Editor

This has the multi-feature of basic editing for any photo. Just like edit, crop, short, effects, blur, and more. You don’t need to go for different apps to perform different tasks every time.

You can convert any still normal photo to a high-class visual and ready-to-use, ready-to-print photo with this module.

6. Artificial Intelligence Logo Creator

An AI logo creator, not just a free tool that is available in the online market but it is quite effective and useful for you to generate any kind of logo. You can now bulk-create 50 logo variations for any brand in 3 easy steps.

All designs are fully customizable, also a single object is customizable with this app.

How DesignBeast will fire in the saas market?

In this section of DesignBeast Review, I am sharing its popularity, hype, and the vendor name-fame with you, so that you can evaluate its worth.

Just because you need a better, time-saving, authentic, graphic designing and animation software that will fulfill your professional graphics need for online marketing.

Because paul Ponna is a tech entrepreneur and he knows what is write to tab the market and what should be the next useful tool for every marketer.

DesignBeast is now going to be a popular one from the software list of its vendor. No matter what competitors of DesignBeast will say about this software. But as a consumer and a digital marketer, I am pretty much excited for its official launch.

DesignBeast Features & Benefits

If you want to create designs for Social media, websites, e-commerce sites, local businesses, promos, and advertising then focus on the features & benefits of DesignBeast Review, so that you can evaluate its actual strength.

 A.I. & Machine Learning Technology

This is the platform that suggests automatically the designs, objects, effects & more things that are based on your needs and the design frame you choose.

Automate design tasks with machine learning and artificial intelligence to leapfrog your competition and maximize revenues.

 6 Apps in the Price of One

There is no comparison of this app in the online market because the bundle of 6 apps and those apps are highly authentic useful in today’s competitive marketing world.

You can replace multiple graphics apps from one that is DesignBeast and you need to replace it if you want to save your money and time.

 Multilingual

This app is available in multi-languages, and with this feature, it doesn’t matter from where you are in this world.

It enables you to sell your service towards the globe and also give you the access to create graphical content in your local language.

 Commercial and resell rights available

Commercial licensing brings you to another stage of selling your services to clients. Now you can freely sell all generated content to your clients in the market. Also charge extra fees according to your skills and set your service on commercial platforms.

 Copywrite free assets and resources

Assets that are really expensive and everyone even I needs to purchase from the online market and those services are very expensive for all of us. But now all are available at one place that is design beast, you will get premium royalty-free images, icons, backgrounds & animations.

 Save Time and money

You can build world-class designs in minutes and all designs are professional, in starting you need to learn some lessons and practice to perform with DesignBeast membersarea.

 Dynamic Visual Effects

The effects offered by this software is so amazing and fully customizable so that I have given the term dynamic. All things are editable and ready to use.

Is there are any skills required to work with DesignBeast?

Designbeast is a DFY editable templates advanced graphic design software that will suggest to you the designs from its A.I. and machine learning technology. So I am sure you don’t need any advanced skills to use DesignBeast.

But to be honest, you need to work on these soft skills.

  1. Knowledge of using basic online apps.
  2. The mindset to Selecting the best
  3. Knowledge of colors
  4. Knowledge of graphics
  5. Understanding of designs
  6. Branding

And there are most soft skills required.

Design Beast Review – Who will be fit for this software?

So now in this series, it’s time to share the industry people who are best fit for this software that is Designbeast. And after lots of research and analysis, I decided to include these professionals in the DesignBeast audience. I am happy to share my point views in this DesignBeast Review.

  • Graphic Designers
  • Digital Marketers
  • Bloggers.
  • Vloggers
  • Youtubers
  • Media Agency
  • Advertising agency
  • Local Businesses
  • Ecommerce Players

DesignBeast Review – Pros & Cons

I have shared the sure short pros and cons for this revolutionary software. But there are some cons also available. After reviewing the product, as a marketer, I also realized this has lots of pros and some cons available in the market.

Pros

  • 6 modules in 1 app
  • 3d photo creation technology with AI and machine learning
  • Background and object removal technology.
  • Designs library over 7000
  • Kindly support team.
  • Trustable vendor
  • 30 Days money back gaurantee.
  • And more…

Cons

  • Some modules are more useful than 1 or 2 other modules.
  • You cannot download the software to your computer or on a desktop.
  • No more cons I have found for this software.

Design Beast OTOs/Upgrades

Here are the details of its upgrade, so that you can utilize all its advanced features. In this DesignBeast Review, I have mentioned the name and price of OTOs, and the rest of the details will be available soon.

Front End: DesignBeast Commercial

Price – $47 Onetime

  • Six Designs App For Price of One
  • Mockup Designer App
  • AI Logo Maker App
  • 1-Click Background Removal App
  • Live Motion Photos App
  • Multi-Purpose Image Editor App
  • Magic Object Removal App
  • 7000+ Ready-to-Use Templates
  • Millions of Royalty-Free Images
  • Copyright-Free Vectors & Icons
  • Hundreds of Fonts
  • Multi-Lingual Support
  • Step-by-Step Video Training
  • Commercial License
  • Sell The Designs For Profit
  • Facebook Group Access
  • Skype Mentorship Group Access
  • 8 Week Training Webinars

OTO#1: DesignBeast Elite

Price – $49 Onetime

Get access to additional features worth thousands. 10X your results, sales and profits and get ahead of the competition and other DesignBeast customers. 

  • Unlock 2,000 additional ready-to-use templates
  • Get 80 new templates added to your account each month for 1 year. (no monthly or yearly fees.)
  • Thousands of Premium Text Effects and Animations
  • Millions of Premium Royalty Free Design Assets, Icons and vectors.
  • Millions of Copyright-Free Image
  • Priority Future Software Updates

OTO#2: DesignBeast Agency

Price – $67

Sell videos for $300 to $500 each with the done-for-you agency package included. This upgrade makes it easy for everyone to find clients and sell their designs for top dollar. 

  • 5 sub accounts
  • Done-For-You Agency Marketing Bundle
  • Done-For-You Legal Client Contracts
  • Done-For-You Agency Website
  • Done-For-You Agency Sales Video

OTO#3: DesignBeast 4 in 1 Ultra.

Price – $39 OneTime

Customers get access to FOUR additional apps as part of this upgrade. 

  • Pixel Perfect
  • Instantly turn any image, even a low quality image, into ultra HD, high quality photo that can be blown up to any size – even billboard size – without any pixelation or distortion.
  • Animated Ads Builder 

Create animated ads in all languages, shapes and sizes using hundreds of ready to use design templates. Use animated ads to promote your products, create ads for clients or sell animated designs on freelancer websites like fiverr, upwork and freelancer to maximize profits. 

  • Video Resizer

With this powerful technology you can resize any video into multiple video sizes perfectly sized for all social platforms. Turn a single video into multiple dimensions and sizes within minutes and share the video onto different platforms to drive more traffic and sales!

  • Video Survey Pro

With this powerful app you can instantly collect:

* Video Testimonials

* Live video feedback from clients about your work

* Add video surveys on your websites to collect valuable information

* Have your team record video feedback about any project 

Streamline your workflows without any confusion or relying on old and outdated methods like email and text.  

OTO#4: DesignBeast Unlimited

Price $67 OneTime

With the DesignBeast basic license, you can create unlimited designs forever with one limit of 600 credits per month on each of the six apps included. 

The limits reset each month so you can continue creating amazing designs, graphics and animations forever without any monthly fees. 

This limit is put in place to prevent abuse and ensure all our customers are getting the best value for years to come at an unbeatable price.

As part of this special unlimited upgrade, you can remove all the monthly limits and restrictions for all the cutting-edge apps and technologies included. 

Design Beast Review Conclusion

From my take, this will be a good and useful tool for you if you belong to these above-mentioned professional categories. No matter you have advanced skills or not because everything will be DFY and ready to use. And the best thing is that you can customize and edit each and every pre-made effect, design, and more thing. According to my opinion, graphics designing software is ned for every marketer and business person, but everyone cannot go for photoshop, AI, and Coral, so for making it easy and useful there will be a choice in your hand that is DesignBeast.

CHECK BONUSES & GRAB IT AT: https://bit.ly/3yhtcqi

SOURCE: https://bit.ly/3Dch4KV

Flutter Firebase & DDD Course [1] – Domain-Driven Design Principles

Firebase 🔥 allows developers to get their apps working quickly. Flutter 💙 does the same thing. But, as it goes in life, trade-offs are everywhere. Sure, you can hack something together in a dash of enthusiasm but this initial excitement will fade away as soon as you get totally lost in your own code.

Flutter apps need structure that is easy to orient yourself in, testable and maintainable. It also wouldn’t hurt if the way you architect your Flutter apps allows for adding new features without a headache. Especially with a client-centric service such as Firebase Firestore, it’s extremely important to keep your code clean. Let’s do it by following the principles of Domain-Driven Design.

We’re going to build a fairly complex note-taking application featuring things such as:

  • Real-time Firestore data Streams
  • Extensive data validation for a rich user experience
  • Google & email + password authentication
  • Reorderable todo lists and much more

#firebase #flutter #developer