main.dart
// p. 148 PDF import 'package:fluttematerial.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: "Flutter Calculator", theme: ThemeData( primarySwatch: Colors.blue, backgroundColor: Colors.black26 ), home: CalculatorHomePage (title: "Flutter Calculator"), ); } } class CalculatorHomePage extends StatefulWidget { CalculatorHomePage({Key key, this.title}) : super(key: key); final String title; @override _CalculatorHomePageState createState() => _CalculatorHomePageState(); } class _CalculatorHomePageState extends State { String _str = "0"; void add(String a) { } void deleteAll() { } void deleteOne() { } void getResult() { } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Card( color: Colors.lightGreen[50], child: Padding( padding: EdgeInsets.all(15.0), child: Text(_str, textScaleFactor: 2.0), ), ), Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ FlatButton( child: Text('C', style: TextStyle(color: Colors.white), ), onPressed: () { deleteAll(); }, color: Colors.black54, ), FlatButton( child: Text('<-', style: TextStyle(color: Colors.white), ), onPressed: () { deleteOne(); }, color: Colors.black87, ) ], ), Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ FlatButton( child: Text('7', style: TextStyle(color: Colors.white)), onPressed: () { add('7'); }, color: Colors.blueAccent, ), FlatButton( child: Text('8', style: TextStyle(color: Colors.white)), onPressed: () { add('8'); }, color: Colors.blueAccent, ), FlatButton( child: Text('9', style: TextStyle(color: Colors.white)), onPressed: () { add('9'); }, color: Colors.blueAccent, ), ], ), Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ FlatButton( child: Text('4', style: TextStyle(color: Colors.white)), onPressed: () { add('4'); }, color: Colors.blueAccent, ), FlatButton( child: Text('5', style: TextStyle(color: Colors.white)), onPressed: () { add('5'); }, color: Colors.blueAccent, ), FlatButton( child: Text('6', style: TextStyle(color: Colors.white)), onPressed: () { add('6'); }, color: Colors.blueAccent, ), ], ), Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ FlatButton( child: Text('1', style: TextStyle(color: Colors.white)), onPressed: () { add('1'); }, color: Colors.blueAccent, ), FlatButton( child: Text('2', style: TextStyle(color: Colors.white)), onPressed: () { add('2'); }, color: Colors.blueAccent, ), FlatButton( child: Text('3', style: TextStyle(color: Colors.white)), onPressed: () { add('3'); }, color: Colors.blueAccent, ), ], ), Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ FlatButton( child: Text('0', style: TextStyle(color: Colors.white)), onPressed: () { add('0'); }, color: Colors.blueAccent, ), FlatButton( child: Text('.', style: TextStyle(color: Colors.white)), onPressed: () { add('.'); }, color: Colors.blueAccent, ), FlatButton( child: Text('=', style: TextStyle(color: Colors.white)), onPressed: () { getResult(); }, color: Colors.blue[50], ), ], ), ], ), Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ FlatButton( child: Image.asset( "icons/divide.png", width: 10.0, height: 10.0, ), onPressed: () {add('÷');}, color: Colors.blue[50], ), FlatButton( child: Text('x'), onPressed: () {add('x');}, color: Colors.blue[50], ), FlatButton( child: Text('-'), onPressed: () {add('-');}, color: Colors.blue[50], ), FlatButton( child: Text('+'), onPressed: () {add('+');}, color: Colors.blue[50], ), ], ) ], ), ], ), ); } }
Errors
Performing hot restart... Syncing files to device Android SDK built for x86... Malformed message Restarted application in 1.064ms. I/flutter (16997): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════ I/flutter (16997): The following assertion was thrown during performLayout(): I/flutter (16997): BoxConstraints forces an infinite height. I/flutter (16997): These invalid constraints were provided to RenderSemanticsAnnotations's layout() function by the I/flutter (16997): following function, which probably computed the invalid constraints in question: I/flutter (16997): RenderFlex.performLayout (package:fluttesrc/rendering/flex.dart:746:15) I/flutter (16997): The offending constraints were: I/flutter (16997): BoxConstraints(0.0<=w<=Infinity, h=Infinity) I/flutter (16997): I/flutter (16997): The relevant error-causing widget was: I/flutter (16997): Row I/flutter (16997): file:///C:/Users/danie/stack/Daniel/Prive/Programmeren/androidApps/flutter_app_calculatolib/main.dart:58:11 I/flutter (16997): I/flutter (16997): When the exception was thrown, this was the stack: I/flutter (16997): #0 BoxConstraints.debugAssertIsValid..throwError (package:fluttesrc/rendering/box.dart:517:9) I/flutter (16997): #1 BoxConstraints.debugAssertIsValid. (package:fluttesrc/rendering/box.dart:561:21) I/flutter (16997): #2 BoxConstraints.debugAssertIsValid (package:fluttesrc/rendering/box.dart:565:6) I/flutter (16997): #3 RenderObject.layout (package:fluttesrc/rendering/object.dart:1670:24) I/flutter (16997): #4 RenderFlex.performLayout (package:fluttesrc/rendering/flex.dart:746:15) I/flutter (16997): #5 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #6 RenderFlex.performLayout (package:fluttesrc/rendering/flex.dart:746:15) I/flutter (16997): #7 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #8 MultiChildLayoutDelegate.layoutChild (package:fluttesrc/rendering/custom_layout.dart:171:11) I/flutter (16997): #9 _ScaffoldLayout.performLayout (package:fluttesrc/material/scaffold.dart:484:7) I/flutter (16997): #10 MultiChildLayoutDelegate._callPerformLayout (package:fluttesrc/rendering/custom_layout.dart:240:7) I/flutter (16997): #11 RenderCustomMultiChildLayoutBox.performLayout (package:fluttesrc/rendering/custom_layout.dart:399:14) I/flutter (16997): #12 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #13 RenderProxyBoxMixin.performLayout (package:fluttesrc/rendering/proxy_box.dart:111:13) I/flutter (16997): #14 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #15 RenderProxyBoxMixin.performLayout (package:fluttesrc/rendering/proxy_box.dart:111:13) I/flutter (16997): #16 _RenderCustomClip.performLayout (package:fluttesrc/rendering/proxy_box.dart:1248:11) I/flutter (16997): #17 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #18 RenderProxyBoxMixin.performLayout (package:fluttesrc/rendering/proxy_box.dart:111:13) I/flutter (16997): #19 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #20 RenderProxyBoxMixin.performLayout (package:fluttesrc/rendering/proxy_box.dart:111:13) I/flutter (16997): #21 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #22 RenderProxyBoxMixin.performLayout (package:fluttesrc/rendering/proxy_box.dart:111:13) I/flutter (16997): #23 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #24 RenderProxyBoxMixin.performLayout (package:fluttesrc/rendering/proxy_box.dart:111:13) I/flutter (16997): #25 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #26 RenderProxyBoxMixin.performLayout (package:fluttesrc/rendering/proxy_box.dart:111:13) I/flutter (16997): #27 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #28 RenderProxyBoxMixin.performLayout (package:fluttesrc/rendering/proxy_box.dart:111:13) I/flutter (16997): #29 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #30 RenderProxyBoxMixin.performLayout (package:fluttesrc/rendering/proxy_box.dart:111:13) I/flutter (16997): #31 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #32 RenderProxyBoxMixin.performLayout (package:fluttesrc/rendering/proxy_box.dart:111:13) I/flutter (16997): #33 RenderOffstage.performLayout (package:fluttesrc/rendering/proxy_box.dart:3225:13) I/flutter (16997): #34 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #35 _RenderTheatre.performLayout (package:fluttesrc/widgets/overlay.dart:700:15) I/flutter (16997): #36 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #37 RenderProxyBoxMixin.performLayout (package:fluttesrc/rendering/proxy_box.dart:111:13) I/flutter (16997): #38 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #39 RenderProxyBoxMixin.performLayout (package:fluttesrc/rendering/proxy_box.dart:111:13) I/flutter (16997): #40 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #41 RenderProxyBoxMixin.performLayout (package:fluttesrc/rendering/proxy_box.dart:111:13) I/flutter (16997): #42 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #43 RenderProxyBoxMixin.performLayout (package:fluttesrc/rendering/proxy_box.dart:111:13) I/flutter (16997): #44 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #45 RenderProxyBoxMixin.performLayout (package:fluttesrc/rendering/proxy_box.dart:111:13) I/flutter (16997): #46 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #47 RenderProxyBoxMixin.performLayout (package:fluttesrc/rendering/proxy_box.dart:111:13) I/flutter (16997): #48 RenderObject.layout (package:fluttesrc/rendering/object.dart:1767:7) I/flutter (16997): #49 RenderView.performLayout (package:fluttesrc/rendering/view.dart:167:13) I/flutter (16997): #50 RenderObject._layoutWithoutResize (package:fluttesrc/rendering/object.dart:1630:7) I/flutter (16997): #51 PipelineOwner.flushLayout (package:fluttesrc/rendering/object.dart:887:18) I/flutter (16997): #52 RendererBinding.drawFrame (package:fluttesrc/rendering/binding.dart:402:19) I/flutter (16997): #53 WidgetsBinding.drawFrame (package:fluttesrc/widgets/binding.dart:884:13) I/flutter (16997): #54 RendererBinding._handlePersistentFrameCallback (package:fluttesrc/rendering/binding.dart:284:5) I/flutter (16997): #55 SchedulerBinding._invokeFrameCallback (package:fluttesrc/schedulebinding.dart:1113:15) I/flutter (16997): #56 SchedulerBinding.handleDrawFrame (package:fluttesrc/schedulebinding.dart:1052:9) I/flutter (16997): #57 SchedulerBinding.scheduleWarmUpFrame. (package:fluttesrc/schedulebinding.dart:861:7) I/flutter (16997): (elided 11 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch) I/flutter (16997): I/flutter (16997): The following RenderObject was being processed when the exception was fired: RenderFlex#9282e relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE: I/flutter (16997): creator: Row ← Column ← _BodyBuilder ← MediaQuery ← LayoutId-[<_ScaffoldSlot.body>] ← I/flutter (16997): CustomMultiChildLayout ← AnimatedBuilder ← DefaultTextStyle ← AnimatedDefaultTextStyle ← I/flutter (16997): _InkFeatures-[GlobalKey#4f494 ink renderer] ← NotificationListener ← I/flutter (16997): PhysicalModel ← ⋯ I/flutter (16997): parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size) I/flutter (16997): constraints: BoxConstraints(w=392.7, 0.0<=h<=Infinity) I/flutter (16997): size: MISSING I/flutter (16997): direction: horizontal I/flutter (16997): mainAxisAlignment: start I/flutter (16997): mainAxisSize: max I/flutter (16997): crossAxisAlignment: stretch I/flutter (16997): textDirection: ltr I/flutter (16997): verticalDirection: down I/flutter (16997): This RenderObject had the following descendants (showing up to depth 5): I/flutter (16997): child 1: RenderSemanticsAnnotations#6a6e2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (16997): child: _RenderInputPadding#bd224 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (16997): child: RenderConstrainedBox#20715 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (16997): child: RenderPhysicalShape#d6cdb NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (16997): child: RenderCustomPaint#dbca6 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (16997): child 2: RenderSemanticsAnnotations#14dfd NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (16997): child: _RenderInputPadding#b1d32 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (16997): child: RenderConstrainedBox#1d4ff NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (16997): child: RenderPhysicalShape#1fcd9 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (16997): child: RenderCustomPaint#fbd76 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (16997): ════════════════════════════════════════════════════════════════════════════════════════════════════ I/flutter (16997): Another exception was thrown: RenderBox was not laid out: RenderFlex#9282e relayoutBoundary=up2 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (16997): Another exception was thrown: RenderBox was not laid out: RenderFlex#96b18 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE I/flutter (16997): Another exception was thrown: NoSuchMethodError: The method '>' was called on null. ════════ Exception caught by rendering library ═════════════════════════════════════════════════════ BoxConstraints forces an infinite height. The relevant error-causing widget was: Row file:/xxxxxx/flutter_app_calculatolib/main.dart:58:11 ════════════════════════════════════════════════════════════════════════════════════════════════════ ════════ Exception caught by rendering library ═════════════════════════════════════════════════════ RenderBox was not laid out: RenderFlex#9282e relayoutBoundary=up2 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE 'package:fluttesrc/rendering/box.dart': Failed assertion: line 1694 pos 12: 'hasSize' The relevant error-causing widget was: Column file:/xxxxxxxxx/flutter_app_calculatolib/main.dart:48:13 ════════════════════════════════════════════════════════════════════════════════════════════════════ ════════ Exception caught by rendering library ═════════════════════════════════════════════════════ RenderBox was not laid out: RenderFlex#96b18 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE 'package:fluttesrc/rendering/box.dart': Failed assertion: line 1694 pos 12: 'hasSize' The relevant error-causing widget was: Scaffold file:/xxxxxxx/flutter_app_calculatolib/main.dart:44:12 ════════════════════════════════════════════════════════════════════════════════════════════════════ ════════ Exception caught by rendering library ═════════════════════════════════════════════════════ The method '>' was called on null. Receiver: null Tried calling: >(1e-10) The relevant error-causing widget was: Column file://xxxxxx/flutter_app_calculatolib/main.dart:48:13 ════════════════════════════════════════════════════════════════════════════════════════════════════
Flutter doctor -v:
[√] Flutter (Channel stable, v1.17.3, on Microsoft Windows [Version 10.0.18363.1082], locale nl-NL) • Flutter version 1.17.3 at xxxx\Installation\Windows • Framework revision b041144f83 (4 months ago), 2020-06-04 09:26:11 -0700 • Engine revision ee76268252 • Dart version 2.8.4 [√] Android toolchain - develop for Android devices (Android SDK version 29.0.3) • Android SDK at xxxxxx\Sdk • Platform android-29, build-tools 29.0.3 • ANDROID_HOME = xxxxxx\Sdk\ • Java binary at: xxxxxx\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) • All Android licenses accepted. [√] Android Studio (version 4.0) • Android Studio at xxxxxx\Android Studio • Flutter plugin version 50.0.1 • Dart plugin version 193.7547 • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) [√] Connected device (1 available) • Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator) • No issues found!