Code Monkey home page Code Monkey logo

celest's Introduction

Celest

Celest is the Flutter cloud platform. We enable Flutter and Dart developers to declaratively define their backend infrastructure in Dart.

And to stay up-to-date on the future of Celest, including managed deployments, join our waitlist at celest.dev.

Getting started with Celest

Prerequisites

To use Celest in your Flutter app, you need the following prerequisites:

  1. Install Flutter
  2. Create a new Flutter project (or choose an existing one)
  3. Download and install the Celest CLI

Creating a Celest project

That’s it! You are now ready to start building your backend - all in Dart!

Start by first creating a new Flutter project. If you have an existing Flutter project, you can use that instead. To start a new Flutter project, go to your console and run the following command.

$ flutter create <flutter_app>

Then, navigate to your new Flutter app directory.

$ cd <flutter_app>

Once you are in your Flutter app directory, run the following command to initialize your Celest project.

$ celest start

Once the command executes, Celest will spin up a local environment and watch for changes made to your backend, generating a Dart client for you to test your changes.

The CLI will also create a folder in your project called celest, which will include the following files.

flutter_app/
└── celest/
    ├── functions/                        # Celest Functions folder
    |   └── greeting.dart                 # Example API file
    ├── lib/
    │   │── client.dart                   # Generated client for your Flutter app
    │   ├── models/                       # Custom API models
    |   |   └── person.dart
    │   └── exceptions/                   # Custom API exceptions
    |       └── bad_name_exception.dart
    └── test/                             # Tests for your backend

To get started building your serverless cloud function, navigate to the <flutter_app>/celest/functions/ folder and create a file named <api_name>.dart. You can create as many APIs as you want in this directory. Think of each file as a way to organize and group multiple Celest Functions of similar functionality into a namespace.

Celest Functions are defined as top-level functions as shown below.

Future<String> sayHello({
  required String name,
}) async {
  return 'Hello, $name';
}

Future<String> sayGoodbye({
  required String name,
}) async {
  return 'Goodbye, $name';
}

That's all you need to define your API! Now, you can connect your Flutter app to your cloud functions by using the code-generated client as shown in the following example. Replace the contents of the main.dart file in your Flutter app to the following code-snippet.

import 'package:flutter/material.dart';
// Import the generated Celest client
import 'package:celest_backend/client.dart';

void main() {
  // Initializes Celest in your Flutter app
  celest.init();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Homepage'),
        ),
        body: Center(
          child: FutureBuilder(
            // Call your function using the Celest client
            future: celest.functions.greeting.sayHello(name: 'Celest'),
            builder: (_, snapshot) => switch (snapshot) {
              AsyncSnapshot(:final data?) => Text(data),
              AsyncSnapshot(:final error?) =>
                Text('${error.runtimeType}: $error'),
              _ => const CircularProgressIndicator(),
            },
          ),
        ),
      ),
    );
  }
}

You have now set up your Celest project and integrated it into your Flutter app. Follow our documentation to learn more about using Celest Functions.

Connect with us

celest's People

Contributors

dnys1 avatar dependabot[bot] avatar abdallahshaban557 avatar hassanteslim007 avatar wolfenrain avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.