download:Flutter advanced practical imitation of Bilibili APP

In recent years, major companies have increasingly higher requirements for THE skills of Flutter, and even set up special positions. However, there are few talents who master the advanced skills of Flutter, and there are few dry courses on the market for Flutter, resulting in a large talent gap. Therefore, we specially designed this course for you to help you become a new generation of engineers in demand.

Dart, Flutter, and cross-platform developers are required

Environment parameters Flutter 2.x Environment parameters 1.Python3.8 2.Selenium3 2. The OjbectId Json serialization can cause a derialization error in MongoDB, which can be handled in one of the following ways

1, the simplest and crude method, a new business primary key such as key, in this case equal to the previous _id does not work

2. Use JsonConverter

public class ObjectIdConverter : JsonConverter

{

public override bool CanConvert(Type objectType)

{

return objectType == typeof(ObjectId);

}

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType ! = JsonToken.String) { throw new Exception( String.Format(“Unexpected token parsing ObjectId. Expected String, got {0}.”, reader.TokenType)); }

var value = (string)reader.Value;
return String.IsNullOrEmpty(value) ? ObjectId.Empty : new ObjectId(value);
Copy the code

}

public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)

{

if (value is ObjectId)

{

var objectId = (ObjectId)value;

writer.WriteValue(objectId ! = ObjectId.Empty ? objectId.ToString() : String.Empty); } else { throw new Exception(" Expected ObjectId value.") ; }Copy the code

Add a line of code to the ObjectId field

[JsonConverter(typeof(ObjectIdConverter))] public string _id { get; set; } If Newtonsoft’s JsonConvert is used, additional parameters are required

JsonConvert.DeserializeObject(json,new ObjectIdConverter());

3. By Ignore, a very tricky way of writing

[JsonIgnore]

public override ObjectId _Id { get; set; }

[BsonIgnore] public string _IdStr { get { return Id.ToString(); } set { ObjectId id; ObjectId.TryParse(value, out id); Id = id; }} # #