UserDoc class

Get user data synchroneously.

사용자 필드(또는 전체) 값을 가져온다. 기본적으로 실시간 업데이트를 하지 않지만, UserDoc.sync 를 사용하면, DB 가 업데이트되면 실시간으로 업데이트된 값을 가져와 위젯을 업데이트한다.

주의, field 가 null 이면, "users/uid" 통째를 가져오고, field 가 'abc/def' 이면, "users/uid/abc/def" 의 값을 가져온다. 참고, 사용자 정보를 전달 할 때, 사용자 데이터를 통째로 읽어 전달 할 필요 없이, 필요한 데이터 필드만 바로 바로 쓰면 된다.

cacheId 에 캐시 ID 값을 주면, 메모리 캐시를 사용한다. 즉, 같은 uid 와 field 에 대한 데이터는 한번만 읽어온다. 캐시는 sync 를 할 때에는 무시된다. 즉, sync 을 안할 때에만 cache 를 사용한다.

field 는 하나의 값을 가져온다.

아래의 예제는 사용자 이름을 실시간으로 표시한다.

UserDoc( ... )
UserDoc.sync(uid: user.uid, field: 'displayName', builder: (data, $) => Text(data)),
UserDoc.field( ... )
UserDoc.fieldSync( ...)
UserDoc(
  uid: message.uid!,
  builder: (data) => UserAvatar(
    user: user,
    radius: 13,
    onTap: () => ...,
  ),
),
Inheritance

Constructors

UserDoc({Key? key, required String uid, required dynamic builder(User data), Widget? onLoading, String? cacheId})
const

Properties

builder → dynamic Function(User data)
final
cacheId String?
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onLoading Widget?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
uid String
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

field({dynamic initialData, required String uid, required String field, required dynamic builder(dynamic), Widget? onLoading, String? cacheId}) Widget
fieldSync({dynamic initialData, required String uid, required String field, required Widget builder(dynamic data), Widget? onLoading}) Widget
사용자의 특정 필드 하나만 listen 한다.
sync({dynamic initialData, required String uid, required Widget builder(User data), Widget? onLoading}) Widget
사용자의 특정 필드 하나만 listen 한다.