首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >_RenderInkFeatures对象在布局过程中被赋予无限大的大小。

_RenderInkFeatures对象在布局过程中被赋予无限大的大小。
EN

Stack Overflow用户
提问于 2020-11-22 06:08:44
回答 1查看 3.6K关注 0票数 1

我是新手,不知道是哪一个问题。正如我所看到的,错误是Widget build中的Widget build在调用方法和创建无限方法时像循环一样工作。

LoginPage.dart

代码语言:javascript
复制
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';

import 'main_page.dart';

class LoginPage extends StatefulWidget {
  @override
  _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  bool _isLoading = false;

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration (
        gradient: LinearGradient (
          colors: [
            Colors.blue,
            Colors.teal
          ],
          begin: Alignment.topCenter,
          end: Alignment.bottomCenter
        )
      ),
      child: _isLoading ? Center(child: CircularProgressIndicator()) : ListView (
        children: <Widget>[
          headerSection(),
          textSection(),
          buttonSection(),
        ],
      ),
    );
  }

  signIn(String email, String password) async {
    Map data = {
      'email': email,
      'password': password
    };

    var jsonData = null;
    SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
    var response = await http.post("", body: data);

    if(response.statusCode == 200) {
      _isLoading = false;
      jsonData = jsonDecode(response.body);

      setState(() {
        sharedPreferences.setString("token", jsonData['token']);
        Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (BuildContext context) => MainPage()), (Route<dynamic> route)  => false);
      });
    } else {
      print(response.body);
    }
  }

  Container buttonSection() {
    return Container(
      width: MediaQuery.of(context).size.width,
      height: 40.0 ,
      margin: EdgeInsets.only(top: 30.0),
      padding: EdgeInsets.symmetric(horizontal: 20.0),
      child: RaisedButton(
        onPressed: () {
            setState(() {
              _isLoading = true;
            });
            signIn(emailController.text, passwordController.text);
          },
          color: Colors.purple,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(5.0),
          ),
          child: Text("Sign In", style: TextStyle(color: Colors.white70))
      ),
    );
  }

  final TextEditingController emailController = new TextEditingController();
  final TextEditingController passwordController = new TextEditingController();

  Container textSection() {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 15.0, vertical: 20.0),
      child: new Scaffold(
        body: new Column(
          children: <Widget>[
            TextFormField(
              controller: emailController,
              cursorColor: Colors.white,

              style: TextStyle(color: Colors.white70),
              decoration: InputDecoration(
                icon: Icon(Icons.email, color: Colors.white70),
                hintText: "Email",
                border: UnderlineInputBorder(borderSide: BorderSide(color: Colors.white70)),
                hintStyle: TextStyle(color: Colors.white70),
              ),
            ),
            SizedBox(height: 30.0),
            TextFormField(
              controller: passwordController,
              cursorColor: Colors.white,

              obscureText: true,
              style: TextStyle(color: Colors.white70),
              decoration: InputDecoration(
                icon: Icon(Icons.lock, color: Colors.white70),
                hintText: "Password",
                border: UnderlineInputBorder(borderSide: BorderSide(color: Colors.white70)),
                hintStyle: TextStyle(color: Colors.white70),
              ),
            ),
          ]
        ),
      ),
    );
  }


  Container headerSection() {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 30.0),
      child: Text("Bob lox", style: TextStyle(color: Colors.white)),

    );
  }
}

误差

代码语言:javascript
复制
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
RenderCustomMultiChildLayoutBox object was given an infinite size during layout.

This probably means that it is a render object that tries to be as big as possible, but it was put inside another render object that allows its children to pick their own size.
The nearest ancestor providing an unbounded height constraint is: RenderIndexedSemantics#7c292 relayoutBoundary=up3 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...  parentData: index=1; layoutOffset=None (can use size)
...  constraints: BoxConstraints(w=320.0, 0.0<=h<=Infinity)
...  semantic boundary
...  size: MISSING
...  index: 1
The constraints that applied to the RenderCustomMultiChildLayoutBox were: BoxConstraints(w=290.0, 0.0<=h<=Infinity)
The exact size it was given was: Size(290.0, Infinity)

See https://flutter.dev/docs/development/ui/layout/box-constraints for more information.

The relevant error-causing widget was: 
  Scaffold file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:92:18
When the exception was thrown, this was the stack: 
#0      RenderBox.debugAssertDoesMeetConstraints.<anonymous closure> (package:flutter/src/rendering/box.dart:2060:9)
#1      RenderBox.debugAssertDoesMeetConstraints (package:flutter/src/rendering/box.dart:2128:6)
#2      RenderBox.size=.<anonymous closure> (package:flutter/src/rendering/box.dart:1846:7)
#3      RenderBox.size= (package:flutter/src/rendering/box.dart:1848:6)
#4      RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:401:5)
...
The following RenderObject was being processed when the exception was fired: RenderCustomMultiChildLayoutBox#b7fbf relayoutBoundary=up8 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...  parentData: <none> (can use size)
...  constraints: BoxConstraints(w=290.0, 0.0<=h<=Infinity)
...  size: Size(290.0, Infinity)
RenderObject: RenderCustomMultiChildLayoutBox#b7fbf relayoutBoundary=up8 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
  parentData: <none> (can use size)
  constraints: BoxConstraints(w=290.0, 0.0<=h<=Infinity)
  size: Size(290.0, Infinity)
...  child 1: RenderFlex#a75fd NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.body
...    constraints: MISSING
...    size: MISSING
...    direction: vertical
...    mainAxisAlignment: start
...    mainAxisSize: max
...    crossAxisAlignment: center
...    verticalDirection: down
...    child 1: RenderMouseRegion#dcc07 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...      constraints: MISSING
...      size: MISSING
...      listeners: enter, exit
...      cursor: SystemMouseCursor(text)
...      child: RenderIgnorePointer#7c564 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: <none>
...        constraints: MISSING
...        size: MISSING
...        ignoring: false
...        ignoringSemantics: implicitly false
...        child: RenderSemanticsAnnotations#b3580 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: <none>
...          constraints: MISSING
...          size: MISSING
...    child 2: RenderConstrainedBox#5d9df NEEDS-LAYOUT NEEDS-PAINT
...      parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...      constraints: MISSING
...      size: MISSING
...      additionalConstraints: BoxConstraints(0.0<=w<=Infinity, h=30.0)
...    child 3: RenderMouseRegion#e2532 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...      constraints: MISSING
...      size: MISSING
...      listeners: enter, exit
...      cursor: SystemMouseCursor(text)
...      child: RenderIgnorePointer#a517c NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: <none>
...        constraints: MISSING
...        size: MISSING
...        ignoring: false
...        ignoringSemantics: implicitly false
...        child: RenderSemanticsAnnotations#bb152 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          parentData: <none>
...          constraints: MISSING
...          size: MISSING
...  child 2: RenderStack#dc014 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.floatingActionButton
...    constraints: MISSING
...    size: MISSING
...    alignment: centerRight
...    textDirection: ltr
...    fit: loose
...    child 1: RenderTransform#36528 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: not positioned; offset=Offset(0.0, 0.0)
...      constraints: MISSING
...      size: MISSING
...      transform matrix: [0] 0.0,0.0,0.0,0.0
[1] 0.0,0.0,0.0,0.0
[2] 0.0,0.0,1.0,0.0
[3] 0.0,0.0,0.0,1.0
...      origin: null
...      alignment: center
...      textDirection: ltr
...      transformHitTests: true
...      child: RenderTransform#2661a NEEDS-LAYOUT NEEDS-PAINT
...        parentData: <none>
...        constraints: MISSING
...        size: MISSING
...        transform matrix: [0] 0.7,0.7,0.0,0.0
[1] -0.7,0.7,0.0,0.0
[2] 0.0,0.0,1.0,0.0
[3] 0.0,0.0,0.0,1.0
...        origin: null
...        alignment: center
...        textDirection: ltr
...        transformHitTests: true
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
_RenderInkFeatures object was given an infinite size during layout.
The relevant error-causing widget was: 
  Scaffold file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:92:18
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderPhysicalModel object was given an infinite size during layout.
The relevant error-causing widget was: 
  Scaffold file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:92:18
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderPadding object was given an infinite size during layout.
The relevant error-causing widget was: 
  Container file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:90:12
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderRepaintBoundary object was given an infinite size during layout.
The relevant error-causing widget was: 
  ListView file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:31:72
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderIndexedSemantics object was given an infinite size during layout.
The relevant error-causing widget was: 
  ListView file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:31:72
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
RenderCustomMultiChildLayoutBox object was given an infinite size during layout.

This probably means that it is a render object that tries to be as big as possible, but it was put inside another render object that allows its children to pick their own size.
The nearest ancestor providing an unbounded height constraint is: RenderIndexedSemantics#7c292 relayoutBoundary=up3 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...  needs compositing
...  parentData: index=1; layoutOffset=116.0 (can use size)
...  constraints: BoxConstraints(w=320.0, 0.0<=h<=Infinity)
...  semantic boundary
...  size: Size(320.0, Infinity)
...  index: 1
The constraints that applied to the RenderCustomMultiChildLayoutBox were: BoxConstraints(w=290.0, 0.0<=h<=Infinity)
The exact size it was given was: Size(290.0, Infinity)

See https://flutter.dev/docs/development/ui/layout/box-constraints for more information.

The relevant error-causing widget was: 
  Scaffold file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:92:18
When the exception was thrown, this was the stack: 
#0      RenderBox.debugAssertDoesMeetConstraints.<anonymous closure> (package:flutter/src/rendering/box.dart:2060:9)
#1      RenderBox.debugAssertDoesMeetConstraints (package:flutter/src/rendering/box.dart:2128:6)
#2      RenderBox.size=.<anonymous closure> (package:flutter/src/rendering/box.dart:1846:7)
#3      RenderBox.size= (package:flutter/src/rendering/box.dart:1848:6)
#4      RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:401:5)
...
The following RenderObject was being processed when the exception was fired: RenderCustomMultiChildLayoutBox#b7fbf relayoutBoundary=up8 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...  needs compositing
...  parentData: <none> (can use size)
...  constraints: BoxConstraints(w=290.0, 0.0<=h<=Infinity)
...  size: Size(290.0, Infinity)
RenderObject: RenderCustomMultiChildLayoutBox#b7fbf relayoutBoundary=up8 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
  needs compositing
  parentData: <none> (can use size)
  constraints: BoxConstraints(w=290.0, 0.0<=h<=Infinity)
  size: Size(290.0, Infinity)
...  child 1: RenderFlex#a75fd NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    needs compositing
...    parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.body
...    constraints: MISSING
...    size: MISSING
...    direction: vertical
...    mainAxisAlignment: start
...    mainAxisSize: max
...    crossAxisAlignment: center
...    verticalDirection: down
...    child 1: RenderMouseRegion#dcc07 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      needs compositing
...      parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...      constraints: MISSING
...      size: MISSING
...      listeners: enter, exit
...      cursor: SystemMouseCursor(text)
...      child: RenderIgnorePointer#7c564 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        needs compositing
...        parentData: <none>
...        constraints: MISSING
...        size: MISSING
...        ignoring: false
...        ignoringSemantics: implicitly false
...        child: RenderSemanticsAnnotations#b3580 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          needs compositing
...          parentData: <none>
...          constraints: MISSING
...          size: MISSING
...    child 2: RenderConstrainedBox#5d9df NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...      constraints: MISSING
...      size: MISSING
...      additionalConstraints: BoxConstraints(0.0<=w<=Infinity, h=30.0)
...    child 3: RenderMouseRegion#e2532 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      needs compositing
...      parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...      constraints: MISSING
...      size: MISSING
...      listeners: enter, exit
...      cursor: SystemMouseCursor(text)
...      child: RenderIgnorePointer#a517c NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        needs compositing
...        parentData: <none>
...        constraints: MISSING
...        size: MISSING
...        ignoring: false
...        ignoringSemantics: implicitly false
...        child: RenderSemanticsAnnotations#bb152 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          needs compositing
...          parentData: <none>
...          constraints: MISSING
...          size: MISSING
...  child 2: RenderStack#dc014 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.floatingActionButton
...    constraints: MISSING
...    size: MISSING
...    alignment: centerRight
...    textDirection: ltr
...    fit: loose
...    child 1: RenderTransform#36528 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: not positioned; offset=Offset(0.0, 0.0)
...      constraints: MISSING
...      size: MISSING
...      transform matrix: [0] 0.0,0.0,0.0,0.0
[1] 0.0,0.0,0.0,0.0
[2] 0.0,0.0,1.0,0.0
[3] 0.0,0.0,0.0,1.0
...      origin: null
...      alignment: center
...      textDirection: ltr
...      transformHitTests: true
...      child: RenderTransform#2661a NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: <none>
...        constraints: MISSING
...        size: MISSING
...        transform matrix: [0] 0.7,0.7,0.0,0.0
[1] -0.7,0.7,0.0,0.0
[2] 0.0,0.0,1.0,0.0
[3] 0.0,0.0,0.0,1.0
...        origin: null
...        alignment: center
...        textDirection: ltr
...        transformHitTests: true
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
_RenderInkFeatures object was given an infinite size during layout.
The relevant error-causing widget was: 
  Scaffold file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:92:18
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderPhysicalModel object was given an infinite size during layout.
The relevant error-causing widget was: 
  Scaffold file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:92:18
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderPadding object was given an infinite size during layout.
The relevant error-causing widget was: 
  Container file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:90:12
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderRepaintBoundary object was given an infinite size during layout.
The relevant error-causing widget was: 
  ListView file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:31:72
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderIndexedSemantics object was given an infinite size during layout.
The relevant error-causing widget was: 
  ListView file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:31:72
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
RenderCustomMultiChildLayoutBox object was given an infinite size during layout.

This probably means that it is a render object that tries to be as big as possible, but it was put inside another render object that allows its children to pick their own size.
The nearest ancestor providing an unbounded height constraint is: RenderIndexedSemantics#7c292 relayoutBoundary=up3 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...  needs compositing
...  parentData: index=1; layoutOffset=116.0 (can use size)
...  constraints: BoxConstraints(w=320.0, 0.0<=h<=Infinity)
...  semantic boundary
...  size: Size(320.0, Infinity)
...  index: 1
The constraints that applied to the RenderCustomMultiChildLayoutBox were: BoxConstraints(w=290.0, 0.0<=h<=Infinity)
The exact size it was given was: Size(290.0, Infinity)

See https://flutter.dev/docs/development/ui/layout/box-constraints for more information.

The relevant error-causing widget was: 
  Scaffold file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:92:18
When the exception was thrown, this was the stack: 
#0      RenderBox.debugAssertDoesMeetConstraints.<anonymous closure> (package:flutter/src/rendering/box.dart:2060:9)
#1      RenderBox.debugAssertDoesMeetConstraints (package:flutter/src/rendering/box.dart:2128:6)
#2      RenderBox.size=.<anonymous closure> (package:flutter/src/rendering/box.dart:1846:7)
#3      RenderBox.size= (package:flutter/src/rendering/box.dart:1848:6)
#4      RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:401:5)
...
The following RenderObject was being processed when the exception was fired: RenderCustomMultiChildLayoutBox#b7fbf relayoutBoundary=up8 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...  needs compositing
...  parentData: <none> (can use size)
...  constraints: BoxConstraints(w=290.0, 0.0<=h<=Infinity)
...  size: Size(290.0, Infinity)
RenderObject: RenderCustomMultiChildLayoutBox#b7fbf relayoutBoundary=up8 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
  needs compositing
  parentData: <none> (can use size)
  constraints: BoxConstraints(w=290.0, 0.0<=h<=Infinity)
  size: Size(290.0, Infinity)
...  child 1: RenderFlex#a75fd NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    needs compositing
...    parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.body
...    constraints: MISSING
...    size: MISSING
...    direction: vertical
...    mainAxisAlignment: start
...    mainAxisSize: max
...    crossAxisAlignment: center
...    verticalDirection: down
...    child 1: RenderMouseRegion#dcc07 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      needs compositing
...      parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...      constraints: MISSING
...      size: MISSING
...      listeners: enter, exit
...      cursor: SystemMouseCursor(text)
...      child: RenderIgnorePointer#7c564 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        needs compositing
...        parentData: <none>
...        constraints: MISSING
...        size: MISSING
...        ignoring: false
...        ignoringSemantics: implicitly false
...        child: RenderSemanticsAnnotations#b3580 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          needs compositing
...          parentData: <none>
...          constraints: MISSING
...          size: MISSING
...    child 2: RenderConstrainedBox#5d9df NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...      constraints: MISSING
...      size: MISSING
...      additionalConstraints: BoxConstraints(0.0<=w<=Infinity, h=30.0)
...    child 3: RenderMouseRegion#e2532 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      needs compositing
...      parentData: offset=Offset(0.0, 0.0); flex=null; fit=null
...      constraints: MISSING
...      size: MISSING
...      listeners: enter, exit
...      cursor: SystemMouseCursor(text)
...      child: RenderIgnorePointer#a517c NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        needs compositing
...        parentData: <none>
...        constraints: MISSING
...        size: MISSING
...        ignoring: false
...        ignoringSemantics: implicitly false
...        child: RenderSemanticsAnnotations#bb152 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          needs compositing
...          parentData: <none>
...          constraints: MISSING
...          size: MISSING
...  child 2: RenderStack#dc014 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.floatingActionButton
...    constraints: MISSING
...    size: MISSING
...    alignment: centerRight
...    textDirection: ltr
...    fit: loose
...    child 1: RenderTransform#36528 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: not positioned; offset=Offset(0.0, 0.0)
...      constraints: MISSING
...      size: MISSING
...      transform matrix: [0] 0.0,0.0,0.0,0.0
[1] 0.0,0.0,0.0,0.0
[2] 0.0,0.0,1.0,0.0
[3] 0.0,0.0,0.0,1.0
...      origin: null
...      alignment: center
...      textDirection: ltr
...      transformHitTests: true
...      child: RenderTransform#2661a NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: <none>
...        constraints: MISSING
...        size: MISSING
...        transform matrix: [0] 0.7,0.7,0.0,0.0
[1] -0.7,0.7,0.0,0.0
[2] 0.0,0.0,1.0,0.0
[3] 0.0,0.0,0.0,1.0
...        origin: null
...        alignment: center
...        textDirection: ltr
...        transformHitTests: true
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
_RenderInkFeatures object was given an infinite size during layout.
The relevant error-causing widget was: 
  Scaffold file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:92:18
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderPhysicalModel object was given an infinite size during layout.
The relevant error-causing widget was: 
  Scaffold file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:92:18
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderPadding object was given an infinite size during layout.
The relevant error-causing widget was: 
  Container file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:90:12
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderRepaintBoundary object was given an infinite size during layout.
The relevant error-causing widget was: 
  ListView file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:31:72
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderIndexedSemantics object was given an infinite size during layout.
The relevant error-causing widget was: 
  ListView file:///home/damir/AndroidStudioProjects/flutter_app/lib/login_page.dart:31:72
════════════════════════════════════════════════════════════════════════════════════════════════════
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-22 06:51:33

在您的shrinkWrap中添加ListView : true。错误解释当脚手架被绘制时,高度是无限的。因为脚手架需要一些最大的高度才能正常工作。您已经在具有无限高度的ListView中使用了Scaffold。要么移除支架小部件,要么将高度添加到其父容器中。同时shrinkWrap你的名单。

试试这个:

代码语言:javascript
复制
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';

import 'main_page.dart';

class LoginPage extends StatefulWidget {
  @override
  _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  bool _isLoading = false;

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
          gradient: LinearGradient(
              colors: [Colors.blue, Colors.teal],
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter)),
      child: _isLoading
          ? Center(child: CircularProgressIndicator())
          : ListView(
              shrinkWrap: true,
              children: <Widget>[
                headerSection(),
                textSection(),
                buttonSection(),
              ],
            ),
    );
  }

  signIn(String email, String password) async {
    Map data = {'email': email, 'password': password};

    var jsonData = null;
    SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
    var response = await http.post("", body: data);

    if (response.statusCode == 200) {
      _isLoading = false;
      jsonData = jsonDecode(response.body);

      setState(() {
        sharedPreferences.setString("token", jsonData['token']);
        Navigator.of(context).pushAndRemoveUntil(
            MaterialPageRoute(builder: (BuildContext context) => MainPage()),
            (Route<dynamic> route) => false);
      });
    } else {
      print(response.body);
    }
  }

  Container buttonSection() {
    return Container(
      width: MediaQuery.of(context).size.width,
      height: 40.0,
      margin: EdgeInsets.only(top: 30.0),
      padding: EdgeInsets.symmetric(horizontal: 20.0),
      child: RaisedButton(
          onPressed: () {
            setState(() {
              _isLoading = true;
            });
            signIn(emailController.text, passwordController.text);
          },
          color: Colors.purple,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(5.0),
          ),
          child: Text("Sign In", style: TextStyle(color: Colors.white70))),
    );
  }

  final TextEditingController emailController = new TextEditingController();
  final TextEditingController passwordController = new TextEditingController();

  Container textSection() {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 15.0, vertical: 20.0),
      child: new Column(children: <Widget>[
        TextFormField(
          controller: emailController,
          cursorColor: Colors.white,
          style: TextStyle(color: Colors.white70),
          decoration: InputDecoration(
            icon: Icon(Icons.email, color: Colors.white70),
            hintText: "Email",
            border: UnderlineInputBorder(
                borderSide: BorderSide(color: Colors.white70)),
            hintStyle: TextStyle(color: Colors.white70),
          ),
        ),
        SizedBox(height: 30.0),
        TextFormField(
          controller: passwordController,
          cursorColor: Colors.white,
          obscureText: true,
          style: TextStyle(color: Colors.white70),
          decoration: InputDecoration(
            icon: Icon(Icons.lock, color: Colors.white70),
            hintText: "Password",
            border: UnderlineInputBorder(
                borderSide: BorderSide(color: Colors.white70)),
            hintStyle: TextStyle(color: Colors.white70),
          ),
        ),
      ]),
    );
  }

  Container headerSection() {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 30.0),
      child: Text("Bob lox", style: TextStyle(color: Colors.white)),
    );
  }
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64951178

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档