If we are not on the edge with GRPC and Protocol Buffer, then most likely we are going to deal with Restful and JSON. In one of my Flutter apps I needed to consume JSON
/// This allows the`User` class to access private members in /// the generated file. The value for this is *.g.dart, where /// the star denotes the source file name. part'user.g.dart';
/// An annotation for the code generator to know that this class needs the /// JSON serialization logic to be generated. @JsonSerializable()
classUser{ User(this.name, this.email);
String name; String email;
/// A necessary factory constructor for creating a new User instance /// from a map. Pass the map to the generated `_$UserFromJson()` constructor. /// The constructor is named after the source class, in this case User. factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
/// `toJson` is the convention for a class to declare support for serialization /// to JSON. The implementation simply calls the private, generated /// helper method `_$UserToJson`. Map<String, dynamic> toJson() => _$UserToJson(this); }
json_resolve
The problem with manual approach is that it involves lot of boilerplate code, especially when accessing property inside deeply nested json. The problem with code generation approach is that it does not always fit our need and may lack of customization.
Therefore I created json_resolve which allows us to access json using keypath, with type checking and safety in mind. The code is small, simple to reason and tested.
Certain Google Play services (such as Google Sign-in and App Invites) require you to provide the SHA-1 of your signing certificate so we can create an OAuth2 client and API key for your app
console.developers.google.com/apis/credentials
Credentials -> OAuth client id If we specify SHA1 in firebase, then console.developers.google.com will generate an Android oauth for us
buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.release } debug { signingConfig signingConfigs.debug } }