搜索插件、代码仓与 APP 分类

插件详情v0.2.3

faker_dart

在 Dart 和 Flutter 中生成大量虚假数据!著名的 faker.js 的 Dart 版本

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1.1万
喜欢数
96
Pub 分数
160

安装插件

flutter pub add faker_dart

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Faker Dart 是流行的 faker.js 库的 Dart 版本,使开发者能够在 Flutter 和 Dart 应用程序中生成大量逼真的虚假数据,用于测试和开发。它支持多种数据类型,包括姓名、地址、电子邮件、电话号码、Lorem Ipsum 文本等。设计简洁易用,可无缝集成到跨多个平台的测试工作流中。该包非常适合填充模拟数据库、创建示例 UI 或在不依赖真实数据的情况下模拟用户输入。

适合场景

  • 填充测试数据库
  • 生成模拟UI数据
  • 创建示例用户资料
  • 模拟 API 响应
  • 测试表单验证
  • 使用虚拟内容进行压力测试

主要特点

  • 支持多种数据类型
  • 跨平台兼容性
  • 简单、直观的 API
  • 轻量且快速
  • 可扩展的数据生成
  • 内置区域设置支持

适合对象

  • 测试人员和质量保证工程师
  • Flutter 开发者
  • 后端开发人员
  • UI/UX 设计师
  • 原型开发团队
  • 数据模拟项目

使用建议

  • 不适合用于生产数据
  • 生成的数据并非真实
  • 可能需要本地化配置
  • 有限的自定义选项
  • 无内置数据持久化
  • 依赖外部 GitHub 仓库

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Pub Version Likes Pub points Pub Pub codecov

generate massive amounts of fake data in Dart & Flutter

Faker.dart is a dart port of the famous faker.js package for the web and NodeJS

:hammer: Usage

faker.dart is split up into modules, where every module has a bunch of faker methods.

Basics
    final faker = Faker.instance;

    String randomName = faker.name.fullName(); // Rowan Nikolaus
    String randomHex = faker.datatype.hexaDecimal(); // 0xF74451AB
Faker.fake()

faker.dart contains a super useful generator method Faker.fake for combining faker API methods using a mustache string format.

Example:

print(faker.fake("{{name.lastName}}, {{name.firstName}} {{name.suffix}}"));
// outputs: "Marks, Dean Sr."

This will interpolate the format string with the value of methods name.lastName(), name.firstName(), and name.suffix()

supported faker methods
Module Methods
datatype number, float, datetime, string, uuid, boolean, hexaDecimal, json, list
name fullName, firstName, lastName, middleName, findName, jobTitle, gender, prefix, suffix, title, jobDescriptor, jobArea, jobType
image image, loremPicsum, lorempixel
address zipCode, city, cityPrefix, citySuffix, cityName, streetName, streetSuffix, streetPrefix, streetAddress, secondaryAddress, county, country, countryCode, state, stateAbbr, latitude, longitude, direction, cardinalDirection, ordinalDirection, nearbyGPSCoordinate, timezone
animal type, animal, dog, cat, snake, bear, lion, catecean, horse, bird, cow, fish, corocodilia, insect, rabbit
commerce color, department, productName, price, productAdjective, productMaterial, product, productDescription
company companyName, companySuffix, catchPhrase, bs, catchPhraseAdjective, catchPhraseDescriptor, catchPhraseNoun, bsAdjective, bsBuzz, bsNoun
database column, type, collation, engine
music genre
hacker abbreviation, adjective, noun, verb, ingverb, phrase
git branch, commitEntry, commitMessage, commitSha, shortSha
date past, future, between, month, weekday
phoneNumber phoneNumber, phoneFormat
lorem word, sentence, paragraph, text
internet url, domainName, domainSuffix, httpMethod, ip, email

:speech_balloon: Localization

faker.dart currently supports 54 Locales!!!

The default language locale is set to English. if your chosen locale doesn't support specific faker data, it will fall back to the English locale.

// sets locale to german
faker.setLocale(FakerLocaleType.de);
// set the locale to your custom Locale:
final FakerLocale locale = FakerLocale(...);
faker.setCustomLocale(locale);
currently internally supported locales:
  • az
  • ar
  • cz
  • de
  • de_AT
  • de_CH
  • en
  • en_AU
  • en_AU_ocker
  • en_BORK
  • en_CA
  • en_GB
  • en_IE
  • en_IND
  • en_US
  • en_ZA
  • es
  • es_MX
  • fa
  • fi
  • fr
  • fr_CA
  • fr_CH
  • ge
  • hy
  • hr
  • id_ID
  • it
  • ja
  • ko
  • nb_NO
  • ne
  • nl
  • nl_BE
  • pl
  • pt_BR
  • pt_PT
  • ro
  • ru
  • sk
  • sv
  • tr
  • uk
  • vi
  • zh_CN
  • zh_TW

:grey_question: what's up next

this package is still in active development. modules are still being added:

  • finance
  • system
  • vehicle
  • word

:wave: Get Involved

If this package is useful to you please :thumbsup: on pub.dev and :star: on Github. If you have any Issues, recommendations or pull requests I'd love to see them!

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目