random_user 0.3.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 74

random_user Build Status Coverage Status pub package #

Framework to Generate Random Users - An Unofficial Dart/Flutter SDK for https://randomuser.me

random_user is an easy to use Dart framework that provides the ability to generate random users and their accompanying data for your Dart of Flutter applications. It utilizes randomuser.me API to generate the data.

Usage #

Import the framework

import 'package:random_user/random_user.dart';

Create an instance of RandomUser class and use the getUser, getUsers or getUsersWithInfo methods. getUser will return a randomly generated user model. Use getUsers to get a list of random users. Call getUsersWithInfo to get not only a list of users, but additional Info structure which may help with pagination.

To get just a random user use:

  final api = RandomUser();
  final user = await api.getUser();

More complex sample

  final api = RandomUser();
  final users = await api.getUsers(gender: 'female', 
                                   password: 'upper,lower,number,8', 
                                   nationalities: 'NO', 
                                   results: 10);

Will return 10 female user accounts from Norway with alpha-numberical 8-symbol passwords.

License #

random_user is released under an MIT License. See LICENSE for details.

Changelog #

0.3.0 #

  • Reformat code

0.2.0 #

  • Change Dart requitement to >= 2.1.0
  • Remove unneded dependency

0.1.0 #

  • Version bump to not to scary Pub users
  • Add example
  • Code formatting

0.0.1 #

Initial Version of the library.

example/example.dart

import 'package:random_user/random_user.dart';

main() async {
  final api = RandomUser();

  final randomUser = await api.getUser();
  print("Just a random user's email:");
  print(randomUser.email);

  final randomList = await api.getUsers(results: 3);
  print("Three random users:");
  randomList.forEach((u) => print("${u.name.first} ${u.name.last}"));

  final knownUser = await api.getUsersWithInfo(seed: 'flutter');
  print("Always the same user:");
  print(knownUser.results.first.login.username);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  random_user: ^0.3.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:random_user/random_user.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
52
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
74
Learn more about scoring.

We analyzed this package on Mar 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Fix lib/random_user_api.dart. (-0.50 points)

Analysis of lib/random_user_api.dart reported 1 hint:

line 95 col 7: DO use curly braces for all flow control structures.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

exitCode: 255 stdout: parsing /tmp/pub-dartlang-dartdocUQJDJR/pkg/lib/random_user_api.dart... parsing /tmp/pub-dartlang-dartdocUQJDJR/pkg/lib/random_user.dart... parsing /tmp/pub-dartlang-dartdocUQJDJR/pkg/lib/models.dart... parsing /dart-sdk/lib/convert/convert.dart... parsing /dart-sdk/lib/async/async.dart... parsing /dart-sdk/lib/collection/collection.dart... parsing /dart-sdk/lib/internal/internal.dart... parsing /dart-sdk/lib/core/core.dart... parsing /dart-sdk/lib/math/math.dart... parsing /dart-sdk/lib/typed_data/typed_data.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/http-0.12.0+4/lib/http.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/client.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/base_client.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/base_request.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/byte_stream.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/streamed_response.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/base_response.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/utils.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/exception.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/request.dart... [...] parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/async-2.4.1/lib/src/result/future.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/async-2.4.1/lib/src/single_subscription_transformer.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/async-2.4.1/lib/src/stream_group.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/async-2.4.1/lib/src/stream_queue.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/async-2.4.1/lib/src/subscription_stream.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/async-2.4.1/lib/src/stream_splitter.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/async-2.4.1/lib/src/stream_sink_completer.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/async-2.4.1/lib/src/stream_subscription_transformer.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/async-2.4.1/lib/src/stream_zip.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/async-2.4.1/lib/src/typed_stream_transformer.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/mock_client.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/browser_client.dart... parsing /tmp/pub-cache-dirJXEWMR/hosted/pub.dartlang.org/pedantic-1.9.0/lib/pedantic.dart... Initialized dartdoc with 183 libraries in 45.6 seconds documenting random_user Generating docs for library models from package:random_user/models.dart... Generating docs for library random_user from package:random_user/random_user_api.dart... Generating docs for library random_user from package:random_user/random_user.dart... Validating docs... Documented 3 public libraries in 3.1 seconds stderr: Documenting random_user... warning: no canonical library found for models.Coordinates.hashCode, not linking, from models.Coordinates.hashCode: (file:///dart-sdk/lib/core/object.dart:94:20) warning: no canonical library found for models.Coordinates.runtimeType, not linking, from models.Coordinates.runtimeType: (file:///dart-sdk/lib/core/object.dart:116:21) warning: no canonical library found for models.Coordinates.noSuchMethod, not linking, from models.Coordinates.noSuchMethod: (file:///dart-sdk/lib/core/object.dart:111:20) warning: no canonical library found for models.Coordinates.toString, not linking, from models.Coordinates.toString: (file:///dart-sdk/lib/core/object.dart:99:19) warning: no canonical library found for models.Coordinates.==, not linking, from models.Coordinates.==: (file:///dart-sdk/lib/core/object.dart:62:26) warning: random_user has no library level documentation comments, from random_user: (file:///tmp/pub-dartlang-dartdocUQJDJR/pkg/lib/random_user_api.dart:1:9) error: failed to write file at: random_user/random_user-library.html for symbol random_user: (file:///tmp/pub-dartlang-dartdocUQJDJR/pkg/lib/random_user.dart:1:1) conflicting with file already generated by random_user: (file:///tmp/pub-dartlang-dartdocUQJDJR/pkg/lib/random_user_api.dart:1:9) Dartdoc generates a path and filename to write to for each symbol. random_user conflicts with another symbol in the generated path, and therefore can not be written out. Changing the name, library name, or class name (if appropriate) of one of the conflicting items can resolve the conflict. Alternatively, use the @nodoc tag in one symbol's documentation comments to hide it. found 6 warnings and 1 error Unhandled exception: dartdoc encountered 1 errors while processing. #0 Dartdoc.generateDocs (package:dartdoc/dartdoc.dart:202:7)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
http ^0.12.0+1 0.12.0+4
Transitive dependencies
async 2.4.1
charcode 1.1.3
collection 1.14.12
http_parser 3.1.4
meta 1.1.8
path 1.6.4
pedantic 1.9.0
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
test >=0.12.42 <2.0.0
test_coverage ^0.2.0