teta_cms 0.3.5 copy "teta_cms: ^0.3.5" to clipboard
teta_cms: ^0.3.5 copied to clipboard

The Dart client for Teta CMS. Our mission is to help people build amazing products.

example/README.md

Retrieve docs from 2 collections, filtering and sorting by email field and limiting to 10 #

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

Future<void> main() {
  const prjToken = '';
  const prjId = 0;

  await TetaCMS.initialize(
    token: prjToken,
    prjId: prjId,
  );

  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({final Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(final BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body:
            TetaFutureBuilder<TetaResponse<List<dynamic>?, TetaErrorResponse?>>(
          future: TetaCMS.I.db.query(
            '''
              MATCHOR name EQ Collection1 name EQ Collection2;
              IN docs;
              MATCHOR email EQ 'value' email LIKE /value2/;
              SORT email 1;
              LIMIT 10;
            ''',
          ),
          builder: (final c, final snap) {
            if (snap.connectionState == ConnectionState.done) {
              if (snap.data?.error != null) {
                return Text('${snap.data?.error?.message}');
              }
              return ListView.builder(
                itemCount: snap.data?.data?.length ?? 0,
                itemBuilder: (final c, final i) {
                  // ignore: avoid_dynamic_calls
                  return Text('${snap.data?.data?[i]['email']}');
                },
              );
            }
            return const Center(
              child: CircularProgressIndicator(),
            );
          },
        ),
      ),
    );
  }
}

Documents #

Insert

final res = await TetaCMS.I.db.from('contacts').insert(
  <String, dynamic>{'name': 'Giulia', 'city': 'Roma'},
);

Update

final res = await TetaCMS.I.db.fromId(collectionId).row(documentId).update(
  <String, dynamic>{'name': 'Alessia', 'city': 'Milano'},
);

Delete

final res = await TetaCMS.I.db.from('users').row(documentId).delete();

Collections #

Create

final res = await TetaCMS.I.db.create(collectionName);

Update

final res = await TetaCMS.I.db.fromId(collectionId).update(
  newName,
  <String, dynamic>{'key': 'value', 'key': 'value'},
);

Delete

final res = await TetaCMS.I.db.from('posts').delete();

Realtime #

Collection changes

TetaCMS.I.db.from('posts').on(
  // action: StreamAction.all,
  callback: (final e) {},
);

Document changes

TetaCMS.I.db.from('users').row(docId).on(
  callback: (final e) {},
);

Tutorials #

This section will be updated whenever a new tutorial is released

Docs #

See our Flutter docs on teta.so/flutter-docs