Ошибка Flutter «Не удалось перейти к исходному root в моем приложении» - PullRequest
0 голосов
/ 07 мая 2020
Performing hot restart...
Syncing files to device Android SDK built for x86...
Restarted application in 2,632ms.
I/flutter (17581): ══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞═════════════════════════════════════════════════════════
I/flutter (17581): The following message was thrown:
I/flutter (17581): Could not navigate to initial route.
I/flutter (17581): The requested route name was: "/home"
I/flutter (17581): There was no corresponding route in the app, and therefore the initial route specified will be
I/flutter (17581): ignored and "/" will be used instead.
I/flutter (17581): ════════════════════════════════════════════════════════════════════════════════════════════════════

Я просто хочу переопределить маршрут '/' на данный момент, '/ home' нужно, чтобы это был мой первый экран, на котором появляется сообщение. Помогите мне, я новичок, который трепещет

Здесь мой код

import 'package:flutter/material.dart';
import 'package:worldtime/pages/choose_location.dart';
import 'package:worldtime/pages/home.dart';
import 'package:worldtime/pages/loading.dart';

void main() => runApp(MaterialApp(
  initialRoute: '/home',
  routes: {
    '/': (context) => Loading(),
    'home': (context) => Home(),
    '/location': (context) => ChooseLocation()
  },
));

1 Ответ

1 голос
/ 07 мая 2020

Вы неправильно ввели маршрут. Вы написали маршрут как:

'home': (context) => Home(),

Вам нужно изменить это на:

'/home': (context) => Home(),
...