ncmb 0.1.7

Flutter Android iOS

Dart and Flutter library for Nifcloud mobile backend(NCMB). Nifcloud mobile backend is a web service of mBaaS.

NCMB for Dart w/ Flutter #

Dart and Flutter library for Nifcloud mobile backend(NCMB).

Usage #

Init #

import 'package:ncmb/ncmb.dart';
NCMB ncmb = new NCMB('YOUR_APPLICATION_KEY', 'YOUR_CLIENT_KEY');

DataStore #

Create data

NCMBObject item = ncmb.Object('Item')
  ..set('msg', 'Hello World')
  ..set('array', ['a', 'b'])
  ..set('int', 1)
  ..set('name', 'Atsushi');
await item.save();
debugPrint(item.get('objectId'));

Update data

await item.set('name', 'goofmint');
await item.save();

Delete data

await item.destroy();

Retribe data

NCMBQuery query = ncmb.Query('Item');

// All data
var items = await query.fetchAll();
print(items[0].get('msg'));

// First data
var item2 = await query.fetch();
print(item2.get('msg'));

// Query (Equal)
query.equalTo('objectId', item.get('objectId'));
var item3 = await query.fetch();
print(item3.get('objectId'));

query.clear();
query
  ..notEqualTo('array', ['a', 'b', 'c'])
  ..limit(2)
  ..lessThan('int', 4);
items = await query.fetchAll();
print(items.length);

ACL

var acl = NCMBAcl();
acl
  ..setPublicReadAccess(true)
  ..setPublicWriteAccess(false)
  ..setRoleWriteAccess('Admin', true)
  ..setUserWriteAccess('aaaaa', true);
item3.set('acl', acl);

Special type

items[0]
  // Class of Datastore
  ..set('item', items[1])
  // DateTime
  ..set('time', DateTime.now())
  // Geo location
  ..set('geo', NCMBGeoPoint(35.658611, 139.745556));

User #

Register

var userName = 'aaa';
var password = 'bbb';
var user = await ncmb.User.signUpByAccount(userName, password);

Login

user = await ncmb.User.login(userName, password);

Anonymous Login

user = await ncmb.User.loginAsAnonymous();

Check session stats

var user = await ncmb.User.CurrentUser();
if (user != null && (await user.enableSession())) {
  print('Login');
} else {
  print('no login');
  await user.logout();
}

Logout

user.logout();

File #

Upload

Upload binary file

var fileName = 'dart.png';
var blob = await File(fileName).readAsBytes();
var file = await ncmb.File.upload(fileName, blob);

Upload text data as text file.

test("Upload text file", () async {
var fileName = 'dart.txt';
var file = await ncmb.File.upload(fileName, 'Hello world');

Custom mime type.

var fileName = 'dart.csv';
var file = await ncmb.File.upload(fileName, 'a,b,c', mimeType: 'text/csv');

Download

var file = await ncmb.File.download('dart.png');

LICENSE #

MIT.

1
likes
60
pub points
38%
popularity

Dart and Flutter library for Nifcloud mobile backend(NCMB). Nifcloud mobile backend is a web service of mBaaS.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

admin@moongift.jp

License

MIT (LICENSE)

Dependencies

crypto, dio, http_parser, intl, mime, notification_reactor, package_info, plain_notification_token, shared_preferences, uuid

More

Packages that depend on ncmb