Skip to content

Exception on set debugPaintSizeEnabled = true #17244

Closed

Description

@sirdody

Here is an example on the internet, I run without any error except when I set debugPaintSizeEnabled = true in the main function:

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart' show debugPaintSizeEnabled;

void main() {
//  debugPaintSizeEnabled = true; 
  runApp(new FriendlychatApp());
}

const String _name = "Your Name";

class FriendlychatApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: "Friendlychat", 
      home: new ChatScreen(),
    );
  }
}

class ChatMessage extends StatelessWidget {
  ChatMessage({this.text, this.animationController});
  final String text;
  final AnimationController animationController;
  @override
  Widget build(BuildContext context) {
      return new SizeTransition(
        sizeFactor: new CurvedAnimation(
          parent: animationController,
          curve: Curves.easeOut
        ),
        axisAlignment: 0.0,
        child: new Container(
          margin: const EdgeInsets.symmetric(vertical: 10.0),
          child: new Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              new Container(
                margin: const EdgeInsets.only(right: 16.0),
                child: new CircleAvatar(child: new Text(_name[0])),
              ),
              new Expanded(
                child: new Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    new Text(_name, style: Theme.of(context).textTheme.subhead),
                    new Container(
                      margin: const EdgeInsets.only(top: 5.0),
                      child: new Text(text),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ) 
      );
  }
}

class ChatScreen extends StatefulWidget {
  @override
  State createState() => new ChatScreenState();
}

class ChatScreenState extends State<ChatScreen> with TickerProviderStateMixin {
  final List<ChatMessage> _messages = <ChatMessage>[];
  final TextEditingController _textController = new TextEditingController();
  bool _isComposing = false;

  void _handleSubmitted(String text) {
    _textController.clear();
    setState(() {
      _isComposing = false;
    });
    ChatMessage message = new ChatMessage(
      text: text,
      animationController: new AnimationController(
        duration: new Duration(milliseconds: 700),
        vsync: this, //TickerProviderStateMixin
      ),
    );
    setState(() {
      _messages.insert(0, message);
    });
    message.animationController.forward();
  }

  void dispose() {
    for (ChatMessage message in _messages)
    message.animationController.dispose();
    super.dispose();
  }

  Widget _buildTextComposer() {
    return new IconTheme(
      data: new IconThemeData(color: Theme.of(context).accentColor),
      child: new  Container(
        margin: const EdgeInsets.symmetric(horizontal: 8.0), //margin left and right
        child: new Row(
          children: <Widget>[
            new Flexible(
              child: new TextField(
                controller: _textController,
                onChanged: (String text) {
                  setState(() {
                    _isComposing = text.length > 0;
                  });
                },
                onSubmitted: _handleSubmitted,
                decoration: new InputDecoration.collapsed(
                  hintText: "Send a message",
                ),
                maxLines: null,
              ) ,
            ),

            new Container(
              margin: new EdgeInsets.symmetric(horizontal: 4.0),
              child: new IconButton(
                icon: new Icon(Icons.send),
                onPressed: _isComposing ? () => _handleSubmitted(_textController.text) : null, //null -> disable button 
              ),
            ),

          ],
        ),         
      ),
    );
  }

  @override 
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Friendly Chat'), //Title at the top of app (just bellow the status bar of phone)
      ),

      body: new Column(
        children: <Widget>[
          new Flexible(
            child: new ListView.builder(
              padding: new EdgeInsets.all(8.0),
              reverse: true,
              itemBuilder: (_, int index) => _messages[index],
              itemCount: _messages.length,
            ),
          ),
          new Divider(height: 1.0,),
          new Container(
            decoration: new BoxDecoration(
              color: Theme.of(context).cardColor,
            ),
            child: _buildTextComposer(),
          ) 
        ],
      ),
    );
  }
}

Logs:

I/flutter ( 6046): #117    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter ( 6046): #118    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter ( 6046): #119    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:751:7)
I/flutter ( 6046): #121    _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
I/flutter ( 6046): #122    _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
I/flutter ( 6046): #123    _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)
I/flutter ( 6046): (elided 3 frames from class _AssertionError and package dart:async)
I/flutter ( 6046):
I/flutter ( 6046): The following RenderObject was being processed when the exception was fired:
I/flutter ( 6046):   RenderViewport#80a19
I/flutter ( 6046):   creator: Viewport ← _ScrollableScope ← IgnorePointer-[GlobalKey#97fb9] ← Semantics ← Listener ←
I/flutter ( 6046):   _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#83270] ←
I/flutter ( 6046):   _ExcludableScrollSemantics-[GlobalKey#fc6db] ← RepaintBoundary ← CustomPaint ← RepaintBoundary ←
I/flutter ( 6046):   NotificationListener<ScrollNotification> ← ⋯
I/flutter ( 6046):   parentData: <none> (can use size)
I/flutter ( 6046):   constraints: BoxConstraints(0.0<=w<=360.0, 0.0<=h<=511.0)
I/flutter ( 6046):   layer: OffsetLayer#a1d9c DETACHED
I/flutter ( 6046):   size: Size(360.0, 511.0)
I/flutter ( 6046):   axisDirection: up
I/flutter ( 6046):   crossAxisDirection: right
I/flutter ( 6046):   offset: ScrollPositionWithSingleContext#47b49(offset: 0.0, range: 0.0..0.0, viewport: 511.0,
I/flutter ( 6046):   ScrollableState, AlwaysScrollableScrollPhysics -> ClampingScrollPhysics, IdleScrollActivity#a5bb0,
I/flutter ( 6046):   ScrollDirection.idle)
I/flutter ( 6046):   anchor: 0.0
I/flutter ( 6046): This RenderObject had the following descendants (showing up to depth 5):
I/flutter ( 6046):   RenderSliverPadding#df3db relayoutBoundary=up1
I/flutter ( 6046):     RenderSliverList#94912 relayoutBoundary=up2 NEEDS-PAINT
I/flutter ( 6046): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 6046): Another exception was thrown: Tried to paint a RenderObject reentrantly.

Flutter Doctor

[flutter] flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v0.3.1, on Microsoft Windows [Version 10.0.15063], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[√] Android Studio (version 3.1)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[√] VS Code, 64-bit edition (version 1.22.2)
[√] Connected devices (1 available)

• No issues found!
exit code 0

Activity

  1. zoechi commented on May 8, 2018

    @zoechi
    Contributor

    If you wrap the code in ``` it will be properly formatted.

  2. sirdody commented on May 8, 2018

    @sirdody
    Author

    I did wrap in ``` but it still not formatted properly, then I left it out.

  3. zoechi commented on Jul 27, 2018

    @zoechi
    Contributor

    Can't reproduce in
    [✓] Flutter (Channel master, v0.5.8-pre.142, on Mac OS X 10.13.6 17G65, locale en-AT)
    • Flutter version 0.5.8-pre.142 at /Users/zoechi/flutter/flutter
    • Framework revision f72c514 (21 hours ago), 2018-07-26 05:08:11 -0700
    • Engine revision 95e91e3
    • Dart version 2.0.0-dev.69.0.flutter-937ee2e8ca

    [✓] Android toolchain - develop for Android devices (Android SDK 28.0.1)
    • Android SDK at /usr/local/opt/android-sdk
    • Android NDK at /usr/local/opt/android-sdk/ndk-bundle
    • Platform android-28, build-tools 28.0.1
    • ANDROID_HOME = /usr/local/opt/android-sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
    • All Android licenses accepted.

    [✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 9.4.1, Build version 9F2000
    • ios-deploy 1.9.2
    • CocoaPods version 1.5.3

    [✓] Android Studio (version 3.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 23.1.2
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

    [✓] IntelliJ IDEA Ultimate Edition (version 2018.1.6)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 26.0.2
    • Dart plugin version 181.4892.1

    [✓] Connected devices (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.1.0 (API 27) (emulator)

    • No issues found!

    Please add a comment and the output of flutter doctor -v if you still can reproduce to reopen.

  4. github-actions commented on Sep 2, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  5. locked as resolved and limited conversation to collaborators on Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions