dartvel_dev 0.9.2 copy "dartvel_dev: ^0.9.2" to clipboard
dartvel_dev: ^0.9.2 copied to clipboard

Dartvel: a batteries-included, AI-native full-stack application platform built around Flutter. Pages, models, backend functions, UI and business logic; everything else is generated, compiled or served.

example/README.md

A Flutter application on the umbrella package #

dartvel create starts a project on the individual Dartvel packages. This example shows the other layout: one dartvel_dev constraint that moves every Dartvel package together. It was checked against 0.6.0 by generating the client, analyzing the application, and analyzing the generated server.

For a full walk from an empty directory to a web build, see the dartvel_cli example.

pubspec.yaml #

name: notes_app
publish_to: none
version: 0.0.1

environment:
  sdk: ">=3.13.0 <4.0.0"

dependencies:
  flutter:
    sdk: flutter
  dartvel_dev: ^0.9.0
  # The umbrella decides these versions. Declaring them is for the
  # depend_on_referenced_packages lint, since models and backend functions
  # import package:dartvel_core by name.
  dartvel_core: any
  dartvel_flutter: any

dev_dependencies:
  dartvel_cli: ^0.9.0   # for `dart run dartvel_cli:dartvel`
  lints: ^4.0.0

flutter:
  uses-material-design: true

dartvel:
  pagesDir: lib/pages
  backendDir: lib/backend

A data model #

// lib/models/note.dart
import 'package:dartvel_core/dartvel.dart';

@DVModel()
@pragma('vm:entry-point')
class const _Note({required final String id, required final String name});

The class is private because it is the generator's input. The application uses the generated Note.

A backend function #

// lib/backend/functions/health.get.dart   ->  GET /api/health
import 'package:dartvel_core/dartvel.dart';

@DVBackendFunction()
Map<String, Object?> _health() => <String, Object?>{
      'status': 'ok',
      'timestamp': DateTime.now().toIso8601String(),
    };

Import dartvel_core here rather than the umbrella. The generated server is pure Dart and drops any import that reaches Flutter, which package:dartvel_dev does.

A page #

// lib/pages/index.dart   ->  /
import 'package:flutter/material.dart';
import '../dartvel_client/dartvel_client.dart';

@DVPage(title: 'Notes', showAppBar: true)
@pragma('vm:entry-point')
Widget _indexPage(BuildContext context) => DVBox.list([
      Note.Form(),
    ]).modifier(const DVModifier().padding(24));

Pages import the generated barrel, which re-exports the framework with the application's own routes, models and client.

Generate and run #

With the CLI installed:

flutter pub get
dartvel routes      # writes lib/dartvel_client/
dartvel dev

Or through the project's own dev dependency, with no binary installed:

dart run dartvel_cli:dartvel routes
dart run dartvel_cli:dartvel dev

lib/main.dart is the one dartvel create writes; it calls the generated createDartvelRouter():

import 'package:flutter/material.dart';
import 'dartvel_client/dartvel_client.dart';

void main(List<String> arguments) async {
  await negotiateDartvelLaunch(arguments);
  runApp(MaterialApp.router(
    routerConfig: createDartvelRouter(arguments: arguments),
  ));
}
1
likes
140
points
452
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Dartvel: a batteries-included, AI-native full-stack application platform built around Flutter. Pages, models, backend functions, UI and business logic; everything else is generated, compiled or served.

Homepage
Repository (GitHub)
View/report issues
Contributing

License

MIT (license)

Dependencies

dartvel_cli, dartvel_core, dartvel_flutter, dartvel_shelf, flutter

More

Packages that depend on dartvel_dev