RenderFlex底部溢出像素

时间:2019-01-02 05:25:13

标签: android visual-studio-code dart flutter

我在Android上调试我的Flutter应用程序时出错。

错误是: RenderFlex在底部溢出了99317像素。

我注意到只有在使用 Color.blue 代码时才会出现错误,但是如果我删除了这行代码,程序就会运行。但我需要使用此代码。

代码:

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: HomeScreen(),
    );
  }
}


class HomeScreen extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: <Widget>[
          HomeScreenTopPart()
        ],
      ),
    );
  }
}

class HomeScreenTopPart extends StatefulWidget {
  @override
  _HomeScreenTopPartState createState() => _HomeScreenTopPartState();
}

class _HomeScreenTopPartState extends State<HomeScreenTopPart> {
  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        Container(height:400.0, color: Colors.blue, )
      ],
    );
  }
}

这是控制台错误:

I/flutter (20722): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (20722): The following _CompileTimeError was thrown building Container(bg: BoxDecoration(color:
I/flutter (20722): MaterialColor(primary value: Color(0xff2196f3))), constraints: BoxConstraints(0.0<=w<=Infinity,
I/flutter (20722): h=400.0)):
I/flutter (20722): 'package:flutter/src/widgets/basic.dart': error: line 4799 pos 30:
I/flutter (20722): file:///C:/src/flutter/packages/flutter/lib/src/widgets/basic.dart:4799:30: Error: Getter not found:
I/flutter (20722): 'rootBundle'.
I/flutter (20722):     return result?.bundle ?? rootBundle;
I/flutter (20722):                              ^^^^^^^^^^
I/flutter (20722):     return result?.bundle ?? rootBundle;
I/flutter (20722):                              ^
I/flutter (20722):
I/flutter (20722): When the exception was thrown, this was the stack:

*************
I/flutter (20722): #125    Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter (20722): #126    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3710:16)
I/flutter (20722): #127    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (20722): #128    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2286:33)
I/flutter (20722): #129    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:676:20)
I/flutter (20722): #130    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
I/flutter (20722): #131    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (20722): #132    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter (20722): #133    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:751:7)
Reloaded 1 of 419 libraries in 810ms.
I/flutter (20722): #135    _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
I/flutter (20722): #136    _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
I/flutter (20722): #137    _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter (20722): (elided one frame from package dart:async)
I/flutter (20722): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (20722): Another exception was thrown: A RenderFlex overflowed by 99317 pixels on the bottom.

0 个答案:

没有答案