How to Build a Full-Stack Dart App with Firebase Functions and GenUI

By

Introduction

At Google Cloud Next 2026, the Flutter and Dart team unveiled a game-changing preview: Dart support for Firebase Functions, plus deeper integrations with the Dart Admin SDK. These tools let you use the same language for both your frontend and backend, reducing context switching and accelerating development. This step-by-step guide will walk you through building a full-stack Dart application—from setting up your environment to deploying a GenUI-powered interface. Whether you're creating a custom latte art app like the GenLatte demo or an enterprise dashboard, these steps will get you from zero to deployed.

How to Build a Full-Stack Dart App with Firebase Functions and GenUI

What You Need

Step-by-Step Guide

Step 1: Set Up Your Flutter Project and Firebase Backend

Start by creating a new Flutter project from the terminal:

flutter create my_fullstack_app
cd my_fullstack_app

Next, install the Firebase Flutter plugins for authentication, firestore, and functions. Add these dependencies to your pubspec.yaml:

dependencies:
  firebase_core: ^2.15.0
  firebase_auth: ^4.7.0
  cloud_firestore: ^4.8.0
  cloud_functions: ^4.0.0

Run flutter pub get to install them.

Step 2: Initialize Firebase in Your Project

Log in to the Firebase CLI and initialize Firebase services:

firebase login
firebase init functions

When prompted, select Dart as the language for Functions (this is the preview feature announced at Google Cloud Next). The CLI will create a functions directory with a pubspec.yaml and a main.dart file for your backend code.

Link your Firebase project by selecting an existing project or creating a new one. Also initialize Firestore if you need a database.

Step 3: Write Your First Dart Firebase Function

Open functions/main.dart and replace its content with a simple HTTP function that returns a dynamic UI payload:

import 'dart:convert';
import 'package:firebase_functions/firebase_functions.dart';
import 'package:googleapis/firestore/v1.dart' as admin;

Future generateLatteArt(request) async {
  final data = request.data as Map;
  final flavor = data['flavor'] ?? 'vanilla';
  // Use the Dart Admin SDK to store order
  final firestore = admin.FirestoreApi(admin.FirestoreApi.ensureInitialized());
  await firestore.documents.create(
    'orders',
    admin.Document(data: {'flavor': flavor, 'timestamp': DateTime.now().toIso8601String()}),
  );
  // Return a GenUI schema (simplified example)
  return Response.json({
    'ui': {
      'type': 'column',
      'children': [
        {'type': 'text', 'value': 'Your $flavor latte is being prepared!'},
        {'type': 'image', 'url': 'https://example.com/latte_art.png'}
      ]
    }
  });
}

This function uses the Dart Admin SDK to write to Firestore and returns a JSON object that your Flutter GenUI client can render as dynamic UI.

Step 4: Connect Your Flutter Frontend to the Function

Back in your Flutter project, create a service class to call the cloud function:

import 'package:cloud_functions/cloud_functions.dart';
import 'package:flutter_gen_ui/flutter_gen_ui.dart'; // hypothetical package

class LatteService {
  final HttpsCallable callable = FirebaseFunctions.instance.httpsCallable('generateLatteArt');

  Future orderLatte(String flavor) async {
    final result = await callable.call({'flavor': flavor});
    final uiJson = result.data['ui'];
    // Pass uiJson to GenUI renderer in your widget
    GenUI.render(uiJson);
  }
}

Use this service in your UI—for example, when a user taps an order button, call LatteService().orderLatte('hazelnut'). The GenUI engine will convert the returned JSON into Flutter widgets on the fly, just like the GenLatte demo at the conference.

Step 5: Deploy and Test Locally

Before deploying to production, test locally with the Firebase Emulator Suite:

firebase emulators:start --only functions,firestore

Run your Flutter app on an emulator or device using flutter run. Point your app to the local emulator by setting FirebaseFunctions.instance.useFunctionsEmulator(origin: 'http://localhost:5001'). Verify that ordering a latte triggers the function, writes to Firestore, and returns a dynamic UI.

Once satisfied, deploy:

firebase deploy --only functions

Step 6: Add Advanced GenUI Features (Optional)

Inspired by the Partiful app demoed at Google Cloud Next, you can generate entire screens from your backend. Extend your function to return nested widgets, charts, or even entire page layouts. For example, return a UI schema that includes a listview with items fetched from Firestore. The Dart Admin SDK makes it easy to query data and transform it into UI definitions.

Tips

Tags:

Related Articles

Recommended

Discover More

7 Amiability Lessons from the Vienna Circle for a More Welcoming WebSecuring VMware vSphere Against BRICKSTORM: A Comprehensive Defense GuideUltra-Thin Smartphone Market Craters: iPhone Air Flop Triggers Industry-Wide Retreat, But Apple Plots ComebackMicrosoft Foundry Unleashes OpenAI's GPT-5.5: Enterprise AI Takes a Leap in Precision and AutonomyBeyond Vibe Coding: How Spec-Driven Development Ensures Code Quality