Couchbase Mobile brings the power of NoSQL to the edge. It is comprised of three components:
Couchbase Mobile supports flexible deployment models. You can deploy:
Note: The Dart SDK for Couchbase Lite is a community based project on GitHub and is not officially supported by Couchbase. If you have questions or issues with the SDK, please post them on the GitHub project.
In this learning path you will be reviewing an Mobile Application written in Dart and Flutter that uses the community supported Dart SDK for Couchbase Lite. You will learn the basics of:
Note: This tutorial will require either having an account already set up with Capella, Couchbase Database as a Service (DBaaS) offering or signing up for a free trial. Please see the Sync Gateway version of this learning path for developers looking to learn Couchbase Mobile with Couchbase Server and Sync Gateway via Docker containers.
Before you get started you should take the following prerequisites into consideration:
Familiarity with Bloc and statement management patterns in Flutter
Android SDK installed and setup (> v.32.0.0)
Android Build Tools (> v.32.0.0)
XCode 13 or later installed and setup
Android device or emulator running API level 23 (Android 6.0 Marshmallow) or above
iOS device or simulator setup for iOS 14 or later
IDE of choice (IntelliJ, Android Studio, VS Code, etc.)
Flutter > 3.0 installed, setup, and configured for your IDE of choice
curl HTTP client
Couchbase Capella
Couchbase Capella provides a free 30 day trial of Couchbase cluster, it is the easiest and fastest way to get started with Couchbase. Be up and running in just under 10 minutes with a fully managed database-as-a-service (DBaaS) and 50GB of initial storage and no upfront payment needed. You can try out our N1QL query language (SQL for JSON) for free along with App Services which allows you to sync information between any mobile application and Capella, eliminating database management efforts and reducing overall costs.
You can sign-up for Couchbase Capella following the link below:
Each section of the learning path will walk through a different feature of the demo application. The parts in this learning path build on one another and sometimes show multiple ways to achieve the same results learned, as the Dart Couchbase Lite SDK is very flexible. Once you understand the basics, you can decide which method works best for your team to query the database, return data, and display it for the end-user to interact with on the screen.
The demo application used in this learning path is based on auditing inventory in various warehouses for a fictitious company. Most companies have some inventory - from laptops to office supplies and must audit their stock from time to time. For example, when a user's laptop breaks, the Information Technology department can send out a replacement from the inventory of spare laptops they have on hand. In this app, the items we are auditing are cases of beer.
Users running the mobile app would log into the application to see the projects they are assigned to work on. Then, the user would look at the project to see which warehouse they need to travel to. Once at the warehouse, they would inspect the number of cases of beer, tracking them in the mobile application. Finally the data can be synced back to the server for use with other analytical data.
The demo application uses bloc, a very popular statement management patternfor Dart.
Bloc is used to manage dependency inversion, injection, and state management. Repositories and Services are registered using Bloc's MultiRepositoryProvider. The sample application is broken down into features which can be found in the src/lib/features directory.
The Database Provider, found in the src/lib/features/database/ diretory, is a custom class that manages the database state and lifecycle. Querying and updating documents in the database is handled using the repository pattern. Blocs will query or post updates to the repository and control the state of objects that the Flutter widgets can use to display information.
The application structure starts with the main function. It creates an InventoryAuditApp that is a Stateless Widget and sets up all repositories and services using MultiRepositoryProvider. The RouteBloc defined is used to handle all routing calls. This bloc defines a child, AppView, which is a stateful widget that uses a MultiBlocListern to react to changes in the route state and thus render new screens as requested.
The default state of the app is for the user to not be authenticated, which will call the LoginScreen widget to render. LoginScreen uses a BlocProvider to inject LoginBloc into the render tree which defines LoginForm as a child to render the UI. When a user taps the _LoginButton, the LoginSubmitted event is added to LoginBloc, which runs the _onSubmitted method to update state with if the user logged in properly or not. If the user is authenticated properly the state is updated and the BlocListner for RouteState will push the ProjectListScreenwidget to the render tree.
The user can use the menu drawer to navigate to other sections of the app or use the Floating Action button to add a new Project.
Couchbase Lite Key Value Engine with Dart and Flutter
Learn how-to include a Pre-built Database with Dart and Flutter
Learn how-to use Couchbase Lite Batch operations with Dart and Flutter
Learn how-to use Couchbase Lite Query Builder Engine with Dart and Flutter
Learn how-to use Couchbase Lite SQL++ Querying with Dart and Flutter
Learn how-to setup Couchbase Capella and App Services for use with Audit Inventory Demo App
**Learn how-to setup Couchbase Lite Replication with Couchbase Capella App Services, Dart, and Flutter