我正在尝试创建一个CustomFutureBuilder
。我想将targetItem
传递给snapshot.data
,当我打电话时,它会从大小写变为另一个。我试图将它们串联起来,但没有用,请在下面查看我的附加代码:
import 'package:flutter/material.dart';
class CustomFutureBuilder extends StatelessWidget {
final BuildContext context;
final Future future;
final Widget returnedWidget;
final bool enableLoading;
final Widget loadingWidget;
final String loadingMessage;
final String targetItem;
CustomFutureBuilder(
{this.context,
this.future,
this.returnedWidget,
this.enableLoading = true,
this.loadingWidget,
this.loadingMessage,
this.targetItem,
});
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: this.future,
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
case ConnectionState.waiting:
return Center(child: CircularProgressIndicator());
default:
return Text(snapshot.data.targetItem);
}
});
}
}