Reputation: 11
I got an error while running my debug app and i do not know why this error is showing, i tried excluding the SingleChildScrollView
but another error showing up and i do not know how to solve it.
The Error i got:
════════ Exception caught by widgets library ═══════════════════════════════════
The following StackOverflowError was thrown building NotificationListener<ScrollMetricsNotification>:
Stack Overflow
The relevant error-causing widget was
SingleChildScrollView
When the exception was thrown, this was the stack
#0 _StringBase.indexOf (dart:core-patch/string_patch.dart:359:7)
#1 String.indexOf (dart:core-patch/string_patch.dart:1068:18)
#2 _StringAllMatchesIterator.moveNext (dart:core-patch/string_patch.dart:1445:24)
#3 _StringBase.replaceAll (dart:core-patch/string_patch.dart:649:35)
#4 StackFrame.fromStackTraceLine
#5 MappedIterator.moveNext (dart:_internal/iterable.dart:391:20)
#6 WhereTypeIterator.moveNext (dart:_internal/iterable.dart:869:20)
#7 new _GrowableList._ofOther (dart:core-patch/growable_array.dart:202:26)
#8 new _GrowableList.of (dart:core-patch/growable_array.dart:152:26)
#9 new List.of (dart:core-patch/array_patch.dart:51:28)
#10 Iterable.toList (dart:core/iterable.dart:470:12)
#11 StackFrame.fromStackString
#12 FlutterError.defaultStackFilter
#13 DiagnosticsStackTrace._applyStackFilter
#14 new DiagnosticsStackTrace
#15 FlutterErrorDetails.debugFillProperties
#16 DiagnosticableNode.builder.<anonymous closure>
#17 DiagnosticableNode.builder
#18 _FlutterErrorDetailsNode.builder
#19 DiagnosticableNode.emptyBodyDescription
#20 DiagnosticsNode.toJsonMap.<anonymous closure>
#21 DiagnosticsNode.toJsonMap
#22 WidgetInspectorService._nodeToJson
#23 WidgetInspectorService._reportStructuredError
#24 FlutterError.reportError
#25 _debugReportException
#26 ComponentElement.performRebuild
#27 Element.rebuild
#28 ComponentElement._firstBuild
#29 ComponentElement.mount
... Normal element mounting (7 frames)
#36 Element.inflateWidget
#37 Element.updateChild
#38 ComponentElement.performRebuild
#39 StatefulElement.performRebuild
#40 Element.rebuild
...
...
#9597 ComponentElement.mount
... Normal element mounting (21 frames)
#9618 Element.inflateWidget
#9619 Element.updateChild
#9620 RenderObjectToWidgetElement._rebuild
#9621 RenderObjectToWidgetElement.mount
#9622 RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure>
#9623 BuildOwner.buildScope
#9624 RenderObjectToWidgetAdapter.attachToRenderTree
#9625 WidgetsBinding.attachRootWidget
#9626 WidgetsBinding.scheduleAttachRootWidget.<anonymous closure>
(elided 11 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
════════════════════════════════════════════════════════════════════════════════
Reloaded 1 of 913 libraries in 748ms.
Reloaded 1 of 913 libraries in 514ms.
Reloaded 1 of 913 libraries in 503ms.
The Code:
@override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: const BottomNavigation(),
body: SafeArea(
child: SingleChildScrollView(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const SizedBox(height: 35),
_appBar(),
const SizedBox(
height: 40,
),
const TitleText(text: "My wallet"),
const SizedBox(
height: 20,
),
const BalanceCard(),
const SizedBox(
height: 50,
),
const TitleText(
text: "Operations",
),
const SizedBox(
height: 10,
),
_operationsWidget(),
const SizedBox(
height: 40,
),
],
)),
)));
}
TitleText widget:
class TitleText extends StatelessWidget {
final String text;
final double fontSize;
final Color color;
const TitleText(
{Key? key,
this.text = '',
this.fontSize = 18,
this.color = LightColor.navyBlue2})
: super(key: key);
@override
Widget build(BuildContext context) {
return Text(text,
style: GoogleFonts.mulish(
fontSize: fontSize, fontWeight: FontWeight.w800, color: color));
}
}
_operationsWidget:
Widget _operationsWidget() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
_icon(Icons.transfer_within_a_station, "Transfer"),
_icon(Icons.phone, "Airtime"),
_icon(Icons.payment, "Pay Bills"),
_icon(Icons.code, "Qr Pay"),
],
);
}
Thank you so much for your help in advance.
Upvotes: 1
Views: 839
Reputation: 748
Try wrapping the Container
in Expanded
Widget
@override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: const BottomNavigation(),
body: SafeArea(
child: SingleChildScrollView(
child: Expanded( // like this
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
Upvotes: 1