文本字段在构建屏幕时会导致无休止的重复错误 颤振网.



我在导航到的屏幕中包含文本字段时遇到奇怪的错误。 从ProductsScreen我有一个按钮,可以在将ProductBloc传递给它时按下NewEditProductScreen。通常Navigator.push我用来将 bloc 传递到下一个屏幕的方式..

onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) =>
BlocProvider.value(
value: BlocProvider.of<
ProductBloc>(context),
child: NewEditProductScreen(
type: 'New',
user: widget.user,
cityDb: widget.cityDb,
regionDb: widget.regionDb,
countryDb:
widget.countryDb),
),
),
);
}

出于某种原因,将 Textfield 放入NewEditProductScreen会引发无限系列的错误,但由于最后一个状态打印是正确的,我想问题不在于集团本身,事实上,如果我将它们注释掉,就不会再有错误了。 该应用程序将在网络和设备上运行,因此要显示正确的文本字段,我使用与在另一个屏幕(设置为此屏幕(中使用的三元组相同的三元,并且我在那里没有问题。

你能发现我在这个屏幕上做错了什么吗?非常感谢。

class NewEditProductScreen extends StatefulWidget {
final FixitUser user;
final String cityDb;
final String regionDb;
final String countryDb;
final String type;
final Product product;
const NewEditProductScreen(
{Key key,
this.type,
this.product,
this.user,
this.cityDb,
this.regionDb,
this.countryDb})
: super(key: key);
@override
_NewEditProductScreenState createState() => _NewEditProductScreenState();
}
class _NewEditProductScreenState extends State<NewEditProductScreen> {
AutoSizeGroup autoSizeGroup = AutoSizeGroup();
TextEditingController idController = TextEditingController();
String productId = '';
String productName = '';
String brand = '';
String price = '';
String productDescription = '';
String category = '';
bool isPromotion = false;
String vendor = '';
String barcode = '';
String imageUrl = '';
Image productImage;
//  Uint8List imageData;
int minimumStock = 0;
int availableQuantity = 0;
int soldQuantity = 0;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
//    return BlocProvider<ProductBloc>(
//      create: (context) => ProductBloc(),
//      lazy: false,
//      child: BlocBuilder<ProductBloc, ProductState>(
return BlocBuilder<ProductBloc, ProductState>(
builder: (context, state) => MultiBlocListener(
listeners: [
BlocListener<ProductBloc, ProductState>(
listener: (BuildContext context, ProductState state) {
if (state is PickedImage) {
setState(() {
//                productImage = Image.memory(state.imageData);
//                imageData = state.imageData;
});
}
if (state is ProductSaved) {
Navigator.pop(context);
}
}),
],
child: Scaffold(
body: Container(
color: Colors.black54,
//          key: widget.key,
padding: EdgeInsets.symmetric(horizontal: 100, vertical: 50),
child: Container(
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(5),
border: Border.all(color: Colors.redAccent, width: 2),
),
padding: EdgeInsets.all(20),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
//              Expanded(
//                child: productImage,
//              ),
SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
AutoSizeText(
AppLocalizations.instance.text('Product id'),
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.w500),
minFontSize: 8,
maxLines: 1,
group: autoSizeGroup,
),
UniversalPlatform.isWeb
? TextField(
readOnly: true,
keyboardType: TextInputType.numberWithOptions(),
textDirection: TextDirection.ltr,
autofocus: true,
controller: idController,
onChanged: (value) {
idController.text = value;
},
)
: UniversalPlatform.isIOS
? CupertinoTextField(
readOnly: true,
keyboardType:
TextInputType.numberWithOptions(),
controller: idController,
onChanged: (value) {
idController.text = value;
},
)
: TextField(
readOnly: true,
keyboardType:
TextInputType.numberWithOptions(),
textDirection: TextDirection.ltr,
autofocus: true,
controller: idController,
onChanged: (value) {
idController.text = value;
},
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
FlatButton(
color: Colors.orangeAccent,
child: AutoSizeText(
AppLocalizations.instance.text('Cancel'),
style: TextStyle(fontSize: 30, color: Colors.white),
minFontSize: 8,
maxLines: 1,
group: autoSizeGroup,
),
onPressed: () {
Navigator.pop(context);
}),
],
)
],
),
),
),
),
),
//      ),
);
}
@override
void dispose() {
idController.dispose();
super.dispose();
}
}

这是来自Chrome控制台的无限重复错误:

BlocTransaction is Transition { currentState: Instance of 'minified:RS', event: LoadOrders {user: User { displayName: zazza zenigata, email: zazza.zenigata.1976@gmail.com, phone number:, uid: eT9FWzlOgYfAIHZNh3bd28Ay4x32, photoUrl: https://lh3.googleusercontent.com/-8UmwYDOTbQg/AAAAAAAAAAI/AAAAAAAAAAA/AAKWJJOuSPI6gPocRgQMP_kIUFaFdTT_LA/s96-c/photo.jpg}}, nextState: LoadedProducts{ number of products: 0} }
2js_primitives.dart:49 Another exception was thrown: Instance of 'minified:bj<void>'
js_primitives.dart:49 Attempted to build a minified:XI, but it already has an HTML element FLT-OFFSET.
js_primitives.dart:49 Throw of null.
at Object.f (http://localhost:5000/main.dart.js:1788:3)
at XI.bT (http://localhost:5000/main.dart.js:21735:26)
at XI.bT (http://localhost:5000/main.dart.js:21771:6)
at XK.bT (http://localhost:5000/main.dart.js:21778:8)
at XK.bT (http://localhost:5000/main.dart.js:21778:8)
at XI.bT (http://localhost:5000/main.dart.js:21778:8)
at XI.bT (http://localhost:5000/main.dart.js:21778:8)
at XK.bT (http://localhost:5000/main.dart.js:21778:8)
at XI.bT (http://localhost:5000/main.dart.js:21778:8)
at XI.bT (http://localhost:5000/main.dart.js:21778:8)
js_primitives.dart:49 Attempted to build a minified:XI, but it already has an HTML element FLT-OFFSET.
js_primitives.dart:49 Throw of null.
at Object.f (http://localhost:5000/main.dart.js:1788:3)
at XI.bT (http://localhost:5000/main.dart.js:21735:26)
at XI.bT (http://localhost:5000/main.dart.js:21771:6)
at XI.bT (http://localhost:5000/main.dart.js:21778:8)
at XK.bT (http://localhost:5000/main.dart.js:21778:8)
at XK.bT (http://localhost:5000/main.dart.js:21778:8)
at XI.bT (http://localhost:5000/main.dart.js:21778:8)
at XI.bT (http://localhost:5000/main.dart.js:21778:8)
at XK.bT (http://localhost:5000/main.dart.js:21778:8)
at XI.bT (http://localhost:5000/main.dart.js:21778:8)
js_primitives.dart:49 Attempted to build a minified:XI, but it already has an HTML element FLT-OFFSET.
js_primitives.dart:49 Throw of null.
at Object.f (http://localhost:5000/main.dart.js:1788:3)
at XI.bT (http://localhost:5000/main.dart.js:21735:26)
at XI.bT (http://localhost:5000/main.dart.js:21771:6)
at XI.bT (http://localhost:5000/main.dart.js:21778:8)
at XI.bT (http://localhost:5000/main.dart.js:21778:8)
at XK.bT (http://localhost:5000/main.dart.js:21778:8)
at XK.bT (http://localhost:5000/main.dart.js:21778:8)
at XI.bT (http://localhost:5000/main.dart.js:21778:8)
at XI.bT (http://localhost:5000/main.dart.js:21778:8)
at XK.bT (http://localhost:5000/main.dart.js:21778:8)
js_primitives.dart:49 Attempted to build a minified:XN, but it already has an HTML element FLT-PICTURE.
js_primitives.dart:49 Throw of null.
at Object.f (http://localhost:5000/main.dart.js:1788:3)
at XN.bT (http://localhost:5000/main.dart.js:21735:26)
at XN.bT (http://localhost:5000/main.dart.js:21628:6)
at XI.bT (http://localhost:5000/main.dart.js:21778:8)
at XK.bT (http://localhost:5000/main.dart.js:21778:8)
at XK.bT (http://localhost:5000/main.dart.js:21778:8)
at XI.bT (http://localhost:5000/main.dart.js:21778:8)
at XI.bT (http://localhost:5000/main.dart.js:21778:8)
at XK.bT (http://localhost:5000/main.dart.js:21778:8)
at XI.bT (http://localhost:5000/main.dart.js:21778:8)

发现问题。它没有包装在扩展的小部件中。现在一切都在工作..

相关内容

  • 没有找到相关文章

最新更新