A Parse Server library for Dart developers.
The original one seems not working and abandoned.
These seems work, still needs test and tweak
A simple usage example can be found in the 'example' directory with almost all working functions.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:math';
import 'package:parse_server_dart/parse_server_dart.dart';
import 'const.dart';
void main() => runApp(new MyApp());
var rndSeed = new Random();
String randomWord(){
const wordList = ['now','is','come','time','for','all','good','this','Jack','not'];
return wordList[rndSeed.nextInt(wordList.length-1)];
}
String randomString(int wordCount){
var res = [];
for(int i=0;i<wordCount;i++){
res.add(randomWord());
}
var r = res.join(' ');
var num = rndSeed.nextInt(100);
return "$r $num";
}
void addObject() {
var article = parse.object("Article");
article.set('name',randomString(2));
article.set('keyword',randomString(3));
article.set('desc',randomString(5));
article.set('content',randomString(10));
article.set('author',parse.user());
article.save();
}
Parse parse = new Parse(new Credentials(Const.PARSE_APPID), Const.PARSE_SERVER_URL);
class MyApp extends StatelessWidget{
@override Widget build(BuildContext context){
return new MaterialApp(
title:'Parse Demo',
home: new ParseList()
);
}
}
class ParseList extends StatefulWidget {
@override createState(){
print("loading");
var state = ParseListState();
state.loadObjects();
return state;
}
}
class ParseListState extends State<ParseList>{
List objList = [];
Future<List> getObjects() async{
var q = parse.query("Article");
return q.findObjects();
}
loadObjects(){
getObjects().then((list){
setState((){
objList = list;
});
});
}
signUp(){
var name = randomWord();
var password = 'nopass';
parse.user().signUp({
'username':name,
'password':password
}).then((res){
print("signup done as: $name");
print("res: $res");
});
}
login(){
parse.user().queryAll().then((users){
for (var user in users) {
var name = user['username'];
print("user: $name");
}
parse.user().set('username',users[0]['username']);
parse.user().set('password','nopass');
parse.user().login().then((res){
print("login as first user: $res");
});
});
}
@override Widget build(BuildContext context){
login();
return new Scaffold(
appBar: new AppBar(
title:new Text('Parse Demo App'),
actions: <Widget>[
new IconButton(
icon: new Icon(Icons.add),
tooltip: 'Add Object',
onPressed:()=>addObject()
),
new IconButton(
icon: new Icon(Icons.refresh),
tooltip: 'Reload',
onPressed: ()=>loadObjects(),
),
new IconButton(
icon: new Icon(Icons.verified_user),
tooltip: 'Sign-up new User',
onPressed: ()=>signUp()
)
]
),
body:new Center(child:ListView.builder(
padding: new EdgeInsets.all(8.0),
itemExtent: 40.0,
itemBuilder: (BuildContext context, int index){
var val = objList[index]['name'];
var id = index+1;
return new Text("$id:$val");
},
itemCount: objList.length
))
);
}
}
Add this to your package's pubspec.yaml file:
dependencies:
parse_server_dart: ^0.0.5
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.
Now in your Dart code, you can use:
import 'package:parse_server_dart/parse_server_dart.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
0.0.5 | Oct 11, 2018 |
|
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
31
|
Health:
Code health derived from static analysis.
[more]
|
82
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
70
|
Overall:
Weighted score of the above.
[more]
|
54
|
We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
Document public APIs. (-0.72 points)
106 out of 107 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.
Fix lib/src/parse_object.dart
. (-6.31 points)
Analysis of lib/src/parse_object.dart
reported 13 hints, including:
line 15 col 15: Don't type annotate initializing formals.
line 15 col 39: Don't type annotate initializing formals.
line 16 col 22: Avoid using braces in interpolation when not needed.
line 36 col 57: Avoid using braces in interpolation when not needed.
line 45 col 58: Avoid using braces in interpolation when not needed.
Fix lib/src/parse_base.dart
. (-2.48 points)
Analysis of lib/src/parse_base.dart
reported 5 hints:
line 16 col 8: The method '_handleResponse' isn't used.
line 18 col 19: Don't type annotate initializing formals.
line 18 col 43: Don't type annotate initializing formals.
line 36 col 15: The value of the field '_parseObject' isn't used.
line 38 col 13: The value of the field '_liveQuery' isn't used.
Fix lib/src/parse_user.dart
. (-1.99 points)
Analysis of lib/src/parse_user.dart
reported 4 hints:
line 39 col 63: Avoid using braces in interpolation when not needed.
line 149 col 65: Avoid using braces in interpolation when not needed.
line 158 col 59: Avoid using braces in interpolation when not needed.
line 158 col 67: Avoid using braces in interpolation when not needed.
Fix additional 7 files with analysis or formatting issues. (-7.47 points)
Additional issues in the following files:
lib/src/queries/parse_query.dart
(4 hints)lib/src/queries/parse_query_controller.dart
(3 hints)lib/src/queries/parse_query_state.dart
(3 hints)lib/src/parse_http_client.dart
(2 hints)lib/src/parse_livequery.dart
(2 hints)lib/src/credentials.dart
(1 hint)lib/src/queries/parse_query_constants.dart
(Run flutter format
to format lib/src/queries/parse_query_constants.dart
.)The package description is too short. (-20 points)
Add more detail to the description
field of pubspec.yaml
. Use 60 to 180 characters to describe the package, what it does, and its target use case.
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.
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.0.0-dev.68.0 <3.0.0 | ||
flutter | 0.0.0 | ||
http | ^0.11.3 | 0.11.3+17 | 0.12.0+1 |
json_annotation | ^1.2.0 | 1.2.0 | 2.0.0 |
path | ^1.4.1 | 1.6.2 | |
web_socket_channel | ^1.0.6 | 1.0.9 | |
Transitive dependencies | |||
async | 2.0.8 | ||
charcode | 1.1.2 | ||
collection | 1.14.11 | ||
convert | 2.1.1 | ||
crypto | 2.0.6 | ||
http_parser | 3.1.3 | ||
meta | 1.1.6 | 1.1.7 | |
sky_engine | 0.0.99 | ||
source_span | 1.5.4 | ||
stream_channel | 1.6.8 | ||
string_scanner | 1.0.4 | ||
term_glyph | 1.1.0 | ||
typed_data | 1.1.6 | ||
vector_math | 2.0.8 |