I'm going through the Flutter's [Write your first app](https://flutter.dev/docs/get-started/codelab) and I thought I'd add something extra to it. So I started playing around with `Dismissible` widget, similarly to how it's done in [cookbook](https://flutter.dev/docs/cookbook/gestures/dismissible). But I noticed different behaviour of that widget when it's placed under `MaterialPageRoute`. The problem is that the `itemBuilder` index doesn't get updated once I dismiss the item, it will refer to the old position before any removals. Dismissing items from the main view does however update the index. Is anybody able to explain this behaviour?

```dart
import 'package:flutter/material.dart';
import 'package:english_words/english_words.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Startup Name Generator',
      home: RandomWords(),
    );
  }
}

class RandomWordsState extends State<RandomWords> {
  final _suggestions = generateWordPairs()
      .map((WordPair pair) => pair.asCamelCase)
      .take(10)
      .toList();
  final _biggerFont = const TextStyle(fontSize: 18.0);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Startup Name Generator'),
        actions: <Widget>[
          IconButton(icon: Icon(Icons.list), onPressed: _pushSaved),
        ],
      ),
      body: _buildSuggestions(),
    );
  }

  Widget _buildSuggestions() {
    return ListView.builder(
        padding: const EdgeInsets.all(16.0),
        itemCount: _suggestions.length,
        itemBuilder: (context, index) {
          final item = _suggestions[index];
          return Dismissible(
              key: Key(item),
              onDismissed: (direction) {
                setState(() {
                  print("MaterialApp index: $index");
                  _suggestions.remove(item);
                });
              },
              background: Container(color: Colors.red),
              child: ListTile(
                title: Text(
                  item,
                  style: _biggerFont,
                ),
              ));
        });
  }

  void _pushSaved() {
    Navigator.of(context).push(
      MaterialPageRoute<void>(
        builder: (BuildContext context) {
          return Scaffold(
              appBar: AppBar(
                title: Text('Saved Suggestions'),
              ),
              body: ListView.builder(
                itemCount: _suggestions.length,
                itemBuilder: (context, index) {
                  final item = _suggestions[index];
                  return Dismissible(
                    key: Key(item),
                    onDismissed: (direction) {
                      setState(() {
                        print("MaterialPageRoute index: $index");
                        _suggestions.remove(item);
                      });
                    },
                    background: Container(color: Colors.red),
                    child: ListTile(title: Text('$item')),
                  );
                },
              ));
        },
      ),
    );
  }
}

class RandomWords extends StatefulWidget {
  @override
  RandomWordsState createState() => RandomWordsState();
}

```

Dismissing items from the main view, starting from the top, index reflects removals. After each dismiss, the top item has index 0:

```
I/flutter ( 8176): MaterialApp index: 0
I/flutter ( 8176): MaterialApp index: 0
I/flutter ( 8176): MaterialApp index: 0

```

Dismissing items from the MaterialPageRoute, starting from the top, index is preserved for all items. After each dismiss, the top item has its original index:

```
I/flutter ( 8176): MaterialPageRoute index: 0
I/flutter ( 8176): MaterialPageRoute index: 1
I/flutter ( 8176): MaterialPageRoute index: 2

```