Skip to content

Afrographic/AnkhAPIMocker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Download the package

click on this link https://drive.google.com/file/d/14KA7jyAjBrTp85pwVvJzsKgwDtRjL7-N/view?usp=sharing to download the package it is a single file that you copy and paste in our project, it has No dependency, No YAML required, lightweight, works on all versions of dart

Getting started

To start using the package your must first create a string representation of your model fields inside your class definition just like this, make it static. we are using the model User for our example

Just copy paste it from your model definition to avoid spelling mistakes

class User{

    // Normal class fields and methods goes here
    
    static String AnkhMockerInit = """
        int idUser;
        String avatar;
        String coverImage;
        String fullName;
        String startDate;
        String descriptionlen45;
        bool isOnline;
    """;
}

AnkhMocker is Flexible

it has no dependency , it is lightweight (single file) and it works on all versions of dart.

Features

  • Generate Mock data from your model fields definition
  • Generate random text from specified length just like lorem ipsum engine
  • Generate random image links (avatars,images)
  • Generate random date in string format
  • Generate random integer in string format

Usage

After that you can generate a single object like this

 dynamic userJSON = await AnkhMocker.generateData(
      fieldSchema: User.AnkhMockerInit);

AnkhMocker have two Additional parameters

1 . delaiInSec

Which determine the amount of time (in seconds) to wait before the data is generated. defaults to 1

 dynamic userJSON =
      await AnkhMocker.generateData(fieldSchema: User.AnkhMockerInit,delayInSec: 5);

2 . count

This parameter helps you to generate a collection of objects (An array of JSON objects), its value represent the number of objects you want to generate

 dynamic usersArray =
      await AnkhMocker.generateData(fieldSchema: User.AnkhMockerInit,delayInSec: 5,count: 15);

Additional Features

How to generate a random avatar image ?

Just make sure the name of the field contains the string avatar

  String userAvatar;

How to generate a random image ?

Just make sure the name of the field contains the string image

  String coverImage;

How to generate a random date ?

Just make sure the name of the field contains the string date

  String createdDate;

How to generate a random text ?

Just make sure the name of the field contains the string len45 , the number 45 here represent the length that you want your text to have, you can replace it with any length

  String userDescriptionlen45;

Generate without a model

You also have the ability to generate random data without the need to define a model

  • Generate a random text , in the example 45 represent the length of the text , you can define any length
    String myText = AnkhMocker.generateText(45);
  • Generate random Date
      // single 
    String myDate = AnkhMocker.generateDate(); // output : 18 jan 2022
    // Multiple
    List<String> myAvatarURLs = AnkhMocker.generateDateList(10);
  • Generate random avatarURL
    // single 
    String myAvatarURL = AnkhMocker.generateAvatarURL();
    // Multiple
    List<String> myAvatarURLs = AnkhMocker.generateAvatarURLList(10);
  • Generate random imageURL
    // Single 
    String imageURL = AnkhMocker.generateRandomImageURL();
    //Mulitple
    List<String> imageURLs = AnkhMocker.generateImageURLList(10);

Let's connect on twitter

this is my profile https://twitter.com/neferou_/status/1679088623054929920?s=46&t=LBm7BbTCqcHgoPTZM5SYgQ

Become our sponsor

If you found the package useful, you can support either in Crypto 😏 (BTC or ETH), here are my wallets adresses

Bitcoin

bc1q8n7z8uyz84p9gv00ytvc2w3k3jhlyz6j85drwh

Ethereum

0x8D0E3Bb7EB460E518A5D1203eb71b86097f04bda

Tether (BEP20)

0x8D0E3Bb7EB460E518A5D1203eb71b86097f04bda

Tether (ERC20)

0x8D0E3Bb7EB460E518A5D1203eb71b86097f04bda

BNB

0x8D0E3Bb7EB460E518A5D1203eb71b86097f04bda

Or with electronic Cash , below are my coordinates

Orange Money - Cameroon - name : Tesse brunel

697830071

MTN mobile money - Cameroon - name : Hamadjoda

678724995

Tap Tap Send - Cameroon

678724995

About

This is a tool to simulate an API response in JSON format by using the class properties definition

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages