首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >(颤振) _RenderInkFeatures对象在布局过程中被赋予无限大的尺寸

(颤振) _RenderInkFeatures对象在布局过程中被赋予无限大的尺寸
EN

Stack Overflow用户
提问于 2022-06-19 08:36:29
回答 2查看 68关注 0票数 0

我正在创建一个颤振应用程序的登录和注册页面。在main.dart中,我将HomePage()称为home属性。然后在Home_Page.dart中,我在Home_page()中初始化火基。然后使用开关语句--如果连接状态已经完成--它会转到Login_page(),然后如果我们单击login_page.dart底部的寄存器按钮,它就会转到Registration_page.dart。这就是控制的流程。现在,在这些步骤之间,调试时会在调试控制台中发生错误。

代码语言: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: _RenderSingleChildViewport#233b4 relayoutBoundary=up14 NEEDS-LAYOUT NEEDS-COMPOSITING-BITS-UPDATE
The constraints that applied to the RenderCustomMultiChildLayoutBox were: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=Infinity)
The exact size it was given was: Size(411.4, Infinity)

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

The relevant error-causing widget was
Scaffold
When the exception was thrown, this was the stack
#0      RenderBox.debugAssertDoesMeetConstraints.<anonymous closure>
#1      RenderBox.debugAssertDoesMeetConstraints
#2      RenderBox.size=.<anonymous closure>
#3      RenderBox.size=
#4      RenderCustomMultiChildLayoutBox.performLayout
#5      RenderObject.layout
#6      RenderBox.layout
#7      RenderProxyBoxMixin.performLayout
#8      RenderObject.layout
#9      RenderBox.layout
#10     RenderProxyBoxMixin.performLayout
#11     _RenderCustomClip.performLayout
#12     RenderObject.layout
#13     RenderBox.layout
#14     _RenderSingleChildViewport.performLayout
#15     RenderObject.layout
#16     RenderBox.layout
#17     RenderProxyBoxMixin.performLayout
#18     RenderObject.layout
#19     RenderBox.layout
#20     RenderProxyBoxMixin.performLayout
#21     RenderObject.layout
#22     RenderBox.layout
#23     RenderProxyBoxMixin.performLayout
#24     RenderObject.layout
#25     RenderBox.layout
#26     RenderProxyBoxMixin.performLayout
#27     RenderObject.layout
#28     RenderBox.layout
#29     RenderProxyBoxMixin.performLayout
#30     RenderObject.layout
#31     RenderBox.layout
#32     RenderProxyBoxMixin.performLayout
#33     RenderObject.layout
#34     RenderBox.layout
#35     RenderProxyBoxMixin.performLayout
#36     RenderObject.layout
#37     RenderBox.layout
#38     RenderProxyBoxMixin.performLayout
#39     RenderCustomPaint.performLayout
#40     RenderObject.layout
#41     RenderBox.layout
#42     RenderProxyBoxMixin.performLayout
#43     RenderObject.layout
#44     RenderBox.layout
#45     MultiChildLayoutDelegate.layoutChild
#46     _ScaffoldLayout.performLayout
#47     MultiChildLayoutDelegate._callPerformLayout
#48     RenderCustomMultiChildLayoutBox.performLayout
#49     RenderObject.layout
#50     RenderBox.layout
#51     RenderProxyBoxMixin.performLayout
#52     RenderObject.layout
#53     RenderBox.layout
#54     RenderProxyBoxMixin.performLayout
#55     _RenderCustomClip.performLayout
#56     RenderObject.layout
#57     RenderBox.layout
#58     RenderProxyBoxMixin.performLayout
#59     RenderObject.layout
#60     RenderBox.layout
#61     MultiChildLayoutDelegate.layoutChild
#62     _ScaffoldLayout.performLayout
#63     MultiChildLayoutDelegate._callPerformLayout
#64     RenderCustomMultiChildLayoutBox.performLayout
#65     RenderObject._layoutWithoutResize
#66     PipelineOwner.flushLayout
#67     RendererBinding.drawFrame
#68     WidgetsBinding.drawFrame
#69     RendererBinding._handlePersistentFrameCallback
#70     SchedulerBinding._invokeFrameCallback
#71     SchedulerBinding.handleDrawFrame
#72     SchedulerBinding._handleDrawFrame
#73     _invoke (dart:ui/hooks.dart:148:13)
#74     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:318:5)
#75     _drawFrame (dart:ui/hooks.dart:115:31)
The following RenderObject was being processed when the exception was fired: RenderCustomMultiChildLayoutBox#6ca1e relayoutBoundary=up17 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
RenderObject: RenderCustomMultiChildLayoutBox#6ca1e relayoutBoundary=up17 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
    parentData: <none> (can use size)
    constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=Infinity)
    size: Size(411.4, Infinity)
    child 1: RenderConstrainedBox#ca2a2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
        parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.body
        constraints: MISSING
        size: MISSING
        additionalConstraints: BoxConstraints(0.0<=w<=Infinity, h=820.6)
        child: RenderDecoratedBox#5b13e NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
            parentData: <none>
            constraints: MISSING
            size: MISSING
            decoration: BoxDecoration
                gradient: LinearGradient(begin: Alignment.topRight, end: Alignment.bottomLeft, colors: [Color(0xff000000), MaterialAccentColor(primary value: Color(0xff69f0ae)), Color(0xff000000)], tileMode: TileMode.clamp)
            configuration: ImageConfiguration(bundle: PlatformAssetBundle#f1631(), devicePixelRatio: 3.5, locale: en_US, textDirection: TextDirection.ltr, platform: android)
            child: RenderRepaintBoundary#6790e NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
                needs compositing
                parentData: <none>
                constraints: MISSING
                size: MISSING
                usefulness ratio: no metrics collected yet (never painted)
                child: RenderCustomPaint#b8e1a NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
                    parentData: <none>
                    constraints: MISSING
                    size: MISSING
                    painter: null
                    foregroundPainter: _GlowingOverscrollIndicatorPainter(_GlowController(color: Color(0xff2196f3), axis: vertical), _GlowController(color: Color(0xff2196f3), axis: vertical))
    child 2: RenderStack#57ee1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
        parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.floatingActionButton
        constraints: MISSING
        size: MISSING
        alignment: Alignment.centerRight
        textDirection: ltr
        fit: loose
        child 1: RenderTransform#0d1ac 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: Alignment.center
            textDirection: ltr
            transformHitTests: true
            child: RenderTransform#06de2 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: 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
════════════════════════════════════════════════════════════════════════════════
Restarted application in 844ms.

════════ Exception caught by rendering library ═════════════════════════════════
RenderPhysicalModel object was given an infinite size during layout.
The relevant error-causing widget was
Scaffold
════════════════════════════════════════════════════════════════════════════════

main.dart代码的代码

代码语言:javascript
运行
复制
import 'package:flutter/material.dart';
import 'package:my_mythology/Pages/home_page.dart';
import 'package:my_mythology/Pages/login_page.dart';
import 'package:my_mythology/Pages/registeration_page.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        scaffoldBackgroundColor: Colors.grey[350],
      ),
      routes: {
        '/login/' :(context)=> LoginPage(),
        '/register/':(context) => RegisterationPage(),
      },
      home: const Scaffold(
        body: HomePage(),
      ),
    );
  }
}

home_page.dart代码

代码语言:javascript
运行
复制
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:my_mythology/Pages/login_page.dart';

import '../firebase_options.dart';

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        decoration: const BoxDecoration(
            gradient: LinearGradient(
                begin: Alignment.topRight,
                end: Alignment.bottomLeft,
                colors: [
              Colors.black,
              Colors.greenAccent,
              Colors.black,
            ])),
        child: SingleChildScrollView(
          child: FutureBuilder(
            future: Firebase.initializeApp(
                options: DefaultFirebaseOptions.currentPlatform),
            builder: (context, snapshot) {
              switch (snapshot.connectionState) {
                case ConnectionState.done:
                  return const LoginPage();
                default:
                  return Text("Loading....");
              }
            },
          ),
        ),
      ),
    );
  }
}

login_page.dart代码

代码语言:javascript
运行
复制
import "package:flutter/material.dart";
import "package:firebase_auth/firebase_auth.dart";
import "package:my_mythology/firebase_options.dart";

class LoginPage extends StatefulWidget {
  const LoginPage({super.key});

  @override
  State<LoginPage> createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  late final TextEditingController _email;
  late final TextEditingController _password;
  @override
  void initState() {
    _email = TextEditingController();
    _password = TextEditingController();

    super.initState();
  }

  @override
  void dispose() {
    _email.dispose();
    _password.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      
      body: Container(
        
        height: MediaQuery.of(context).size.height,
        decoration: const BoxDecoration(
            gradient: LinearGradient(
                begin: Alignment.topRight,
                end: Alignment.bottomLeft,
                colors: [
              Colors.black,
              Colors.greenAccent,
              Colors.black,
            ])),
        
          child :
          
          
           SingleChildScrollView(
            
            
              
              child: FutureBuilder(
                future: Firebase.initializeApp(
                    options: DefaultFirebaseOptions.currentPlatform),
                builder: (context, snapshot) {
                  switch (snapshot.connectionState) {
                    case ConnectionState.done:
                      return Column(
                        
                        children: [
                          const SizedBox(
                            height: 150,
                          ),
                          Row(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: const [
                              Text(
                                "Login",
                                style: TextStyle(
                                    fontWeight: FontWeight.bold,
                                    color: Colors.white,
                                    fontSize: 50,
                                    fontStyle: FontStyle.italic),
                                textAlign: TextAlign.center,
                              ),
                            ],
                          ),
                          const SizedBox(height: 80),
                          Padding(
                            padding: const EdgeInsets.only(right: 50, left: 50),
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                TextFormField(
                                  controller: _email,
                                  enableSuggestions: true,
                                  keyboardType: TextInputType.emailAddress,
                                  decoration: const InputDecoration(
                                      labelText: 'E-Mail',
                                      hintText: "Yourname@example.com ",
                                      hintStyle: TextStyle(color: Colors.grey),
                                      labelStyle: TextStyle(
                                        fontSize: 20,
                                        fontWeight: FontWeight.normal,
                                        color: Colors.white,
                                      )),
                                ),
                                TextFormField(
                                  controller: _password,
                                  obscureText: true,
                                  enableSuggestions: false,
                                  autocorrect: false,
                                  decoration: const InputDecoration(
                                      labelText: 'Password',
                                      hintText: "yourpassword",
                                      hintStyle: TextStyle(color: Colors.grey),
                                      labelStyle: TextStyle(
                                        fontSize: 20,
                                        fontWeight: FontWeight.normal,
                                        color: Colors.white,
                                      )),
                                ),
                              ],
                            ),
                          ),
                          const SizedBox(height: 50),
                          Container(
                            height: 50,
                            width: 150,
                            decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(20),
                              color: Colors.black45,
                            ),
                            child: Column(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                TextButton(
                                  onPressed: () async {
                                    final email = _email.text;
                                    final password = _password.text;
                                    try {
                                      Firebase.initializeApp(
                                          options: DefaultFirebaseOptions
                                              .currentPlatform);
                                    } on FirebaseAuthException catch (e) {
                                      if (e.code == "User not found") ;
                                      {
                                        print("User not found");
                                      }
                                    }
                                    await FirebaseAuth.instance
                                        .signInWithEmailAndPassword(
                                            email: email, password: password);
                                  },
                                  child: const Text("Login",
                                      textAlign: TextAlign.center,
                                      style: TextStyle(
                                          color: Colors.white, fontSize: 25)),
                                ),
                              ],
                            ),
                          ),
                          const SizedBox(
                            height: 100,
                          ),
                          Padding(
                            padding: const EdgeInsets.only(left: 25),
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                const Text("Don't Have A account? Create One",
                                    style: TextStyle(
                                        color: Colors.white, fontSize: 15)),
                                Row(
                                  children:  [
                                    TextButton(
                                      onPressed: () => Navigator.of(context).pushNamed('/register/'),
                                      child: Text("Register",
                                          style: TextStyle(
                                              color: Colors.white, fontSize: 15)),
                                    ),
                                    Icon(Icons.arrow_forward_ios_rounded,
                                        color: Colors.white)
                                  ],
                                ),
                              ],
                            ),
                          )
                        ],
                      );
                    default:
                      return Text("Loading....");
                  }
                },
              ),
            ),
          
        ),
      );
    
  }
}

registration_page.dart代码

代码语言:javascript
运行
复制
import 'package:firebase_core/firebase_core.dart';
import "package:flutter/material.dart";
import "package:firebase_auth/firebase_auth.dart";
import "package:my_mythology/firebase_options.dart";

class RegisterationPage extends StatefulWidget {
  const RegisterationPage({super.key});

  @override
  State<RegisterationPage> createState() => _RegisterationPageState();
}

class _RegisterationPageState extends State<RegisterationPage> {
  late final TextEditingController _email;
  late final TextEditingController _password;
  @override
  void initState() {
    _email = TextEditingController();
    _password = TextEditingController();

    super.initState();
  }

  @override
  void dispose() {
    _email.dispose();
    _password.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        height: MediaQuery.of(context).size.height,
        decoration: const BoxDecoration(
            gradient: LinearGradient(
                begin: Alignment.topRight,
                end: Alignment.bottomLeft,
                colors: [
              Colors.black,
              Colors.greenAccent,
              Colors.black,
            ])),
        child: SingleChildScrollView(
          child: FutureBuilder(
            builder: (context, snapshot) {
              switch (snapshot.connectionState) {
                case ConnectionState.done:
                  return Column(
                    children: [
                      const SizedBox(
                        height: 150,
                      ),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: const [
                          Text(
                            "Register",
                            style: TextStyle(
                                fontWeight: FontWeight.bold,
                                color: Colors.white,
                                fontSize: 50,
                                fontStyle: FontStyle.italic),
                            textAlign: TextAlign.center,
                          ),
                        ],
                      ),
                      const SizedBox(height: 80),
                      Padding(
                        padding: const EdgeInsets.only(right: 50, left: 50),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            TextFormField(
                              controller: _email,
                              enableSuggestions: true,
                              keyboardType: TextInputType.emailAddress,
                              decoration: const InputDecoration(
                                  labelText: 'E-Mail',
                                  hintText: "Yourname@example.com ",
                                  hintStyle: TextStyle(color: Colors.grey),
                                  labelStyle: TextStyle(
                                    fontSize: 20,
                                    fontWeight: FontWeight.normal,
                                    color: Colors.white,
                                  )),
                            ),
                            TextFormField(
                              controller: _password,
                              obscureText: true,
                              enableSuggestions: false,
                              autocorrect: false,
                              decoration: const InputDecoration(
                                  labelText: 'Password',
                                  hintText: "yourpassword",
                                  hintStyle: TextStyle(color: Colors.grey),
                                  labelStyle: TextStyle(
                                    fontSize: 20,
                                    fontWeight: FontWeight.normal,
                                    color: Colors.white,
                                  )),
                            ),
                          ],
                        ),
                      ),
                      const SizedBox(height: 50),
                      Container(
                        height: 50,
                        width: 150,
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(20),
                          color: Colors.black45,
                        ),
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            TextButton(
                              onPressed: () async {
                                final email = _email.text;
                                final password = _password.text;
                                await Firebase.initializeApp(
                                    options:
                                        DefaultFirebaseOptions.currentPlatform);
                                try {
                                  await FirebaseAuth.instance
                                      .createUserWithEmailAndPassword(
                                          email: email, password: password);
                                } on FirebaseAuthException catch (e) {
                                  if (e.code == "weak-password") {
                                    print("Weak Message");
                                  } else if (e.code == "email-already-in-use") {
                                    print("Email Already In use");
                                  } else if (e.code == "invalid-email ") {
                                    print("Invalid Email");
                                  }
                                }
                              },
                              child: const Text("Register",
                                  textAlign: TextAlign.center,
                                  style: TextStyle(
                                      color: Colors.white, fontSize: 25)),
                            ),
                          ],
                        ),
                      ),
                      const SizedBox(
                        height: 100,
                      ),
                      Padding(
                        padding: const EdgeInsets.only(left: 25),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            const Text("Already Have a Account? ",
                                style: TextStyle(
                                    color: Colors.white, fontSize: 15)),
                            Row(
                              children: const [
                                Text("Login",
                                    style: TextStyle(
                                        color: Colors.white, fontSize: 15)),
                                Icon(Icons.arrow_forward_ios_rounded,
                                    color: Colors.white)
                              ],
                            ),
                          ],
                        ),
                      )
                    ],
                  );
                default:
                  return Center(child: Text("Loading...."));
              }
            },
          ),
        ),
      ),
    );
  }
}

Github链接->https://github.com/ramanjitsingh-hub/My_Mythology

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-06-21 08:29:01

为了删除此错误,首先删除singlechildscrollview作为futurebuilder的父级。现在,在未来构建器的构建函数中,将singlechildscrollview添加为列的父级,我们将返回。

代码语言:javascript
运行
复制
  return Scaffold(
      body: Container(
        
        height: MediaQuery.of(context).size.height,
        width: MediaQuery.of(context).size.width,
        decoration: const BoxDecoration(
            gradient: LinearGradient(
                begin: Alignment.topRight,
                end: Alignment.bottomLeft,
                colors: [
              Colors.black,
              Colors.greenAccent,
              Colors.black,
            ])),
        child: FutureBuilder(
           future: Firebase.initializeApp(
                    options: DefaultFirebaseOptions.currentPlatform),
          builder: (context, snapshot) {
            switch (snapshot.connectionState) {
              case ConnectionState.done:
                return SingleChildScrollView(
                  child: Column(
                    children: [
                      const SizedBox(
                        height: 150,
                      ),

将高度和宽度添加到容器中,以删除底部的空白。

Login_page.dartRegisteration_page.dart页面执行此操作

这将修复错误。

代码中的小错误是,futurebuilder的未来属性在futurebuilder of Registeration_Page.dart中丢失了。这就是注册页面总是返回Loading的原因。

票数 1
EN

Stack Overflow用户

发布于 2022-06-19 08:55:34

请在主页中添加容器的高度和宽度。您已经添加了一个容器,并分配了一个SingleChildScrollView作为它的子容器,它没有边界。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72675402

复制
相关文章

相似问题

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