User class abstract

This object represents a Telegram user or bot.

Implemented types
Available extensions
Annotations
  • @freezed

Constructors

User({@JsonKey.new(name: 'id') required int id, @JsonKey.new(name: 'is_bot') required bool isBot, @JsonKey.new(name: 'first_name') required String firstName, @JsonKey.new(name: 'last_name') String? lastName, @JsonKey.new(name: 'username') String? username, @JsonKey.new(name: 'language_code') String? languageCode, @JsonKey.new(name: 'is_premium') bool? isPremium, @JsonKey.new(name: 'added_to_attachment_menu') bool? addedToAttachmentMenu, @JsonKey.new(name: 'can_join_groups') bool? canJoinGroups, @JsonKey.new(name: 'can_read_all_group_messages') bool? canReadAllGroupMessages, @JsonKey.new(name: 'supports_inline_queries') bool? supportsInlineQueries, @JsonKey.new(name: 'can_connect_to_business') bool? canConnectToBusiness, @JsonKey.new(name: 'has_main_web_app') bool? hasMainWebApp, @JsonKey.new(name: 'has_topics_enabled') bool? hasTopicsEnabled, @JsonKey.new(name: 'allows_users_to_create_topics') bool? allowsUsersToCreateTopics, @JsonKey.new(name: 'can_manage_bots') bool? canManageBots, @JsonKey.new(name: 'supports_guest_queries') bool? supportsGuestQueries, @JsonKey.new(name: 'supports_join_request_queries') bool? supportsJoinRequestQueries})
Creates a Telegram user or bot
const
factory
User.fromJson(Map<String, dynamic> json)
Creates a User from a JSON map
factory

Properties

addedToAttachmentMenu → bool?
Optional. True, if this user added the bot to the attachment menu
no setterinherited
allowsUsersToCreateTopics → bool?
Optional. True, if the bot allows users to create and delete topics in private chats. Returned only in getMe.
no setterinherited
canConnectToBusiness → bool?
Optional. True, if the bot can be connected to a Telegram Business account to receive its messages. Returned only in getMe.
no setterinherited
canJoinGroups → bool?
Optional. True, if the bot can be invited to groups. Returned only in getMe.
no setterinherited
canManageBots → bool?
Optional. True, if other bots can be created to be controlled by the bot. Returned only in getMe.
no setterinherited
canReadAllGroupMessages → bool?
Optional. True, if privacy mode is disabled for the bot. Returned only in getMe.
no setterinherited
copyWith → $UserCopyWith<User>
Create a copy of User with the given fields replaced by the non-null parameter values.
no setterinherited
firstName → String
User's or bot's first name
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
hasMainWebApp → bool?
Optional. True, if the bot has a main Web App. Returned only in getMe.
no setterinherited
hasTopicsEnabled → bool?
Optional. True, if forum topic mode is enabled for the bot in private chats.
no setterinherited
id → int
Unique identifier for this user or bot. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
no setterinherited
isBot → bool
True, if this user is a bot
no setterinherited
isPremium → bool?
Optional. True, if this user is a Telegram Premium user
no setterinherited
languageCode → String?
Optional. IETF language tag of the user's language
no setterinherited
lastName → String?
Optional. User's or bot's last name
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
supportsGuestQueries → bool?
Optional. True, if the bot supports guest queries from chats it is not a member of. Returned only in getMe.
no setterinherited
supportsInlineQueries → bool?
Optional. True, if the bot supports inline queries. Returned only in getMe.
no setterinherited
supportsJoinRequestQueries → bool?
Optional. True, if the bot supports join request queries and can be assigned to process them. Returned only in getMe.
no setterinherited
username → String?
Optional. User's or bot's username
no setterinherited

Methods

getChannelId() → ID?

Available on User, provided by the GetUserChatID extension

Gets the chat's ChannelID from the username
getId() → ChatID

Available on User, provided by the GetUserChatID extension

Returns the ChatID of the chat.
isTheSameChat(ID chatId) → bool

Available on User, provided by the GetUserChatID extension

Returns true if the chatId passed matches the current chat's ID.
map<TResult extends Object?>(TResult $default(_User value)) → TResult

Available on User, provided by the UserPatterns extension

A switch-like method, using callbacks.
mapOrNull<TResult extends Object?>(TResult? $default(_User value)?) → TResult?

Available on User, provided by the UserPatterns extension

A variant of map that fallback to returning null.
maybeMap<TResult extends Object?>(TResult $default(_User value)?, {required TResult orElse()}) → TResult

Available on User, provided by the UserPatterns extension

A variant of map that fallback to returning orElse.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, dynamic>
Serializes this User to a JSON map.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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