Cannot Write to Collection Using Realm Sync in Flutter

Hi all, what I am trying to do is to read and write from a MongoDB atlas cloud database from my Flutter application. I am trying to use Realm to do so (I was previously using the mongo_dart plugin which was much simpler but this doesn’t work for web apps). To do so, I downloaded and unzipped the Flutter flexible sync demo available here: https://github.com/realm/realm-dart-samples/tree/main/flutter_flexible_sync. After downloading this file, I just replaced my app ID and ran it. After running the app, I realized that I had a defined schema in mongoDB but pressing the buttons at the bottom of the screen did not write anything to the database. The app is successfully reading from the database but it cannot write to it. You’ll realize that I thought this was due to me not subscribing to it so I pasted (now commented out in the code below) some sample code I found on the Flutter realm package website to create a mutable subscription). I added print statements in the _createImportantTasks function to see if it was exiting somewhere in the middle of the function but it seemed to be working just fine and I don’t have errors in my debug console. All I want to do is to be able to read the “linkID” property from a Links Schema I would like to create by querying for it for a user with the specified “username” property (i.e. finding the linkID of user with the email jo@gmail.com). I also want to be able to insert new users into the Link collection (with a name string property, a linkID string property, and an email string property). How can I do this? Here’s the code I was trying out:

import 'dart:convert';
import 'dart:io';
import 'package:flutter/services.dart' show rootBundle;
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
import 'package:realm/realm.dart';
import 'model.dart';

// part 'app.g.dart';

@RealmModel() // define a data model class named `_Car`.
class _Car {
  late String make;

  late String model;

  int? kilometers = 500;
}

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final realmConfig = {
    "config_version": 20210101,
    "app_id": "teescanfire-jumnr",
    "name": "flutter_flexible_sync",
    "location": "DE-FF",
    "deployment_model": "LOCAL"
  };
  String appId = "teescanfire-jumnr";
  // String appId = realmConfig['app_id'];
  MyApp.allTasksRealm = await createRealm(appId, CollectionType.allTasks);
  MyApp.importantTasksRealm =
      await createRealm(appId, CollectionType.importantTasks);
  MyApp.normalTasksRealm = await createRealm(appId, CollectionType.normalTasks);

  runApp(const MyApp());
}

enum CollectionType { allTasks, importantTasks, normalTasks }

Future<Realm> createRealm(String appId, CollectionType collectionType) async {
  final appConfig = AppConfiguration(appId);
  final app = App(appConfig);
  final user = await app.logIn(Credentials.anonymous());

  final flxConfig = Configuration.flexibleSync(user, [Task.schema],
      path: await absolutePath("db_${collectionType.name}.realm"));
  var realm = Realm(flxConfig);
  print("Created local realm db at: ${realm.config.path}");

  final RealmResults<Task> query;

  if (collectionType == CollectionType.allTasks) {
    query = realm.all<Task>();
  } else {
    query = realm.query<Task>(r'isImportant == $0',
        [collectionType == CollectionType.importantTasks]);
  }

  realm.subscriptions.update((mutableSubscriptions) {
    mutableSubscriptions.add(query);
  });

  await realm.subscriptions.waitForSynchronization();
  await realm.syncSession.waitForDownload();
  print("Syncronization completed for realm: ${realm.config.path}");

  return realm;
}

Future<String> absolutePath(String fileName) async {
  final appDocsDirectory = await getApplicationDocumentsDirectory();
  final realmDirectory = '${appDocsDirectory.path}/mongodb-realm';
  if (!Directory(realmDirectory).existsSync()) {
    await Directory(realmDirectory).create(recursive: true);
  }
  return "$realmDirectory/$fileName";
}

class MyApp extends StatelessWidget {
  static late Realm allTasksRealm;
  static late Realm importantTasksRealm;
  static late Realm normalTasksRealm;

  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.green,
      ),
      home: const MyHomePage(title: 'Flutter Realm Flexible Sync'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _allTasksCount = MyApp.allTasksRealm.all<Task>().length;
  int _importantTasksCount = MyApp.importantTasksRealm.all<Task>().length;
  int _normalTasksCount = MyApp.normalTasksRealm.all<Task>().length;

  void _createImportantTasks() async {
    // print("going to try insert method I found on GitHub");
    // MyApp.importantTasksRealm.subscriptions.update((mutableSubscriptions) {
    //   mutableSubscriptions.add(MyApp.importantTasksRealm.query<Task>(
    //       r'isCompleted == $0 AND isImportant == $1', [true, false]));
    // });
    // await MyApp.importantTasksRealm.subscriptions.waitForSynchronization();
    // MyApp.normalTasksRealm.write(() {
    //   MyApp.importantTasksRealm
    //       .add(Task(ObjectId(), "Send an email", true, false));
    // });

    print("Starting to create an important task");
    var importantTasks = MyApp.importantTasksRealm.all<Task>();
    print("Starting to count an important task");
    var allTasksCount = MyApp.allTasksRealm.all<Task>();
    print("Starting to write important task");
    MyApp.allTasksRealm.write(() {
      MyApp.allTasksRealm.add(Task(ObjectId(),
          "Important task ${importantTasks.length + 1}", false, true));
    });
    print("Waiting for upload");
    await MyApp.allTasksRealm.syncSession.waitForUpload();
    print("Waiting for sync");
    await MyApp.importantTasksRealm.subscriptions.waitForSynchronization();
    print("Setting State");
    setState(() {
      _importantTasksCount = importantTasks.length;
      _allTasksCount = allTasksCount.length;
    });
  }

  void _createNormalTasks() async {
    var normalTasks = MyApp.normalTasksRealm.all<Task>();
    var allTasksCount = MyApp.allTasksRealm.all<Task>();
    MyApp.allTasksRealm.write(() {
      MyApp.allTasksRealm.add(Task(
          ObjectId(), "Normal task ${normalTasks.length + 1}", false, false));
    });
    await MyApp.allTasksRealm.syncSession.waitForUpload();
    await MyApp.normalTasksRealm.subscriptions.waitForSynchronization();
    setState(() {
      _normalTasksCount = normalTasks.length;
      _allTasksCount = allTasksCount.length;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              const Text('Important tasks count:',
                  style: TextStyle(fontWeight: FontWeight.bold)),
              Text('$_importantTasksCount',
                  style: Theme.of(context).textTheme.headline4),
              const Text('Normal tasks count:',
                  style: TextStyle(fontWeight: FontWeight.bold)),
              Text('$_normalTasksCount',
                  style: Theme.of(context).textTheme.headline4),
              const Text('All tasks count:',
                  style: TextStyle(fontWeight: FontWeight.bold)),
              Text('$_allTasksCount',
                  style: Theme.of(context).textTheme.headline4),
            ],
          ),
        ),
        floatingActionButton: Stack(
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.only(left: 0.0),
              child: Align(
                  alignment: Alignment.bottomLeft,
                  child: FloatingActionButton(
                    onPressed: _createImportantTasks,
                    tooltip: 'High priority task',
                    child: const Icon(Icons.add),
                  )),
            ),
            Padding(
              padding: const EdgeInsets.only(right: 40.0),
              child: Align(
                  alignment: Alignment.bottomRight,
                  child: FloatingActionButton(
                    onPressed: _createNormalTasks,
                    tooltip: 'Normal task',
                    child: const Icon(Icons.add),
                  )),
            ),
          ],
        ),
        floatingActionButtonLocation: FloatingActionButtonLocation.startFloat);
  }
}

// class _MyHomePageState extends State<MyHomePage> {
//   int _allTasksCount = 0;
//   int _importantTasksCount = 0;
//   int _normalTasksCount = 0;

//   @override
//   void initState() {
//     super.initState();
//     _fetchTaskCounts();
//   }

//   void _fetchTaskCounts() {
//     _allTasksCount = MyApp.allTasksRealm.all<Task>().length;
//     _importantTasksCount = MyApp.importantTasksRealm.all<Task>().length;
//     _normalTasksCount = MyApp.normalTasksRealm.all<Task>().length;
//   }

//   void _createTask(bool isImportant) async {
//     MyApp.allTasksRealm.write(() {
//       MyApp.allTasksRealm.add(
//         Task(ObjectId(), "New task", false, isImportant),
//       );
//     });

//     await MyApp.allTasksRealm.syncSession.waitForUpload();
//     await MyApp.allTasksRealm.subscriptions.waitForSynchronization();

//     setState(() {
//       _fetchTaskCounts();
//     });
//   }

//   void writeObjectToDatabase() async {}
//   @override
//   Widget build(BuildContext context) {
//     return Scaffold(
//       appBar: AppBar(
//         title: Text(widget.title),
//       ),
//       body: Center(
//         child: Column(
//           mainAxisAlignment: MainAxisAlignment.center,
//           children: <Widget>[
//             const Text(
//               'Important tasks count:',
//               style: TextStyle(fontWeight: FontWeight.bold),
//             ),
//             Text(
//               '$_importantTasksCount',
//               style: Theme.of(context).textTheme.headline4,
//             ),
//             const Text(
//               'Normal tasks count:',
//               style: TextStyle(fontWeight: FontWeight.bold),
//             ),
//             Text(
//               '$_normalTasksCount',
//               style: Theme.of(context).textTheme.headline4,
//             ),
//             const Text(
//               'All tasks count:',
//               style: TextStyle(fontWeight: FontWeight.bold),
//             ),
//             Text(
//               '$_allTasksCount',
//               style: Theme.of(context).textTheme.headline4,
//             ),
//           ],
//         ),
//       ),
//       floatingActionButton: FloatingActionButton(
//         onPressed: () => _createTask(true),
//         tooltip: 'Create Task',
//         child: const Icon(Icons.add),
//       ),
//     );
//   }
// }

Here’s how my UI looks (I’d like to press on a button on the screen to write a new object to a specific collection):


Note: I’ve allowed anonymous access to my database, it’s in development mode, and I’ve allowed access from any IP

Hi @Matthew_Gerges,

If you look at the logs tab in the your app services dashboard, you’ll notice that your app is triggering compensating writes due to the writes violating your write permissions, which is why your writes are being reverted. You should double check your app logic to ensure it’s compatible with your rules and tweak it accordingly.

Hi @Matthew_Gerges!
You could skip doing all the configurations by hand. There is a Readme file in this sample that explains how you can upload all the settings using Realm CLI . The settings are in folder assets\atlas_app. It seems you have already configured most of them, but you can compare if something is missing in your App Service. The only thing that you haven’t mentioned are the rules. What are the rules in your App Service? They should be as the one defined in default_rule.json. Do you have write permissions? You can check that in App Services/Rules/Default roles and filters.

If this was the case you should’ve seen information printed in the console similar to
[ERROR] Realm: CompensatingWriteError message: Client attempted a write that is disallowed by permissions, or modifies an object outside the current query, and the server undid the change category: SyncErrorCategory.session code: SyncSessionErrorCode.compensatingWrite.

Please, let me know if the issue is related to your permissions! You can also set Realm.logger.level =RealmLogLevel.debug; and to investigate the details in the log.

Ok thank you! This actually solved one of my problems - I went into the MongoDB atlas UI and under rules changed both read and write to true. Using the template app from the gitHub I linked above, I can read from and write to “tasks” under my todo but I can’t write to userLinks under my test database in my collections. This is the error I get:


I thought this was because I hadn’t configured it in my model.dart so I did configure it in my model.dart file like so:

import 'package:realm/realm.dart';
part 'model.g.dart';

@RealmModel()
class _Task {
  @PrimaryKey()
  @MapTo('_id')
  late ObjectId id;
  late String title;
  late bool isCompleted;
  late bool isImportant;
}

@RealmModel()
class _Links {
  @PrimaryKey()
  @MapTo('_id')
  late ObjectId id;
  late String name;
  late String email;
  late bool linkID;
}

And then I also ran the generate command so it can update my model.g.dart file which looks like so:

// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'model.dart';

// **************************************************************************
// RealmObjectGenerator
// **************************************************************************

class Task extends _Task with RealmEntity, RealmObjectBase, RealmObject {
  Task(
    ObjectId id,
    String title,
    bool isCompleted,
    bool isImportant,
  ) {
    RealmObjectBase.set(this, '_id', id);
    RealmObjectBase.set(this, 'title', title);
    RealmObjectBase.set(this, 'isCompleted', isCompleted);
    RealmObjectBase.set(this, 'isImportant', isImportant);
  }

  Task._();

  @override
  ObjectId get id => RealmObjectBase.get<ObjectId>(this, '_id') as ObjectId;
  @override
  set id(ObjectId value) => RealmObjectBase.set(this, '_id', value);

  @override
  String get title => RealmObjectBase.get<String>(this, 'title') as String;
  @override
  set title(String value) => RealmObjectBase.set(this, 'title', value);

  @override
  bool get isCompleted =>
      RealmObjectBase.get<bool>(this, 'isCompleted') as bool;
  @override
  set isCompleted(bool value) =>
      RealmObjectBase.set(this, 'isCompleted', value);

  @override
  bool get isImportant =>
      RealmObjectBase.get<bool>(this, 'isImportant') as bool;
  @override
  set isImportant(bool value) =>
      RealmObjectBase.set(this, 'isImportant', value);

  @override
  Stream<RealmObjectChanges<Task>> get changes =>
      RealmObjectBase.getChanges<Task>(this);

  @override
  Task freeze() => RealmObjectBase.freezeObject<Task>(this);

  static SchemaObject get schema => _schema ??= _initSchema();
  static SchemaObject? _schema;
  static SchemaObject _initSchema() {
    RealmObjectBase.registerFactory(Task._);
    return const SchemaObject(ObjectType.realmObject, Task, 'Task', [
      SchemaProperty('id', RealmPropertyType.objectid,
          mapTo: '_id', primaryKey: true),
      SchemaProperty('title', RealmPropertyType.string),
      SchemaProperty('isCompleted', RealmPropertyType.bool),
      SchemaProperty('isImportant', RealmPropertyType.bool),
    ]);
  }
}

class Links extends _Links with RealmEntity, RealmObjectBase, RealmObject {
  Links(
    ObjectId id,
    String name,
    String email,
    bool linkID,
  ) {
    RealmObjectBase.set(this, '_id', id);
    RealmObjectBase.set(this, 'name', name);
    RealmObjectBase.set(this, 'email', email);
    RealmObjectBase.set(this, 'linkID', linkID);
  }

  Links._();

  @override
  ObjectId get id => RealmObjectBase.get<ObjectId>(this, '_id') as ObjectId;
  @override
  set id(ObjectId value) => RealmObjectBase.set(this, '_id', value);

  @override
  String get name => RealmObjectBase.get<String>(this, 'name') as String;
  @override
  set name(String value) => RealmObjectBase.set(this, 'name', value);

  @override
  String get email => RealmObjectBase.get<String>(this, 'email') as String;
  @override
  set email(String value) => RealmObjectBase.set(this, 'email', value);

  @override
  bool get linkID => RealmObjectBase.get<bool>(this, 'linkID') as bool;
  @override
  set linkID(bool value) => RealmObjectBase.set(this, 'linkID', value);

  @override
  Stream<RealmObjectChanges<Links>> get changes =>
      RealmObjectBase.getChanges<Links>(this);

  @override
  Links freeze() => RealmObjectBase.freezeObject<Links>(this);

  static SchemaObject get schema => _schema ??= _initSchema();
  static SchemaObject? _schema;
  static SchemaObject _initSchema() {
    RealmObjectBase.registerFactory(Links._);
    return const SchemaObject(ObjectType.realmObject, Links, 'Links', [
      SchemaProperty('id', RealmPropertyType.objectid,
          mapTo: '_id', primaryKey: true),
      SchemaProperty('name', RealmPropertyType.string),
      SchemaProperty('email', RealmPropertyType.string),
      SchemaProperty('linkID', RealmPropertyType.bool),
    ]);
  }
}

But when I did so I was told that Links wasn’t in the schema and I don’t know how to fix this I tried just going into my C:\Users\matth\Documents\Flutter App Development\TeeScanFire_3\teescan_fire\assets\atlas_app\data_sources\mongodb-atlas\flutter_flexible_sync\Task\schema.json and I tried adding a new object called Link to this - but it wouldn’t let me add a comma anywhere without showing a red squiggly:

{
    "bsonType": "object",
    "properties": {
        "_id": {
            "bsonType": "objectId"
        },
        "isCompleted": {
            "bsonType": "bool"
        },
        "isImportant": {
            "bsonType": "bool"
        },
        "title": {
            "bsonType": "string"
        }
    },
    "required": [
        "_id",
        "title",
        "isCompleted",
        "isImportant"
    ],
    "title": "Task"
}

Even when I erased this whole file and saved, my app still ran fine so I don’t think this is the issue. All I want to do is be able to read and write to a Links collection under my test database the properties linkID (string), name (string), and email (string).

This is how my main.dart file looks by the way (I tried copying all the steps the original coder took to set up the process for reading from and writing to the tasks):

import 'dart:convert';
import 'dart:io';
import 'package:flutter/services.dart' show rootBundle;
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
import 'package:realm/realm.dart';
import 'model.dart';

// part 'app.g.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final realmConfig = {
    "config_version": 20210101,
    "app_id": "teescanfire-jumnr",
    "name": "flutter_flexible_sync",
    "location": "DE-FF",
    "deployment_model": "LOCAL"
  };
  String appId = "teescanfire-jumnr";
  // String appId = realmConfig['app_id'];
  MyApp.allTasksRealm = await createRealm(appId, CollectionType.allTasks);
  MyApp.importantTasksRealm =
      await createRealm(appId, CollectionType.importantTasks);
  MyApp.normalTasksRealm = await createRealm(appId, CollectionType.normalTasks);
  MyApp.linksRealm = await createRealm2(appId, CollectionType.normalTasks);

  runApp(const MyApp());
}

enum CollectionType { allTasks, importantTasks, normalTasks }

Future<Realm> createRealm(String appId, CollectionType collectionType) async {
  final appConfig = AppConfiguration(appId);
  final app = App(appConfig);
  final user = await app.logIn(Credentials.anonymous());

  final flxConfig = Configuration.flexibleSync(user, [Task.schema],
      path: await absolutePath("db_${collectionType.name}.realm"));
  var realm = Realm(flxConfig);
  print("Created local realm db at: ${realm.config.path}");

  final RealmResults<Task> query;

  if (collectionType == CollectionType.allTasks) {
    query = realm.all<Task>();
  } else {
    query = realm.query<Task>(r'isImportant == $0',
        [collectionType == CollectionType.importantTasks]);
  }

  realm.subscriptions.update((mutableSubscriptions) {
    mutableSubscriptions.add(query);
  });

  await realm.subscriptions.waitForSynchronization();
  await realm.syncSession.waitForDownload();
  print("Syncronization completed for realm: ${realm.config.path}");

  return realm;
}

Future<Realm> createRealm2(String appId, CollectionType collectionType) async {
  final appConfig = AppConfiguration(appId);
  final app = App(appConfig);
  final user = await app.logIn(Credentials.anonymous());

  final flxConfig = Configuration.flexibleSync(user, [Links.schema],
      path: await absolutePath("db_${collectionType.name}.realm"));
  var realm = Realm(flxConfig);
  print("Created local realm db at: ${realm.config.path}");

  final RealmResults<Links> query;

  // if (collectionType == CollectionType.allTasks) {
  //   query = realm.all<Links>();
  // } else {
  //   query = realm.query<Links>(r'isImportant == $0',
  //       [collectionType == CollectionType.importantTasks]);
  // }
  query = realm.all<Links>();

  realm.subscriptions.update((mutableSubscriptions) {
    mutableSubscriptions.add(query);
  });

  await realm.subscriptions.waitForSynchronization();
  await realm.syncSession.waitForDownload();
  print("Syncronization completed for realm: ${realm.config.path}");

  return realm;
}

Future<String> absolutePath(String fileName) async {
  final appDocsDirectory = await getApplicationDocumentsDirectory();
  final realmDirectory = '${appDocsDirectory.path}/mongodb-realm';
  if (!Directory(realmDirectory).existsSync()) {
    await Directory(realmDirectory).create(recursive: true);
  }
  return "$realmDirectory/$fileName";
}

class MyApp extends StatelessWidget {
  static late Realm allTasksRealm;
  static late Realm importantTasksRealm;
  static late Realm normalTasksRealm;
  static late Realm linksRealm;

  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.green,
      ),
      home: const MyHomePage(title: 'Flutter Realm Flexible Sync'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _allTasksCount = MyApp.allTasksRealm.all<Task>().length;
  int _importantTasksCount = MyApp.importantTasksRealm.all<Task>().length;
  int _normalTasksCount = MyApp.normalTasksRealm.all<Task>().length;
  int _linksCount = MyApp.normalTasksRealm.all<Links>().length;
  // int _linksCount = MyApp.linksRealm.all<Link>().length;
  // int _LinksCount = MyApp.linksRealm.all<Link>().length;

  void _createImportantTasks() async {
    // print("going to try insert method I found on GitHub");
    // MyApp.importantTasksRealm.subscriptions.update((mutableSubscriptions) {
    //   mutableSubscriptions.add(MyApp.importantTasksRealm.query<Task>(
    //       r'isCompleted == $0 AND isImportant == $1', [true, false]));
    // });
    // await MyApp.importantTasksRealm.subscriptions.waitForSynchronization();
    // MyApp.normalTasksRealm.write(() {
    //   MyApp.importantTasksRealm
    //       .add(Task(ObjectId(), "Send an email", true, false));
    // });

    print("Starting to create an important task");
    var importantTasks = MyApp.importantTasksRealm.all<Task>();
    print("Starting to count an important task");
    var allTasksCount = MyApp.allTasksRealm.all<Task>();
    print("Starting to write important task");
    MyApp.allTasksRealm.write(() {
      MyApp.allTasksRealm.add(Task(ObjectId(),
          "Important task ${importantTasks.length + 1}", false, true));
    });
    print("Waiting for upload");
    await MyApp.allTasksRealm.syncSession.waitForUpload();
    print("Waiting for sync");
    await MyApp.importantTasksRealm.subscriptions.waitForSynchronization();
    print("Setting State");
    setState(() {
      _importantTasksCount = importantTasks.length;
      _allTasksCount = allTasksCount.length;
    });
  }

  void _createNormalTasks() async {
    var normalTasks = MyApp.normalTasksRealm.all<Task>();
    var allTasksCount = MyApp.allTasksRealm.all<Task>();
    MyApp.allTasksRealm.write(() {
      MyApp.allTasksRealm.add(Task(
          ObjectId(), "Normal task ${normalTasks.length + 1}", false, false));
    });
    await MyApp.allTasksRealm.syncSession.waitForUpload();
    await MyApp.normalTasksRealm.subscriptions.waitForSynchronization();
    setState(() {
      _normalTasksCount = normalTasks.length;
      _allTasksCount = allTasksCount.length;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              const Text('Important tasks count:',
                  style: TextStyle(fontWeight: FontWeight.bold)),
              Text('$_importantTasksCount',
                  style: Theme.of(context).textTheme.headline4),
              const Text('Normal tasks count:',
                  style: TextStyle(fontWeight: FontWeight.bold)),
              Text('$_normalTasksCount',
                  style: Theme.of(context).textTheme.headline4),
              const Text('All tasks count:',
                  style: TextStyle(fontWeight: FontWeight.bold)),
              Text('$_allTasksCount',
                  style: Theme.of(context).textTheme.headline4),
              Text('$_linksCount',
                  style: Theme.of(context).textTheme.headline4),
            ],
          ),
        ),
        floatingActionButton: Stack(
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.only(left: 0.0),
              child: Align(
                  alignment: Alignment.bottomLeft,
                  child: FloatingActionButton(
                    onPressed: _createImportantTasks,
                    tooltip: 'High priority task',
                    child: const Icon(Icons.add),
                  )),
            ),
            Padding(
              padding: const EdgeInsets.only(right: 40.0),
              child: Align(
                  alignment: Alignment.bottomRight,
                  child: FloatingActionButton(
                    onPressed: _createNormalTasks,
                    tooltip: 'Normal task',
                    child: const Icon(Icons.add),
                  )),
            ),
          ],
        ),
        floatingActionButtonLocation: FloatingActionButtonLocation.startFloat);
  }
}

Also as a side note, I tried doing the realm-cli push inside my assets/atlas_app directory but it told me push failed: failed to find group

Hi @Matthew_Gerges!
It is good to see that your project is moving forward. The next error that you have received is because the new class that you have added Links is not added to the Configuration. You should just update Configuration.flexibleSync in the code like this:

final flxConfig = Configuration.flexibleSync(user, [Task.schema, Links.schema], path.......

Probably, we should consider adding more explanations to this error text.