Skip to content

Ali-AlDhamen/celest-todo-app

Repository files navigation

🌟 Celest Todo App

A simple yet elegant Todo application built with Flutter for the frontend and Dart using Celest for the backend. Dive into the world of seamless full-stack development in Dart.

🚀 Getting Started

1. Create the Flutter App

flutter create todo-app

2. Download Celest

Download Celest from the official website:

🔗 Celest Download

3. Initialize and Run Celest

start celest

4. Run the Flutter App

flutter run

5. Run the Json Database

npx json-server --watch --port 8000 ./data/db.json

📚 Working with Celest

Define Models

Create your models in:

celest/lib/models

Define Functions

Create functions to interact with your database in:

celest/functions/<filename>

For example, in celest/functions/todo:

Future<List<Todo>> getTodos() async {
  final response = await dio.get("http://localhost:8000/todos");
  final todos = (response.data as List).map((e) => Todo.fromMap(e)).toList();
  return todos;
}

Initialize Celest Client in Flutter

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

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

Call Celest Function in Client Side

Future<List<Todo>> _fetchTodo() async {
  final todoList = celest.functions.todo.getTodos();
  return todoList;
}

Conclusion

This README provides a basic guide to setting up a Todo application with Flutter and Celest, leveraging Dart for a full-stack experience. Happy coding! 🎉