menu

  1. [ Flutter ](index.html)
  2. [ widgets.dart ](widgets/widgets-library.html)
  3. IndexedSemantics class 

IndexedSemantics

brightness_4  brightness_5

[ description
](https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/basic.dart#L7526
"View source code")

#  IndexedSemantics  class

A widget that annotates the child semantics with an index.

Semantic indexes are used by TalkBack/Voiceover to make announcements about
the current scroll state. Certain widgets like the [ ListView
](widgets/ListView-class.html) will automatically provide a child index for
building semantics. A user may wish to manually provide semantic indexes if
not all child of the scrollable contribute semantics.

The example below handles spacers in a scrollable that don't contribute
semantics. The automatic indexes would give the spaces a semantic index,
causing scroll announcements to erroneously state that there are four items
visible.

_link_

_content_copy_

    
    
    ListView(
      addSemanticIndexes: false,
      semanticChildCount: 2,
      children: const <Widget>[
        IndexedSemantics(index: 0, child: Text('First')),
        Spacer(),
        IndexedSemantics(index: 1, child: Text('Second')),
        Spacer(),
      ],
    )

See also:

  * [ CustomScrollView ](widgets/CustomScrollView-class.html) , for an explanation of index semantics. 

Inheritance

    

  * [ Object ](dart-core/Object-class.html)
  * [ DiagnosticableTree ](foundation/DiagnosticableTree-class.html)
  * [ Widget ](widgets/Widget-class.html)
  * [ RenderObjectWidget ](widgets/RenderObjectWidget-class.html)
  * [ SingleChildRenderObjectWidget ](widgets/SingleChildRenderObjectWidget-class.html)
  * IndexedSemantics 

##  Constructors

[ IndexedSemantics ](widgets/IndexedSemantics/IndexedSemantics.html) (  {  [
Key ](foundation/Key-class.html) ?  key  ,  required  [ int ](dart-core/int-
class.html) index  ,  [ Widget ](widgets/Widget-class.html) ?  child  }  )

     Creates a widget that annotated the first child semantics node with an index. 

const

##  Properties

[ child ](widgets/SingleChildRenderObjectWidget/child.html) → [ Widget
](widgets/Widget-class.html) ?

     The widget below this widget in the tree. 

final  inherited

[ hashCode ](widgets/Widget/hashCode.html) → [ int ](dart-core/int-class.html)

     The hash code for this object. 

no setter  inherited

[ index ](widgets/IndexedSemantics/index.html) → [ int ](dart-core/int-
class.html)

     The index used to annotate the first child semantics node. 

final

[ key ](widgets/Widget/key.html) → [ Key ](foundation/Key-class.html) ?

     Controls how one widget replaces another widget in the tree. 

final  inherited

[ runtimeType ](dart-core/Object/runtimeType.html) → [ Type ](dart-core/Type-
class.html)

     A representation of the runtime type of the object. 

no setter  inherited

##  Methods

[ createElement ](widgets/SingleChildRenderObjectWidget/createElement.html) (
)  → [ SingleChildRenderObjectElement
](widgets/SingleChildRenderObjectElement-class.html)

     RenderObjectWidgets always inflate to a [ RenderObjectElement ](widgets/RenderObjectElement-class.html) subclass. 

inherited

[ createRenderObject ](widgets/IndexedSemantics/createRenderObject.html) (  [
BuildContext ](widgets/BuildContext-class.html) context  )  → [
RenderIndexedSemantics ](rendering/RenderIndexedSemantics-class.html)

     Creates an instance of the [ RenderObject ](rendering/RenderObject-class.html) class that this [ RenderObjectWidget ](widgets/RenderObjectWidget-class.html) represents, using the configuration described by this [ RenderObjectWidget ](widgets/RenderObjectWidget-class.html) . 

override

[ debugDescribeChildren
](foundation/DiagnosticableTree/debugDescribeChildren.html) (  )  → [ List
](dart-core/List-class.html) < [ DiagnosticsNode ](foundation/DiagnosticsNode-
class.html) >

     Returns a list of ` DiagnosticsNode ` objects describing this node's children. 

inherit