Кнопка «Назад» в браузере и на панели приложений не будет работать в веб-разработке Flutter - PullRequest
0 голосов
/ 15 апреля 2020

Я новичок во Flutter, и у меня возникли проблемы с переходом по страницам в моем веб-приложении, особенно при переходе со страницы 1 на страницу 2, когда я пытаюсь go вернуться (будь то кнопка «Назад» в браузере или «Назад» Кнопка на панели приложения, которая создается автоматически), я получаю IndexError и приложение вылетает. Я пытаюсь использовать Navigator.pu sh, но, похоже, это не работает.

RangeError (index): Index out of range: index should be less than 6: 6

When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 216:49  throw_
dart-sdk/lib/_internal/js_dev_runtime/private/js_array.dart 577:7             _get]
packages/booth_v1/main.dart 93:70                                             <fn>
packages/flutter/src/widgets/sliver.dart 446:22                               build
packages/flutter/src/widgets/sliver.dart 1134:67                              <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/identity_hash_map.dart 77:23    putIfAbsent
packages/flutter/src/widgets/sliver.dart 1134:26                              [_build]
packages/flutter/src/widgets/sliver.dart 1147:55                              <fn>
packages/flutter/src/widgets/framework.dart 2607:19                           buildScope
packages/flutter/src/widgets/sliver.dart 1140:11                              createChild
packages/flutter/src/rendering/sliver_multi_box_adaptor.dart 354:23           <fn>
packages/flutter/src/rendering/object.dart 1866:58                            <fn>
packages/flutter/src/rendering/object.dart 918:15                             [_enableMutationsToDirtySubtrees]
packages/flutter/src/rendering/object.dart 1866:13                            invokeLayoutCallback
packages/flutter/src/rendering/sliver_multi_box_adaptor.dart 343:5            [_createOrObtainChild]
packages/flutter/src/rendering/sliver_multi_box_adaptor.dart 489:5            insertAndLayoutChild
packages/flutter/src/rendering/sliver_grid.dart 587:17                        performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/sliver_padding.dart 135:11                     performLayout
packages/flutter/src/rendering/sliver_padding.dart 375:11                     performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/viewport.dart 452:12                           layoutChildSequence
packages/flutter/src/rendering/viewport.dart 1444:12                          [_attemptLayout]
packages/flutter/src/rendering/viewport.dart 1353:20                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/shifted_box.dart 394:13                        performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/custom_layout.dart 171:10                      layoutChild
packages/flutter/src/material/scaffold.dart 484:7                             performLayout
packages/flutter/src/rendering/custom_layout.dart 240:7                       [_callPerformLayout]
packages/flutter/src/rendering/custom_layout.dart 399:14                      performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/proxy_box.dart 1248:11                         performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/proxy_box.dart 3225:13                         performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/widgets/overlay.dart 700:14                              performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/proxy_box.dart 111:13                          performLayout
packages/flutter/src/rendering/object.dart 1767:7                             layout
packages/flutter/src/rendering/view.dart 167:48                               performLayout
packages/flutter/src/rendering/object.dart 1630:7                             [_layoutWithoutResize]
packages/flutter/src/rendering/object.dart 887:17                             flushLayout
packages/flutter/src/rendering/binding.dart 402:19                            drawFrame
packages/flutter/src/widgets/binding.dart 865:13                              drawFrame
packages/flutter/src/rendering/binding.dart 284:5                             [_handlePersistentFrameCallback]
packages/flutter/src/scheduler/binding.dart 1074:15                           [_invokeFrameCallback]
packages/flutter/src/scheduler/binding.dart 1013:9                            handleDrawFrame
packages/flutter/src/scheduler/binding.dart 822:7                             <fn>
dart-sdk/lib/_internal/js_dev_runtime/private/isolate_helper.dart 50:19       internalCallback
════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: RangeError (index): Index out of range: index should be less than 6: 7
Another exception was thrown: Assertion failed: org-dartlang-sdk:///flutter_web_sdk/lib/_engine/engine/surface/clip.dart:289:12
Another exception was thrown: PersistedScene: is in an unexpected state.
Another exception was thrown: PersistedOffset: is in an unexpected state.
Another exception was thrown: PersistedPhysicalShape: is in an unexpected state.
Another exception was thrown: PersistedOffset: is in an unexpected state.
Another exception was thrown: PersistedOffset: is in an unexpected state.
Another exception was thrown: PersistedOffset: is in an unexpected state.
Another exception was thrown: PersistedOffset: is in an unexpected state.
Another exception was thrown: PersistedOffset: is in an unexpected state.
Another exception was thrown: PersistedOffset: is in an unexpected state.
Another exception was thrown: PersistedOffset: is in an unexpected state.
Another exception was thrown: PersistedOffset: is in an unexpected state.
Another exception was thrown: PersistedOffset: is in an unexpected state.
Another exception was thrown: PersistedOffset: is in an unexpected state.

Вот мой пример кода

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        iconTheme: new IconThemeData(color: Colors.black),
        title: Text(
          widget.title,
          style: TextStyle(
            color: Colors.black,
            fontSize: 35,
            fontWeight: FontWeight.w400
          ),
        ),
        actions: [
          new IconButton(icon: Icon(Icons.shopping_cart,color: Colors.black), onPressed: () {
            Navigator.push(context,MaterialPageRoute(builder: (BuildContext context) => Cart()));
          })
        ],
        backgroundColor: Colors.white,
        centerTitle: true,
        elevation: 0.0,
      ),
...