StackOverflowError 由我的自定义 bottom-sheet 小部件抛出
StackOverflowError is thrown by my custom bottom-sheet widget
当我尝试在我的底页小部件上设置值时,抛出以下错误:
Exception caught by widgets library
═══════════════════════════════════ The following WhosebugError
was thrown building BSheetWidget(dirty, dependencies: [MediaQuery],
state: _BSheetWidgetState#759dc): Stack Overflow
The relevant error-causing widget was BSheetWidget
lib\…\client\clientscreen_view.dart:874 When the exception was thrown,
this was the stack
#0 Driver.carReference package:taxi_app/…/models/driver.dart:29
#1 Driver.carReference package:taxi_app/…/models/driver.dart:29
#2 Driver.carReference package:taxi_app/…/models/driver.dart:29
#3 Driver.carReference package:taxi_app/…/models/driver.dart:29
#4 Driver.carReference package:taxi_app/…/models/driver.dart:29 ...
════════════════════════════════════════════════════════════════════════════════
Reloaded 1 of 2190 libraries in 2 987ms.
我发现问题出在这里:
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('vehicule model'),
],
),
Text(widget.fullData.driver.carReference != null ? widget.fullData.driver.carReference.toString() : '', style: TextStyle(color: ThemeUtils.bluePlus,fontSize: 18)), //
],
),
),
但我发现当我尝试更改文本时:
Text(widget.fullData.driver.carReference != null ? widget.fullData.driver.carReference.toString() : '', style: TextStyle(color: ThemeUtils.bluePlus,fontSize: 18)),
有效:
我的模特:
@override
Driver clone(Map<String, dynamic> map) => Driver()..fromJson(map);
static const String carNameKey = 'carName';
static const String carReferenceKey = 'carReference';
static const String carSerieKey = 'carSerie';
static const String carImageKey = 'carImage';
String get carName => get<String>(carNameKey);
String get carReference => get<String>(carReference);
String get carSerie => get<String>(carSerie);
ParseFile get carImage => get<ParseFile>(carImageKey);
set carName(String value) => set<String>(carNameKey, value);
set carReference(String value) => set<String>(carReferenceKey, value);
set carSerie(String value) => set<String>(carSerieKey, value);
set carImage(ParseFile value) => set<ParseFile>(carImageKey, value);
解决方法是将我的setter修改为
String get carReference => get<String>(carReferenceKey);
String get carSerie => get<String>(carSerieKey);
当我尝试在我的底页小部件上设置值时,抛出以下错误:
Exception caught by widgets library ═══════════════════════════════════ The following WhosebugError was thrown building BSheetWidget(dirty, dependencies: [MediaQuery], state: _BSheetWidgetState#759dc): Stack Overflow
The relevant error-causing widget was BSheetWidget lib\…\client\clientscreen_view.dart:874 When the exception was thrown, this was the stack #0 Driver.carReference package:taxi_app/…/models/driver.dart:29 #1 Driver.carReference package:taxi_app/…/models/driver.dart:29 #2 Driver.carReference package:taxi_app/…/models/driver.dart:29 #3 Driver.carReference package:taxi_app/…/models/driver.dart:29 #4 Driver.carReference package:taxi_app/…/models/driver.dart:29 ... ════════════════════════════════════════════════════════════════════════════════ Reloaded 1 of 2190 libraries in 2 987ms.
我发现问题出在这里:
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('vehicule model'),
],
),
Text(widget.fullData.driver.carReference != null ? widget.fullData.driver.carReference.toString() : '', style: TextStyle(color: ThemeUtils.bluePlus,fontSize: 18)), //
],
),
),
但我发现当我尝试更改文本时:
Text(widget.fullData.driver.carReference != null ? widget.fullData.driver.carReference.toString() : '', style: TextStyle(color: ThemeUtils.bluePlus,fontSize: 18)),
有效:
我的模特:
@override
Driver clone(Map<String, dynamic> map) => Driver()..fromJson(map);
static const String carNameKey = 'carName';
static const String carReferenceKey = 'carReference';
static const String carSerieKey = 'carSerie';
static const String carImageKey = 'carImage';
String get carName => get<String>(carNameKey);
String get carReference => get<String>(carReference);
String get carSerie => get<String>(carSerie);
ParseFile get carImage => get<ParseFile>(carImageKey);
set carName(String value) => set<String>(carNameKey, value);
set carReference(String value) => set<String>(carReferenceKey, value);
set carSerie(String value) => set<String>(carSerieKey, value);
set carImage(ParseFile value) => set<ParseFile>(carImageKey, value);
解决方法是将我的setter修改为
String get carReference => get<String>(carReferenceKey);
String get carSerie => get<String>(carSerieKey);