Open marcelocajaiba opened 4 years ago
class FormContrato extends StatefulWidget { User user;
FormContrato({this.user, Key key}) : super(key: key);
@override _FormContratoState createState() => _FormContratoState(user: user); }
class _WatermarkPaint extends CustomPainter { final String price; final String watermark;
_WatermarkPaint(this.price, this.watermark);
@override void paint(ui.Canvas canvas, ui.Size size) { canvas.drawCircle(Offset(size.width / 2, size.height / 2), 10.8, Paint()..color = Colors.blue); }
@override bool shouldRepaint(_WatermarkPaint oldDelegate) { return oldDelegate != this; }
@override bool operator ==(Object other) => identical(this, other) || other is _WatermarkPaint && runtimeType == other.runtimeType && price == other.price && watermark == other.watermark;
@override int get hashCode => price.hashCode ^ watermark.hashCode; }
class _FormContratoState extends State
Associacao associacao = Associacao(); AssociacaoHelper associacaoHelper = AssociacaoHelper();
ByteData _img = ByteData(0);
var color = Colors.blue;
var strokeWidth = 3.0;
final _sign = GlobalKey
final formatDate = DateFormat("dd/MM/yyyy"); final _keyboardTypeNumber = TextInputType.number; final _keyboardTypeText = TextInputType.text; var _ctrlMatricula = TextEditingController(); var _ctrlOBS = TextEditingController(); DateTime _dataContrato;
var _dropdownAssociacao = null; List
@override bool get wantKeepAlive => true;
void initState() { regiaoHelper.getAllData().then((regiao) { if (mounted) { setState(() { for (Regiao c in regiao) { itemsRegiao.add({'value': c.idRegiao, 'nome': c.nome}); } }); } }); associacaoHelper.getAllData().then((associacao) { if (mounted) { setState(() { for (Associacao c in associacao) { itemsAssociacao.add({'value': c.idAssociacao, 'nome': c.nome}); } }); } }); super.initState(); }
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Column(
// crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
buildDropDown(
_dropdownAssociacao,
itemsAssociacao,
'Associação',
validarVazio,
(newValue) => setState(() => _dropdownAssociacao = newValue)),
buildDropDown(_dropdownRegiao, itemsRegiao, 'Região', validarVazio,
(newValue) => setState(() => _dropdownRegiao = newValue)),
buildDate('Data do Contrato *', formatDate,
(newValue) => _dataContrato, validar),
buildTextField("Numero da Matrícula (Manual)", false, null,
_ctrlMatricula, _keyboardTypeText, false, 1),
buildTextField(
"OBS", false, null, _ctrlOBS, _keyboardTypeText, false, 5),
Container(
margin: const EdgeInsets.only(top: 10.0),
child: Text(
'Assinatura',
style: TextStyle(color: Color(0xFF00b3c9), fontSize: 20),
),
),
Expanded(
child: Container(
height: 200,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Signature(
color: color,
key: _sign,
onSign: () {
final sign = _sign.currentState;
debugPrint(
'${sign.points.length} points in the signature');
},
strokeWidth: strokeWidth,
backgroundPainter: _WatermarkPaint("2.0", "2.0"),
),
),
color: Colors.black12,
),
),
_img.buffer.lengthInBytes == 0
? Container()
: LimitedBox(
maxHeight: 100.0,
child: Image.memory(_img.buffer.asUint8List())),
Column(
children:
This will help https://www.youtube.com/watch?v=W5U9tTAeN-M
Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible children (using Flexible rather than Expanded). This will allow the flexible children to size themselves to less than the infinite remaining space they would otherwise be forced to take, and then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum constraints provided by the parent. If this message did not help you determine the problem, consider using debugDumpRenderTree(): https://flutter.dev/debugging/#rendering-layer http://api.flutter.dev/flutter/rendering/debugDumpRenderTree.html The affected RenderFlex is: RenderFlex#dbf9e relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE(creator: Column ← Padding ← _SingleChildViewport ← IgnorePointer-[GlobalKey#a630f] ← Semantics ← _PointerListener ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey#6734b] ← _PointerListener ← Listener ← _ScrollableScope ← ⋯, parentData: offset=Offset(0.0, 0.0) (can use size), constraints: BoxConstraints(w=401.4, 0.0<=h<=Infinity), size: MISSING, direction: vertical, mainAxisAlignment: start, mainAxisSize: max, crossAxisAlignment: center, verticalDirection: down)
The creator information is set to:
Column ← Padding ← _SingleChildViewport ← IgnorePointer-[GlobalKey#a630f] ← Semantics ←
_PointerListener ← Listener ← _GestureSemantics ←
RawGestureDetector-[LabeledGlobalKey#6734b] ← _PointerListener ← Listener
← _ScrollableScope ← ⋯
The nearest ancestor providing an unbounded width constraint is: _RenderSingleChildViewport#9ba66 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:
needs compositing
creator: _SingleChildViewport ← IgnorePointer-[GlobalKey#a630f] ← Semantics ← _PointerListener ←
Listener ← _GestureSemantics ←
RawGestureDetector-[LabeledGlobalKey#6734b] ← _PointerListener ← Listener
← _ScrollableScope ← _ScrollSemantics-[GlobalKey#6e550] ← RepaintBoundary ← ⋯
parentData: (can use size)
constraints: BoxConstraints(w=411.4, h=555.4)
size: MISSING
See also: https://flutter.dev/layout/
If none of the above helps enough to fix this problem, please don't hesitate to file a bug:
https://github.com/flutter/flutter/issues/new?template=BUG.md
The relevant error-causing widget was:
Column
lib\…\view\formContrato.dart:117
When the exception was thrown, this was the stack: