-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Description
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
Metadata
Metadata
Assignees
Labels
No labels