您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
33 行
918 B
33 行
918 B
using ChatComponents;
|
|
using Unity.UIWidgets.foundation;
|
|
using Unity.UIWidgets.widgets;
|
|
|
|
namespace UIWidgetsSample
|
|
{
|
|
internal class InheritedUser : InheritedWidget
|
|
{
|
|
/// Represents current logged in user. Used to determine message's author.
|
|
public readonly User user;
|
|
|
|
/// Creates [InheritedWidget] from a provided [types.User] class
|
|
public InheritedUser(
|
|
User user,
|
|
Widget child,
|
|
Key key = null
|
|
) : base(key, child)
|
|
{
|
|
this.user = user;
|
|
}
|
|
|
|
public static InheritedUser of(BuildContext context)
|
|
{
|
|
return context.dependOnInheritedWidgetOfExactType<InheritedUser>();
|
|
}
|
|
|
|
public override bool updateShouldNotify(InheritedWidget oldWidget)
|
|
{
|
|
var result = user.id != ((InheritedUser) oldWidget).user.id;
|
|
return result;
|
|
}
|
|
}
|
|
}
|