leancloud_flutter_plugin 0.0.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 66

LeanCloud flutter plugin #

Bless Package version

Leancloud flutter plugin by Luna Gao

Dark packages

Description #

This plugin depends on Leancloud Native(iOS / Android) SDK. It's just convert the code from dart to those native language(Objective-C / Java).

Getting Started #

Install #

  • Add this to your package's pubspec.yaml file:
dependencies:
  leancloud_flutter_plugin: ^0.0.2
  • Install packages from the command line:
flutter packages get
  • Import it
import 'package:leancloud_flutter_plugin/leancloud_flutter_plugin.dart';

How to use #

Before your runApp function, initialize the leancloud. Such as the example app does.

Steps:

  • initialize plugin
  • setup log level (Optional, default value is OFF)
  • setup region (Optional, default value is NorthChina)
  • initialize leancloud
  • save object or you can do whet ever you want :)

Initialize plugin #

Plugin is Singleton mode. Please NOT initialize it by yourself.

Import: import 'package:leancloud_flutter_plugin/leancloud_flutter_plugin.dart';

LeancloudFlutterPlugin leancloudFlutterPlugin = LeancloudFlutterPlugin.getInstance();

Log Level (Optional)

Setup log level must be earlier than initialize leancloud function.

leancloudFlutterPlugin.setLogLevel(LeancloudLoggerLevel.DEBUG);

Region (Optional)

Setup region must be earlier than initialize leancloud function.

leancloudFlutterPlugin.setRegion(LeancloudCloudRegion.NorthChina);

Initialize Leancloud #

leancloudFlutterPlugin.initialize(appId, appKey);

Create and update an Object #

Import: import 'package:leancloud_flutter_plugin/leancloud_object.dart';

// Create
AVObject object = new AVObject("YOUR_OBJECT");
object.put("FIELD_NAME", "VALUE"); // String
object.put("OR_INT", 10); // int
object.put("OR_BOOLEAN", true); // boolean
object.put("OR_FLOAT", 10.01); // float
object.save().then((object) {
  // Saved
  print(object);
  
  // and Update
  object.put("description", "updated!");
  object.save().then((object) {
    // Updated
    print(object);
  });
});

If your update your object, {"code":403,"error":"Forbidden writing by object's ACL."} happened, then please check leancloud data's ACL field.

Delete an Object #

// object is an AVObject
object.delete().then((isDeleted) {
  // Deleted
  if (isDeleted) {
    object = null; // you should set ref to null manually if you don't using this object
    print("Deleted!");
  }
});

Query an Object #

Import: import 'package:leancloud_flutter_plugin/leancloud_query.dart';

// query by object_id
AVQuery avQuery = new AVQuery("DemoObject");
avQuery.get("OBJECT_ID").then((object) {
  print("Queryed!");
});

// query objects
AVQuery avQuery = new AVQuery("DemoObject");
avQuery.whereEqualTo("KEY", "VALUE"); // string value
avQuery.whereNotEqualTo("KEY", 10); // int value
avQuery.whereGreaterThan("KEY", true); // bool value
avQuery.whereGreaterThanOrEqualTo("KEY", "VALUE");
avQuery.whereLessThan("KEY", "VALUE");
avQuery.whereLessThanOrEqualTo("KEY", "VALUE");
avQuery.find().then((objects) {
  print("All Objects Queryed!");
});

Example App #

Example App README.md

0.0.3 #

  • add query function
    • orderByAscending
    • orderByDescending
    • addAscendingOrder
    • addDescendingOrder
    • limit
    • skip
  • Fixed query object by objectId on Android

0.0.2 #

  • fixed android package error.

0.0.1 #

  • Init leancloud plugin
  • Setup Log Level
  • Setup Region
  • Create object
  • Update object
  • Query object by objectId(iOS only)
  • Query objects

example/README.md

Example App for LeanCloud flutter plugin #

Getting Started #

Setup Leancloud Data #

  • Create an Class named DemoObject
  • Set ACL to unlimited (无限制). (This is important because if the Class is limited, we can't update or delete any object. It's not a bug, it's leancloud design for security.)

Setup AppID and AppKey #

"Oh, I don't have an appId or an appKey." Please click here

  • open example/lib/main.dart file.
  • replace YOUR_APP_ID to your appId.
  • replace YOUR_APP_KEY to your appKey.

Android #

According Flutter document

  • Run flutter build command
cd example
flutter build apk
  • Launch Android Studio.
  • Select Import project in Welcome to Android Studio dialog, or select File > New > Import Project… in the menu, and select the example/android/build.gradle file.
  • In the Gradle Sync dialog, select OK.
  • In the Android Gradle Plugin Update dialog, select Don’t remind me again for this project.
  • Run this example app from Android Studio by pressing the ▶ button.

iOS #

According Flutter document

  • Run flutter build command.
cd example
flutter build ios --no-codesign
  • Launch Xcode.
  • Select File > Open, and select the example/ios/Runner.xcworkspace file.
  • Run this example app by pressing the ▶ button.

Use this package as a library

1. Depend on it

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


dependencies:
  leancloud_flutter_plugin: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:leancloud_flutter_plugin/leancloud_flutter_plugin.dart';
  
Version Uploaded Documentation Archive
0.0.3 Jan 11, 2019 Go to the documentation of leancloud_flutter_plugin 0.0.3 Download leancloud_flutter_plugin 0.0.3 archive
0.0.2 Jan 7, 2019 Go to the documentation of leancloud_flutter_plugin 0.0.2 Download leancloud_flutter_plugin 0.0.2 archive
0.0.1 Jan 7, 2019 Go to the documentation of leancloud_flutter_plugin 0.0.1 Download leancloud_flutter_plugin 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
38
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
66
Learn more about scoring.

We analyzed this package on Apr 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14
  • Flutter: 1.4.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/leancloud_query.dart. (-1.49 points)

Analysis of lib/leancloud_query.dart reported 3 hints:

line 14 col 10: The class 'Future' was not exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 40 col 3: The class 'Future' was not exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 50 col 3: The class 'Future' was not exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

Fix lib/leancloud_object.dart. (-1 points)

Analysis of lib/leancloud_object.dart reported 2 hints:

line 54 col 3: The class 'Future' was not exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 63 col 3: The class 'Future' was not exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

Fix lib/leancloud_user.dart. (-1 points)

Analysis of lib/leancloud_user.dart reported 2 hints:

line 1 col 8: Unused import: 'package:leancloud_flutter_plugin/leancloud_flutter_plugin.dart'.

line 6 col 7: The value of the field '_userName' isn't used.

Format lib/leancloud_flutter_plugin.dart.

Run flutter format to format lib/leancloud_flutter_plugin.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8