错误未处理异常[177]堆栈溢出

如何解决错误未处理异常[177]堆栈溢出

因此,我不熟悉并尝试观看此视频。 (实际上,我几乎完蛋了),在视频中,讲师曾经尝试捕获语句,以作为发生错误时的示例。它确实对他有效,但对我无效。所以我删除了try and catch,因为它以前那样工作,但是我无法找回当时的陈述,并且陷入了以前尝试和今天遇到的错误。这是我在world_time类上的代码

import 'package:http/http.dart';
import 'dart:convert';

class WorldTime {
  String location;
  String time;
  String flag;
  String url;

  WorldTime({this.location,this.flag,this.url});

  Future<void> getTime() async {
    Response response = await get('http://worldtimeapi.org/api/timezone/$url');
    Map data = jsonDecode(response.body);
    //print(data);

    String datetime = data['datetime'];
    String offset = data['utc_offset'].substring(1,3);
    //print(datetime);
    //print(offset);

    DateTime now = DateTime.parse(datetime);
    now = now.add(Duration(hours: int.parse(offset)));

    time = now.toString();
  }

  WorldTime instance =
      WorldTime(location: 'Berlin',flag: 'germany.png',url: 'Europe/Berlin');
}

这是我在加载应用中的代码

import 'package:flutter/material.dart';
import 'package:worldtime_app/service/world_time.dart';

class Loading extends StatefulWidget {
  @override
  _LoadingState createState() => _LoadingState();
}

class _LoadingState extends State<Loading> {
  String time = 'loading';
  void setupworldtime() async {
    WorldTime instance = WorldTime(
        location: 'Berlin',url: 'Europe/Berlin');
    await instance.getTime();
    print(instance.time);
    setState(() {
      time = instance.time;
    });
  }

  @override
  void initState() {
    super.initState();
    setupworldtime();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Padding(
        padding: EdgeInsets.all(50.0),child: Text(time),),);
  }
}

我的家庭班代码:

import 'package:flutter/material.dart';

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Column(
          children: <Widget>[
            FlatButton.icon(
              onPressed: () {
                Navigator.pushNamed(context,'/Choose_Location');
              },icon: Icon(Icons.edit_location),label: Text("Choose Location"),],);
  }
}

还有我在Choose_Location类上的代码:

import 'package:flutter/material.dart';

class Choose_Location extends StatefulWidget {
  @override
  _Choose_LocationState createState() => _Choose_LocationState();
}

class _Choose_LocationState extends State<Choose_Location> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.grey[200],appBar: AppBar(
        backgroundColor: Colors.blue[900],title: Text('Choose a Location'),centerTitle: true,elevation: 0,body: RaisedButton(
        onPressed: () {
          setState(() {});
        },);
  }
}

我的主要班级:

import 'package:flutter/material.dart';
import 'package:worldtime_app/pages/Home.dart';
import 'package:worldtime_app/pages/Loading.dart';
import 'package:worldtime_app/pages/Choose_Location.dart';

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

我在pubspec.yaml依赖项中使用http:^ 0.12.2。

该应用程序的目的是使用Dart作为一种语言,使世界范围内的应用变得扑朔迷离。

这是我得到的错误。

Performing hot restart...
Syncing files to device CPH1803...
Restarted application in 36,026ms.
E/flutter (29658): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Stack Overflow
E/flutter (29658): #0      new WorldTime (package:worldtime_app/service/world_time.dart:10:3)
E/flutter (29658): #1      new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #2      new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #3      new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #4      new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #5      new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #6      new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #7      new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #8      new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #9      new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #10     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #11     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #12     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #13     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #14     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #15     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #16     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #17     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #18     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #19     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #20     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #21     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #22     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #23     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #24     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #25     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #26     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #27     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #28     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #29     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #30     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #31     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #32     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #33     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #34     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #35     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #36     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #37     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #38     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #39     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #40     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #41     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #42     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): #43     new WorldTime (package:worldtime_app/service/world_time.dart:33:24)
E/flutter (29658): ...
E/flutter (29658): ...
E/flutter (29658): #6738   Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (29658): #6739   ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
E/flutter (29658): #6740   Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
E/flutter (29658): #6741   ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5)
E/flutter (29658): #6742   ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter (29658): #6743   Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (29658): #6744   Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (29658): #6745   ComponentElement.performRebuild 

希望您能为我提供帮助,如果对我的问题有任何疑问,请提出要求以容纳您并回答我的问题。谢谢

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-