Skip to content

Instantly share code, notes, and snippets.

@vferreirati
Last active August 31, 2019 19:39
Show Gist options
  • Save vferreirati/04f61c8e782473ab9a79c1de8e26ded7 to your computer and use it in GitHub Desktop.
Save vferreirati/04f61c8e782473ab9a79c1de8e26ded7 to your computer and use it in GitHub Desktop.
dart live templates
import 'package:chopper/chopper.dart';
part '$FILENAME$.chopper.dart';
@ChopperApi(baseUrl: '')
abstract class $SERVICE_NAME$ extends ChopperService {
static $SERVICE_NAME$ create([ChopperClient client]) => _$$$SERVICE_NAME$(client);
// endpoints
}
{
"New chopper service": {
"prefix": "chopper",
"body": [
"import 'package:chopper/chopper.dart';",
"\npart '$1.chopper.dart';",
"\n@ChopperApi(baseUrl: '')",
"abstract class $2 extends ChopperService {",
"\tstatic $2 create([ChopperClient client]) => _$$2(client);",
"\n\t// Endpoints",
"\t$3",
"}"
],
"description": "Creates a new chopper service"
},
"New Json Serializable Class": {
"prefix": "jclass",
"body": [
"import 'package:json_annotation/json_annotation.dart';",
"\npart '$1.g.dart';",
"\n@JsonSerializable()",
"class $2 {",
"\n\tstatic $2 fromJson(Map<String, dynamic> json) => _$$2FromJson(json);",
"\tMap<String, dynamic> toJson() => _$$2ToJson(this);",
"}"
],
"description": "Creates a new Json Serializable class"
}
}
import 'package:json_annotation/json_annotation.dart';
part '$FILENAME$.g.dart';
@JsonSerializable()
class $CLASSNAME$ {
static $CLASSNAME$ fromJson(Map<String, dynamic> json) => _$$$CLASSNAME$FromJson(json);
Map<String, dynamic> toJson() => _$$$CLASSNAME$ToJson(this);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment