Flutter Hot Reload和Hot Restart无法正常工作 [英] Flutter Hot Reload and Hot Restart not working

查看:794
本文介绍了Flutter Hot Reload和Hot Restart无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试处理一个刚启动的项目,并且在编辑应用程序时我意识到,即使我多次更改了设计,热重加载和热重启动都没有作用。我唯一会看到屏幕更改的时间是当我卸载应用并再次运行时,

I am trying to work on a project that I just started and while editing the app I realized that neither hot reload nor hot restart are working even though I have changed the design multiple times. The only time that I would see a change in the screen is when I uninstall the app and run again,

我正在测试该应用一个模拟器,我正在使用Android Studio。

I am testing the app on an emulator and I am using Android Studio.

在输入此问题之前,我已经找到了解决方案,这就是我尝试过的事情:

I searched for a solution before typing this question and this is what I have tried:


  • 颤振清洁

  • 颤振医生-v 然后颤振升级

  • 删除模拟器并尝试使用另一个模拟器

  • 使缓存无效并重新启动

  • flutter clean
  • flutter doctor -v then flutter upgrade
  • deleting the emulator and trying on another emulator
  • invalidate cache and restart

可以很好地工作,现在却不能,下面是一个例子:

It used to work really well and now it is not, here's an example:

import 'package:gradient_app_bar/gradient_app_bar.dart';

import '../constants.dart';

class PlantScreen extends StatefulWidget {
  @override
  _PlantScreenState createState() => _PlantScreenState();
}

class _PlantScreenState extends State<PlantScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: GradientAppBar(
        centerTitle: true,
        title: Text('plant A'),
        gradient: LinearGradient(
            colors: Constants.primaryGradient,
            begin: Alignment.topLeft,
            end: Alignment.bottomRight),
      ),
      body: Container(
        constraints: BoxConstraints.expand(),
        decoration: BoxDecoration(
          gradient: LinearGradient(
              colors: Constants.primaryVariantGradient,
              begin: Alignment.topLeft,
              end: Alignment.bottomRight),
        ),
        child: Column(
          children: <Widget>[
            Card(
              child: Column(
                children: <Widget>[

                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}

推荐答案

我认为问题出在我的导入语句上

I figured the issue was with my import statement

it是:

import'file:/// E:/SelfProjects2/water_my_plants/lib/screens/plantScreen.dart';

我已经将其更改为

import'package:water_my_plants / screens / plantScreen.dart';

在我的主dart文件中,该文件具有到PlantScreen()的路径

in my main dart file that had the route to the PlantScreen()

这篇关于Flutter Hot Reload和Hot Restart无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆