Flutter开发之下标

Flutter开发之下标

在iOS开发中使用下标就很方便,本文主要是记录一下Flutter中系统自带的下标,还可以通过对应的方法编写自己的下标。
Flutter开发之下标

在Objective-C中的下标

关键字Subscript

NSArray
- (ObjectType)objectAtIndexedSubscript:(NSUInteger)idx API_AVAILABLE(macos(10.8), ios(6.0), watchos(2.0), tvos(9.0));- (void)setObject:(ObjectType)obj atIndexedSubscript:(NSUInteger)idx API_AVAILABLE(macos(10.8), ios(6.0), watchos(2.0), tvos(9.0));

在Swift中的下标

关键字subscript

Array
@inlinable public subscript(index: Int) -> Element@inlinable public subscript(bounds: Range<Int>) -> ArraySlice<Element>@inlinable public subscript<R>(r: R) -> ArraySlice<Element> where R : RangeExpression, Int == R.Bound { get }@inlinable public subscript(x: (UnboundedRange_) -> ()) -> ArraySlice<Element> { get }@inlinable public subscript<R>(r: R) -> ArraySlice<Element> where R : RangeExpression, Int == R.Bound@inlinable public subscript(x: (UnboundedRange_) -> ()) -> ArraySlice<Element>

Dart中的下标

关键字operator

List

abstract interface class List<E> implements Iterable<E>, _ListIterable<E>

对应的下标
  /// The object at the given [index] in the list.////// The [index] must be a valid index of this list,/// which means that `index` must be non-negative and/// less than [length].E operator [](int index);/// Sets the value at the given [index] in the list to [value].////// The [index] must be a valid index of this list,/// which means that `index` must be non-negative and/// less than [length].void operator []=(int index, E value);/// Returns the concatenation of this list and [other].////// Returns a new list containing the elements of this list followed by/// the elements of [other].////// The default behavior is to return a normal growable list./// Some list types may choose to return a list of the same type as themselves/// (see [Uint8List.+]);List<E> operator +(List<E> other);/// Whether this list is equal to [other].////// Lists are, by default, only equal to themselves./// Even if [other] is also a list, the equality comparison/// does not compare the elements of the two lists.bool operator ==(Object other);

Map

abstract interface class Map<K, V>

对应的下标
  /// The value for the given [key], or `null` if [key] is not in the map.////// Some maps allow `null` as a value./// For those maps, a lookup using this operator cannot distinguish between a/// key not being in the map, and the key being there with a `null` value./// Methods like [containsKey] or [putIfAbsent] can be used if the distinction/// is important.V? operator [](Object? key);/// Associates the [key] with the given [value].////// If the key was already in the map, its associated value is changed./// Otherwise the key/value pair is added to the map.void operator []=(K key, V value);

bool

final class bool

对应的下标
  /// The logical conjunction ("and") of this and [other].////// Returns `true` if both this and [other] are `true`, and `false` otherwise.@Since("2.1")bool operator &(bool other) => other && this;/// The logical disjunction ("inclusive or") of this and [other].////// Returns `true` if either this or [other] is `true`, and `false` otherwise.@Since("2.1")bool operator |(bool other) => other || this;/// The logical exclusive disjunction ("exclusive or") of this and [other].////// Returns whether this and [other] are neither both `true` nor both `false`.@Since("2.1")bool operator ^(bool other) => !other == this;

num

sealed class num implements Comparable<num>

对应的下标
  /// Test whether this value is numerically equal to `other`.////// If both operands are [double]s, they are equal if they have the same/// representation, except that://////   * zero and minus zero (0.0 and -0.0) are considered equal. They///     both have the numerical value zero.///   * NaN is not equal to anything, including NaN. If either operand is///     NaN, the result is always false.////// If one operand is a [double] and the other is an [int], they are equal if/// the double has an integer value (finite with no fractional part) and/// the numbers have the same numerical value.////// If both operands are integers, they are equal if they have the same value.////// Returns false if [other] is not a [num].////// Notice that the behavior for NaN is non-reflexive. This means that/// equality of double values is not a proper equality relation, as is/// otherwise required of `operator==`. Using NaN in, e.g., a [HashSet]/// will fail to work. The behavior is the standard IEEE-754 equality of/// doubles.////// If you can avoid NaN values, the remaining doubles do have a proper/// equality relation, and can be used safely.////// Use [compareTo] for a comparison that distinguishes zero and minus zero,/// and that considers NaN values as equal.bool operator ==(Object other);/// Adds [other] to this number.////// The result is an [int], as described by [int.+],/// if both this number and [other] is an integer,/// otherwise the result is a [double].num operator +(num other);/// Subtracts [other] from this number.////// The result is an [int], as described by [int.-],/// if both this number and [other] is an integer,/// otherwise the result is a [double].num operator -(num other);/// Multiplies this number by [other].////// The result is an [int], as described by [int.*],/// if both this number and [other] are integers,/// otherwise the result is a [double].num operator *(num other);/// Euclidean modulo of this number by [other].////// Returns the remainder of the Euclidean division./// The Euclidean division of two integers `a` and `b`/// yields two integers `q` and `r` such that/// `a == b * q + r` and `0 <= r < b.abs()`.////// The Euclidean division is only defined for integers, but can be easily/// extended to work with doubles. In that case, `q` is still an integer,/// but `r` may have a non-integer value that still satisfies `0 <= r < |b|`.////// The sign of the returned value `r` is always positive.////// See [remainder] for the remainder of the truncating division.////// The result is an [int], as described by [int.%],/// if both this number and [other] are integers,/// otherwise the result is a [double].////// Example:/// ```dart/// print(5 % 3); // 2/// print(-5 % 3); // 1/// print(5 % -3); // 2/// print(-5 % -3); // 1/// ```num operator %(num other);/// Divides this number by [other].double operator /(num other);/// Truncating division operator.////// Performs truncating division of this number by [other]./// Truncating division is division where a fractional result/// is converted to an integer by rounding towards zero.////// If both operands are [int]s, then [other] must not be zero./// Then `a ~/ b` corresponds to `a.remainder(b)`/// such that `a == (a ~/ b) * b + a.remainder(b)`.////// If either operand is a [double], then the other operand is converted/// to a double before performing the division and truncation of the result./// Then `a ~/ b` is equivalent to `(a / b).truncate()`./// This means that the intermediate result of the double division/// must be a finite integer (not an infinity or [double.nan]).int operator ~/(num other);/// The negation of this value.////// The negation of a number is a number of the same kind/// (`int` or `double`) representing the negation of the/// numbers numerical value (the result of subtracting the/// number from zero), if that value *exists*.////// Negating a double gives a number with the same magnitude/// as the original value (`number.abs() == (-number).abs()`),/// and the opposite sign (`-(number.sign) == (-number).sign`).////// Negating an integer, `-number`, is equivalent to subtracting/// it from zero, `0 - number`.////// (Both properties generally also hold for the other type,/// but with a few edge case exceptions).num operator -();/// Whether this number is numerically smaller than [other].////// Returns `true` if this number is smaller than [other]./// Returns `false` if this number is greater than or equal to [other]/// or if either value is a NaN value like [double.nan].bool operator <(num other);/// Whether this number is numerically smaller than or equal to [other].////// Returns `true` if this number is smaller than or equal to [other]./// Returns `false` if this number is greater than [other]/// or if either value is a NaN value like [double.nan].bool operator <=(num other);/// Whether this number is numerically greater than [other].////// Returns `true` if this number is greater than [other]./// Returns `false` if this number is smaller than or equal to [other]/// or if either value is a NaN value like [double.nan].bool operator >(num other);/// Whether this number is numerically greater than or equal to [other].////// Returns `true` if this number is greater than or equal to [other]./// Returns `false` if this number is smaller than [other]/// or if either value is a NaN value like [double.nan].bool operator >=(num other);

int

abstract final class int extends num

对应的下标
  /// Bit-wise and operator.////// Treating both `this` and [other] as sufficiently large two's component/// integers, the result is a number with only the bits set that are set in/// both `this` and [other]////// If both operands are negative, the result is negative, otherwise/// the result is non-negative./// ```dart/// print((2 & 1).toRadixString(2)); // 0010 & 0001 -> 0000/// print((3 & 1).toRadixString(2)); // 0011 & 0001 -> 0001/// print((10 & 2).toRadixString(2)); // 1010 & 0010 -> 0010/// ```int operator &(int other);/// Bit-wise or operator.////// Treating both `this` and [other] as sufficiently large two's component/// integers, the result is a number with the bits set that are set in either/// of `this` and [other]////// If both operands are non-negative, the result is non-negative,/// otherwise the result is negative.////// Example:/// ```dart/// print((2 | 1).toRadixString(2)); // 0010 | 0001 -> 0011/// print((3 | 1).toRadixString(2)); // 0011 | 0001 -> 0011/// print((10 | 2).toRadixString(2)); // 1010 | 0010 -> 1010/// ```int operator |(int other);/// Bit-wise exclusive-or operator.////// Treating both `this` and [other] as sufficiently large two's component/// integers, the result is a number with the bits set that are set in one,/// but not both, of `this` and [other]////// If the operands have the same sign, the result is non-negative,/// otherwise the result is negative.////// Example:/// ```dart/// print((2 ^ 1).toRadixString(2)); //  0010 ^ 0001 -> 0011/// print((3 ^ 1).toRadixString(2)); //  0011 ^ 0001 -> 0010/// print((10 ^ 2).toRadixString(2)); //  1010 ^ 0010 -> 1000/// ```int operator ^(int other);/// The bit-wise negate operator.////// Treating `this` as a sufficiently large two's component integer,/// the result is a number with the opposite bits set.////// This maps any integer `x` to `-x - 1`.int operator ~();/// Shift the bits of this integer to the left by [shiftAmount].////// Shifting to the left makes the number larger, effectively multiplying/// the number by `pow(2, shiftAmount)`.////// There is no limit on the size of the result. It may be relevant to/// limit intermediate values by using the "and" operator with a suitable/// mask.////// It is an error if [shiftAmount] is negative.////// Example:/// ```dart/// print((3 << 1).toRadixString(2)); // 0011 -> 0110/// print((9 << 2).toRadixString(2)); // 1001 -> 100100/// print((10 << 3).toRadixString(2)); // 1010 -> 1010000/// ```int operator <<(int shiftAmount);/// Shift the bits of this integer to the right by [shiftAmount].////// Shifting to the right makes the number smaller and drops the least/// significant bits, effectively doing an integer division by/// `pow(2, shiftAmount)`.////// It is an error if [shiftAmount] is negative.////// Example:/// ```dart/// print((3 >> 1).toRadixString(2)); // 0011 -> 0001/// print((9 >> 2).toRadixString(2)); // 1001 -> 0010/// print((10 >> 3).toRadixString(2)); // 1010 -> 0001/// print((-6 >> 2).toRadixString); // 111...1010 -> 111...1110 == -2/// print((-85 >> 3).toRadixString); // 111...10101011 -> 111...11110101 == -11/// ```int operator >>(int shiftAmount);/// Bitwise unsigned right shift by [shiftAmount] bits.////// The least significant [shiftAmount] bits are dropped,/// the remaining bits (if any) are shifted down,/// and zero-bits are shifted in as the new most significant bits.////// The [shiftAmount] must be non-negative.////// Example:/// ```dart/// print((3 >>> 1).toRadixString(2)); // 0011 -> 0001/// print((9 >>> 2).toRadixString(2)); // 1001 -> 0010/// print(((-9) >>> 2).toRadixString(2)); // 111...1011 -> 001...1110 (> 0)/// ```int operator >>>(int shiftAmount);/// Return the negative value of this integer.////// The result of negating an integer always has the opposite sign, except/// for zero, which is its own negation.int operator -();

double

abstract final class double extends num

对应的下标
  double operator +(num other);double operator -(num other);double operator *(num other);double operator %(num other);double operator /(num other);int operator ~/(num other);double operator -();

Uint8List

abstract final class Uint8List implements List<int>, _TypedIntList

对应的下标
  /// Returns a concatenation of this list and [other].////// If [other] is also a typed-data list, then the return list will be a/// typed data list capable of holding both unsigned 8-bit integers and/// the elements of [other], otherwise it'll be a normal list of integers.List<int> operator +(List<int> other);

Float32x4List

abstract final class Float32x4List implements List<Float32x4>, TypedData

对应的下标
  /// Returns the concatenation of this list and [other].////// If [other] is also a [Float32x4List], the result is a new [Float32x4List],/// otherwise the result is a normal growable `List<Float32x4>`.List<Float32x4> operator +(List<Float32x4> other);

Int32x4List

abstract final class Int32x4List implements List<Int32x4>, TypedData

对应的下标
  /// Returns the concatenation of this list and [other].////// If [other] is also a [Int32x4List], the result is a new [Int32x4List],/// otherwise the result is a normal growable `List<Int32x4>`.List<Int32x4> operator +(List<Int32x4> other);

Float64x2List

abstract final class Float64x2List implements List<Float64x2>, TypedData

对应的下标
  /// Returns the concatenation of this list and [other].////// If [other] is also a [Float64x2List], the result is a new [Float64x2List],/// otherwise the result is a normal growable `List<Float64x2>`.List<Float64x2> operator +(List<Float64x2> other);

Float32x4

abstract final class Float32x4

对应的下标
  /// Addition operator.Float32x4 operator +(Float32x4 other);/// Negate operator.Float32x4 operator -();/// Subtraction operator.Float32x4 operator -(Float32x4 other);/// Multiplication operator.Float32x4 operator *(Float32x4 other);/// Division operator.Float32x4 operator /(Float32x4 other);

Float64x2

abstract final class Float64x2

对应的下标
  /// Addition operator.Float64x2 operator +(Float64x2 other);/// Negate operator.Float64x2 operator -();/// Subtraction operator.Float64x2 operator -(Float64x2 other);/// Multiplication operator.Float64x2 operator *(Float64x2 other);/// Division operator.Float64x2 operator /(Float64x2 other);

Object

class Object

对应的下标
  /// The equality operator.////// The default behavior for all [Object]s is to return true if and/// only if this object and [other] are the same object.////// Override this method to specify a different equality relation on/// a class. The overriding method must still be an equivalence relation./// That is, it must be://////  * Total: It must return a boolean for all arguments. It should never throw.//////  * Reflexive: For all objects `o`, `o == o` must be true.//////  * Symmetric: For all objects `o1` and `o2`, `o1 == o2` and `o2 == o1` must///    either both be true, or both be false.//////  * Transitive: For all objects `o1`, `o2`, and `o3`, if `o1 == o2` and///    `o2 == o3` are true, then `o1 == o3` must be true.////// The method should also be consistent over time,/// so whether two objects are equal should only change/// if at least one of the objects was modified.////// If a subclass overrides the equality operator, it should override/// the [hashCode] method as well to maintain consistency.external bool operator ==(Object other);

Type

abstract interface class Type

对应的下标
  /// Whether [other] is a [Type] instance representing an equivalent type.////// The language specification dictates which types are considered/// to be the equivalent./// If two types are equivalent, it's guaranteed that they are subtypes/// of each other,/// but there are also types which are subtypes of each other,/// and which are not equivalent (for example `dynamic` and `void`,/// or `FutureOr<Object>` and `Object`).bool operator ==(Object other);

String

abstract final class String implements Comparable<String>, Pattern

对应的下标
  /// The character (as a single-code-unit [String]) at the given [index].////// The returned string represents exactly one UTF-16 code unit, which may be/// half of a surrogate pair. A single member of a surrogate pair is an/// invalid UTF-16 string:/// ```dart/// var clef = '\u{1D11E}';/// // These represent invalid UTF-16 strings./// clef[0].codeUnits;      // [0xD834]/// clef[1].codeUnits;      // [0xDD1E]/// ```/// This method is equivalent to/// `String.fromCharCode(this.codeUnitAt(index))`.String operator [](int index);/// Whether [other] is a `String` with the same sequence of code units.////// This method compares each individual code unit of the strings./// It does not check for Unicode equivalence./// For example, both the following strings represent the string 'Amélie',/// but due to their different encoding, are not equal:/// ```dart/// 'Am\xe9lie' == 'Ame\u{301}lie'; // false/// ```/// The first string encodes 'é' as a single unicode code unit (also/// a single rune), whereas the second string encodes it as 'e' with the/// combining accent character '◌́'.bool operator ==(Object other);/// Creates a new string by concatenating this string with [other].////// Example:/// ```dart/// const string = 'dart' + 'lang'; // 'dartlang'/// ```String operator +(String other);/// Creates a new string by concatenating this string with itself a number/// of times.////// The result of `str * n` is equivalent to/// `str + str + ...`(n times)`... + str`.////// ```dart/// const string = 'Dart';/// final multiplied = string * 3;/// print(multiplied); // 'DartDartDart'/// ```/// Returns an empty string if [times] is zero or negative.String operator *(int times);

Element

abstract class Element extends DiagnosticableTree implements BuildContext

对应的下标
  /// Compare two widgets for equality.////// When a widget is rebuilt with another that compares equal according/// to `operator ==`, it is assumed that the update is redundant and the/// work to update that branch of the tree is skipped.////// It is generally discouraged to override `operator ==` on any widget that/// has children, since a correct implementation would have to defer to the/// children's equality operator also, and that is an O(N²) operation: each/// child would need to itself walk all its children, each step of the tree.////// It is sometimes reasonable for a leaf widget (one with no children) to/// implement this method, if rebuilding the widget is known to be much more/// expensive than checking the widgets' parameters for equality and if the/// widget is expected to often be rebuilt with identical parameters.////// In general, however, it is more efficient to cache the widgets used/// in a build method if it is known that they will not change.@nonVirtual@override// ignore: avoid_equals_and_hash_code_on_mutable_classes, hash_and_equalsbool operator ==(Object other) => identical(this, other);

IndexedSlot

class IndexedSlot<T extends Element?>

对应的下标
  @overridebool operator ==(Object other) {if (other.runtimeType != runtimeType) {return false;}return other is IndexedSlot&& index == other.index&& value == other.value;}

OffsetPair

class OffsetPair

对应的下标
  /// Adds the `other.global` to [global] and `other.local` to [local].OffsetPair operator+(OffsetPair other) {return OffsetPair(local: local + other.local,global: global + other.global,);}/// Subtracts the `other.global` from [global] and `other.local` from [local].OffsetPair operator-(OffsetPair other) {return OffsetPair(local: local - other.local,global: global - other.global,);}

Velocity

class Velocity

对应的下标
  /// Return the negation of a velocity.Velocity operator -() => Velocity(pixelsPerSecond: -pixelsPerSecond);/// Return the difference of two velocities.Velocity operator -(Velocity other) {return Velocity(pixelsPerSecond: pixelsPerSecond - other.pixelsPerSecond);}/// Return the sum of two velocities.Velocity operator +(Velocity other) {return Velocity(pixelsPerSecond: pixelsPerSecond + other.pixelsPerSecond);}@overridebool operator ==(Object other) {return other is Velocity&& other.pixelsPerSecond == pixelsPerSecond;}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/572420.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

EFI Driver Model(下)-SCSI 驱动设计

1、SCSI简介 SCSI是Small Computer System Interface&#xff08;小型计算机系统接口&#xff09;的缩写&#xff0c;使用50针接口&#xff0c;外观和普通硬盘接口有些相似。SCSI硬盘和普通IDE硬盘相比有很多优点&#xff1a;接口速度快&#xff0c;并且由于主要用于服务器&…

通往荣耀之路! 在 The Sandbox 中种植树木,拯救真正的森林

The Sandbox 团队祝你国际森林日快乐&#xff01; 我们相信&#xff0c;在创造一个更美好、更包容、更友善的地球的过程中&#xff0c;我们每个人都有责任采取具有影响力和目的性的行动。这就是为什么我们平台的核心支柱是利用元宇宙来推动公益事业。 国际森林日是我们践行这一…

数据分析之POWER Piovt透视表分析与KPI设置

将几个数据表之间进行关联 生成数据透视表 超级透视表这里的字段包含子字段 这三个月份在前面的解决办法 1.选中这三个月份&#xff0c;鼠标可移动的时候移动到后面 2.在原数据进行修改 添加列获取月份&#xff0c;借助month的函数双击日期 选择月份这列----按列排序-----选择月…

2024年目前阿里云服务器一个月收费价格表多少钱?

阿里云服务器一个月多少钱&#xff1f;最便宜5元1个月。阿里云轻量应用服务器2核2G3M配置61元一年&#xff0c;折合5元一个月&#xff0c;2核4G服务器30元3个月&#xff0c;2核2G3M带宽服务器99元12个月&#xff0c;轻量应用服务器2核4G4M带宽165元12个月&#xff0c;4核16G服务…

Django开发复盘

一、URL 对于一个不会写正则表达式的蒟蒻来说&#xff0c;在urls.py中就只能傻傻的写死名字&#xff0c;但是即便这样&#xff0c;还会有很多相对路径和绝对路径的问题&#xff08;相对ip端口的路径&#xff09;&#xff0c;因为我们网页中涉及到页面跳转&#xff0c;涉及到发送…

机器学习复习手册

机器学习的要素 基本概念 泛化&#xff1a; The ability to predict accurately the target for new examples that differ from those used in the training set is known as generalization.监督学习&#xff1a;The training data comprises examples of the input variab…

python在运行时控制台以表格形式输出结果prettytable.PrettyTable()

使用prettytable库按表格的形式美化输出结果 效果如图&#xff1a; 表格中可接收列表格式的数据&#xff0c;列表中装字符串 # 引入模块 import prettytable as pt# 创建表格与表头&#xff0c;包含五列&#xff0c;分别为train-epoch&#xff0c;class&#xff0c;precisio…

【进程控制】超详细讲解wait和waitpid的原理(结合代码)

文章目录 前言waitpid函数参数option什么叫非阻塞等待&#xff1f;参数status wait 函数 前言 在了解了进程状态这一概念之后&#xff0c;我们明白了什么叫做僵尸进程&#xff1a;子进程退出&#xff0c;父进程“不管不顾”。而一旦存在僵尸进程&#xff0c;势必也会存在内存泄…

SpringBoot整合Redis:面试必考题-缓存击穿--逻辑过期解决

&#x1f389;&#x1f389;欢迎光临&#xff0c;终于等到你啦&#x1f389;&#x1f389; &#x1f3c5;我是苏泽&#xff0c;一位对技术充满热情的探索者和分享者。&#x1f680;&#x1f680; &#x1f31f;持续更新的专栏Redis实战与进阶 本专栏讲解Redis从原理到实践 …

如何解决Modbus转Profinet网关通信不稳定或数据丢失问题

接到现场反映&#xff0c;在配置Modbus转Profinet网关时&#xff0c;出现Modbus转Profinet网关&#xff08;XD-MDPN100&#xff09;通信不稳定或数据丢失的问题&#xff0c;就这个问题特做出答疑。 解决Modbus转Profinet网关&#xff08;XD-MDPN100&#xff09;通信不稳定或数据…

【Java.mysql】——数据删改(DU) 附加数据库约束

目录 &#x1f6a9;更新(Update) &#x1f6a9;删除&#xff08;Delete&#xff09; &#x1f6a9;数据库约束 &#x1f388;约束类型 ✅NULL约束 ✅NNIQUE 唯一约束 ✅DEFAULT&#xff1a;默认值约束 ✅PRIMARY KEY&#xff1a;主键约束 ✅FOREIGN KEY&#xff1a;外键…

python Flask扩展:如何查找高效开发的第三方模块(库/插件)

如何找到扩展以及使用扩展的文档 一、背景二、如何寻找框架的扩展&#xff1f;三、找到想要的扩展四、找到使用扩展的文档五、项目中实战扩展 一、背景 刚入门python的flask的框架&#xff0c;跟着文档学习了一些以后&#xff0c;想着其实在项目开发中&#xff0c;经常会用到发…