A string generator that helps to implement real-time editing of an ordered sequence.

Related tags

Templates dart flutter
Overview

About

A string generator that helps to implement real-time editing of an ordered sequence.

It makes reordering, sorting, and interleaving transactions faster and simpler.

Usage

  • Get a string between two strings in the lexicographical(lexical or alphabetical) order.

    final mid = between(prev: 'B', next: 'D');
    assert(
      areEqual(
        [mid, 'D', 'B']..sort(),
        ['B', mid, 'D'],
      ),
    );
  • Generate order keys.

    final keyCount = 100; 
    final orderKeys = generateOrderKeys(keyCount);

    This is useful for the following cases:

    1. between cannot be used because the table (collection) is empty.

      Future<void> addTodo(CreateTodo command) async {
        final String orderKey = todos.isEmpty 
          ? generateOrderKeys(1).first // <==
          : between(prev: todos.last.orderKey);
        
        final todo = await todoRepository.create(command, orderKey);
        todos.add(todo);
      }
    2. when migrating to an efficient ordered system.

      Future<void> migrateToLexicalOrderSystem(Table table) async {
        final itemCount = table.count();
        final orderKeys = generateOrderKeys(itemCount);
        /* omitted */
      }

Caution

The between function accepts only allowed characters as arguments

more precisely, the following code is used inside between.

LexOrderValidator().checkBetweenArgs(prev: prev, next: next);

The LexOrderValidator checks the following constraints:

  1. both prev and next must be composed of alphabets.

  2. prev.isNotEmpty && next.isNotEmpty

  3. prev != null && next != null

  4. prev != next

  5. prev[prev.length-1] != 'A' && next[next.length-1] != 'A'

  6. prev.compareTo(next) == -1, for example:

    between(prev: 'C', next: 'B');

In debug mode, you get ArgumentError if you violate the above constraints. but not in release mode. you can check the constraints manually by using LexOrderValidator.

I recommend you to only use between and generateOrderKey for generating keys. because this package is designed for that case only. If you use arguments generated by other sources for the between function, the ordered state of your data may be broken.

You might also like...

Socket library for creating real-time multiplayer games. Based on TCP, with the ability to send messages over UDP (planned).

Game socket The library was published in early access and is not stable, as it is being developed in parallel with other solutions. English is not a n

Aug 10, 2022

The prime objective of this app is to store the real time information of the user using firebase cloud firestore and also can delete, remove and update the customer information

crud_firestore A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started i

Mar 15, 2022

Real-time object detection in Flutter using camera and tflite plugin

Real-time object detection in Flutter using camera and tflite plugin

For details: https://medium.com/@shaqian629/real-time-object-detection-in-flutter-b31c7ff9ef96 flutter_realtime_detection Real-time object detection i

Oct 12, 2022

Bitcoin Ticker App which will fetch you the real time Bitcoin exchange values written in Dart & Flutter

Bitcoin Ticker App which will fetch you the real time Bitcoin exchange values written in Dart & Flutter

About This project is written completely in Dart & Flutter. The app will basically provide you the real time value of three major cryptocurrencies nam

Dec 21, 2021

Access links between your devices in real time!

Access links between your devices in real time!

Lineker Description Lineker allows you to manage links between your desktop and smartphone in real time, saving and deleting at any time. Create filte

Aug 5, 2022

Flutter App - Add Firebase Crud Operation can Create Delete Update Read real time data

Flutter App - Add Firebase Crud Operation can Create Delete Update Read real time data

Firebase-Crud-Operation In This Flutter App I Will Add Firebase Crud Operation like you can Create Delete Update Read real time data. Sample Images Re

Nov 7, 2022

The solution allows anchors to compete with each other and co-anchor with viewers in real time

The solution allows anchors to compete with each other and co-anchor with viewers in real time

The solution allows anchors to compete with each other and co-anchor with viewers in real time, with a global end-to-end latency of below 300 ms on average, and supports 1080p resolution.

Dec 29, 2022

Social app has a real time connection with firebase , contains posts, chats, stories, friends

##SocialKom (Social App) #####First Notice this: you need to link the app with fire base by: 1- adding google-services.json for android 2- adding goog

Oct 8, 2022

Keyviz is a free and open-source tool to visualize your keystrokes ⌨️ in real-time.

Keyviz is a free and open-source tool to visualize your keystrokes ⌨️ in real-time.

Keyviz Keyviz is a free and open-source software to visualize your ⌨️ keystrokes in realtime! Let your audience know what handy shortcuts/keys you're

Jan 2, 2023
A Flutter step_tracker plugin is collect information from user and display progress through a sequence of steps. this plugin also have privilege for fully customization from user side. like flipkart, amazon, myntra, meesho.

step_tracker plugin A Flutter step_tracker plugin is collect information from user and display progress through a sequence of steps. this plugin also

Roshan nahak 5 Oct 21, 2022
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!

SwiftGen SwiftGen is a tool to automatically generate Swift code for resources of your projects (like images, localised strings, etc), to make them ty

null 8.3k Dec 31, 2022
Simple, random string generator for Dart

Simple Random String Simple, random string generator Features Lower characters Upper characters Numbers Customizable special characters Repeatable or

Yasin TUNCEL 1 Dec 19, 2022
Flutter plugin which helps you to find links in String using NSDataDetector and Linkify

Flutter's Native Linkify native_linkify is a Flutter plugin. Use it to find links in plain-text. The plugin uses NSDataDetector for iOS and macOS; Lin

Ilia Beregovskii 3 Nov 29, 2022
Z time ago - A simple Flutter z time ago package used to change date to time ago for english, arabic and kurdish languages

This package is used to get time duration from now and given time for kurdish, a

Zakarya Muhammad 2 May 19, 2022
App-flutter-real-estate - Real Estate App Built With Flutter

Real Estate App - Flutter Preview video: https://youtu.be/11u0KeymAAs My Twitter

Sangvaleap Vanny 136 Dec 7, 2022
A Dart package that helps to implement value based equality without needing to explicitly override == and hashCode.

Simplify Equality Comparisons Overview Being able to compare objects in Dart often involves having to override the == operator as well as hashCode. No

Felix Angelov 747 Jan 8, 2023
A new Flutter package which helps you to implement Ticket Widget in your app.

flutter_ticket_widget A new Flutter package which helps you to implement Ticket Widget in your app. The source code is 100% Dart, and everything resid

Mohak Gupta 112 Dec 22, 2022
Startup-Name-Generator-App-in-Flutter - Business Startup Name Generator App in Flutter

Business Startup Name Generator App #About APP: A simple mobile app that generat

AHSAN SIDDZ 0 Jan 30, 2022