我收到以下错误:
即,抛出了另一个异常:ParentDataWidget 的错误使用。在手机屏幕上显示错误。
@override
Widget build(BuildContext context) {
return MaterialApp(
title: widget.title,
theme: ThemeData.light().copyWith(
platform: _platform ?? Theme.of(context).platform,
),
home: DefaultTabController(
length: categoryNames.length,
child: Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: SafeArea(
child: Column(
children: <Widget>[
Chewie(
controller: _chewieController,
),
TabBar(
labelColor:Colors.black,
tabs: categoryNames,
),
Expanded(
child: TabBarView(
children: [
ImageList()
],
),
)
/*TabBarView(
children: [
Icon(Icons.directions_car),
Icon(Icons.directions_transit),
Icon(Icons.directions_bike),
],
)*/
],
)
),
),
),
);
}
Run Code Online (Sandbox Code Playgroud)
这是我的代码,请检查并让我知道问题。
我试图从 API 中获取一个列表,它是两种方法 fetchImages 和 fetchCategories。第一次显示红屏错误,然后在 2 秒后自动加载列表。你能告诉我我的代码有什么问题以及如何避免在我的应用程序中显示红屏错误吗?
Widget build(context) {
try{
if (isFirst == true) {
fetchImage();
fetchCategories(context);
isFirst = false;
}
}catch(Exception){
}
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
title: Text('Lets see images!'),
),
body: new Column(
children: <Widget>[
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new InkResponse(
child: new Column(
children: <Widget>[
Padding(
padding: EdgeInsets.all(10.0),
child: new Image.asset(
catimages[0],
width: 60.0,
height: 60.0,
),
),
new Text(
categoriesText[0],
style: TextStyle(color: Colors.white),
),
],
),
onTap: () …Run Code Online (Sandbox Code Playgroud) 我通过使用dio来传递表单数据并获得响应,但我无法将数据存储到对象。请帮助我它在打印 response.data 时给出响应,但我不知道如何存储对对象的响应。
class MainActivityGrid extends StatefulWidget {
@override
_MainActivityGridState createState() => _MainActivityGridState();
}
class _MainActivityGridState extends State<MainActivityGrid> {
// List<ImageModel>images= [];
@override
Widget build(BuildContext context) {
return MaterialApp(
home: new Scaffold(
appBar: AppBar(
title: new Text("IPTV"),
),
body: new Center(
child: new RaisedButton(
child: new Text("Button"), onPressed: fetchImage),
),
),
);
}
Future<String> fetchImage() async {
String url = "http://xxxxxx:xxx/onnet_api/mediaList.php";
Response response;
Dio dio = new Dio();
FormData formData = new FormData.from(
{"publisherid": 102, "tag": "media", "subtag": …Run Code Online (Sandbox Code Playgroud) 以下是我的屏幕,我正在尝试获取
body: SafeArea(
child: Column(
children: <Widget>[
Expanded(child:
Chewie(
controller: _chewieController,
)
),
TabBar(
labelColor:Colors.black,
tabs: categoryNames,
),
Expanded(
child:TabBarView(
children: [
ImageList()
],
),
),
],
)
),
),
Run Code Online (Sandbox Code Playgroud)
但是我不知道如何将屏幕分成多个部分并为其添加小部件。请帮我解决一下这个。
上面是到目前为止我尝试过的代码。
class ImageList extends StatelessWidget {
final List<SubContentsDatum>images = [];
//ImageModel data = new ImageModel();
//ImageList();
Widget build(context) {
fetchSubCategoryContentlist(context, 20);
print('iamgelist:$images');
print('imagelistlengthimages:${images.length}');
return Expanded(
child: GridView.count(
shrinkWrap: true,
childAspectRatio: 2,
scrollDirection: Axis.vertical,
crossAxisCount: 2,
children: new List<Widget>.generate(images.length, (index) {
return buildImage(images[index], context, index);
},
).toList(),
),
);
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用图像选择器,但我无法获取。每当我调用 Imagepicker 时,它都会显示错误,因为在通道 plugins.flutter.io/image_picker 上找不到方法 pickImage 的实现。请让我知道这个问题。
我更新了我的问题并添加了 pubspec.yaml
name: demo_flutter
description: A new Flutter application.
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
video_player: ^0.5.2
image_picker: ^0.5.0+1
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# …Run Code Online (Sandbox Code Playgroud)