1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Widgets render in debug, but not in release

Discussão em 'Mobile' iniciado por Stack, Novembro 7, 2024 às 15:33.

  1. Stack

    Stack Membro Participativo

    In one of my Flutter files I have this code that theoretically doesn't seem it should be a problem to run at all. It renders nicely in the debug version but when I build a release iOS and Android app files, it becomes partly invisible. There's a widget that renders called _heyName() which is just a text widget. The _whatWouldYouLike() widget is pretty much a 1:1 copy of the _heyName() one, yet this one doesn't render and neither does any widget afterwards.

    Console does throw this warning though:

    ======== Exception caught by widgets library =======================================================
    The following assertion was thrown while applying parent data.:
    Incorrect use of ParentDataWidget.

    The ParentDataWidget Flexible(flex: 1) wants to apply ParentData of type FlexParentData to a RenderObject, which has been set up to accept ParentData of incompatible type ParentData.

    Usually, this means that the Flexible widget has the wrong ancestor RenderObjectWidget. Typically, Flexible widgets are placed directly inside Flex widgets.
    The offending Flexible is currently placed inside a RepaintBoundary widget.

    The ownership chain for the RenderObject that received the incompatible parent data was:
    ConstrainedBox ← Container ← Flexible ← RepaintBoundary ← IndexedSemantics ← NotificationListener<KeepAliveNotification> ← KeepAlive ← AutomaticKeepAlive ← KeyedSubtree ← SliverList ← ⋯
    When the exception was thrown, this was the stack:
    #0 RenderObjectElement._updateParentData.<anonymous closure> (package:flutter/src/widgets/framework.dart:5723:11)
    #1 RenderObjectElement._updateParentData (package:flutter/src/widgets/framework.dart:5739:6)
    #2 RenderObjectElement.attachRenderObject (package:flutter/src/widgets/framework.dart:5761:7)
    #3 RenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5440:5)
    #4 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6082:11)
    ...
    ====================================================================================================


    Widget build(BuildContext context) {
    return Scaffold(
    body: NestedScrollView(
    headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
    return <Widget>[
    SliverAppBar(
    backgroundColor: Colors.transparent,
    shadowColor: Colors.transparent,
    pinned: false,
    expandedHeight: appBarHeight,
    automaticallyImplyLeading: false,
    floating: true,
    flexibleSpace: LayoutBuilder(
    builder: (context, constraints) {
    return Container(
    alignment: Alignment.bottomCenter,
    child: Container(
    height: SizeConfig.screenWidth * 0.13,
    child: GestureDetector(
    onTap: () {
    },
    child: _searchCategories(context))),
    );
    },
    ),
    ),
    ];
    },
    body: ListView(
    shrinkWrap: true,
    children: [
    _heyName(),
    SizedBox(
    height: 10,
    ),
    _whatWouldYouLike(),
    SizedBox(
    height: 10,
    ),
    _requests(),
    SizedBox(
    height: 10,
    ),
    Column(
    children: [
    Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
    _categoriesText(),
    _seeAll(),
    ],
    ),
    SizedBox(
    height: SizeConfig.screenWidth * 0.03,
    ),
    Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
    _category("Food and Beverages", 1),
    _category("Design", 2),
    ],
    ),
    SizedBox(
    height: SizeConfig.screenWidth * 0.1,
    ),
    Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
    _category("Music", 3),
    _category("Sports and Fitness", 4),
    ],
    ),
    SizedBox(
    height: SizeConfig.screenWidth * 0.1,
    ),
    Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
    _category("Personal Grooming", 5),
    _category("Information Technology", 6),
    ],
    ),
    SizedBox(
    height: SizeConfig.screenWidth * 0.1,
    ),
    Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
    _category("Home Services", 7),
    _category("Lifestyle", 8),
    ],
    ),
    SizedBox(
    height: SizeConfig.screenWidth * 0.1,
    ),
    Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
    _category("Pet Services", 9),
    _category("Consulting", 10),
    ],
    ),
    SizedBox(
    height: SizeConfig.screenWidth * 0.25,
    ),
    ],
    ),
    ],
    ),
    ),
    );
    }
    }



    Is there any other widget I could use instead of ListView here? I feel like that's the source of the problem as when I use a Column instead of ListView, it renders fine, just because it's bigger than the screen, it throws the good old RenderFlex error. I tried putting the Column in Expanded, but no luck. I feel I'm missing something here.

    [​IMG]

    [​IMG]

    Continue reading...

Compartilhe esta Página