github.com/hsfzxjy/dgo/go@v0.2.0/dart_future_callback.go (about) 1 package dgo 2 3 type DartFutureCallback DartCallback 4 5 func (dcb DartFutureCallback) specialInt() {} 6 7 func (dcb DartFutureCallback) Complete(val any, err error) bool { 8 if err == nil { 9 return DartCallback(dcb). 10 Flag(CF_POP | CF_WITHCONTEXT | cf_fut_resolve). 11 Call(val) 12 } else { 13 return DartCallback(dcb). 14 Flag(CF_POP | CF_WITHCONTEXT | cf_fut_reject). 15 Call(err.Error()) 16 } 17 } 18 19 func (dcb DartFutureCallback) Resolve(val any) bool { 20 return dcb.Complete(val, nil) 21 } 22 23 func (dcb DartFutureCallback) Reject(err error) bool { 24 if err == nil { 25 panic("dgo:go: expect non-nil value as error") 26 } 27 return dcb.Complete(nil, err) 28 }