Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振布局错误:在选项卡式内容中使用webview_Flutter_Webview_Uitabcontroller - Fatal编程技术网

Flutter 颤振布局错误:在选项卡式内容中使用webview

Flutter 颤振布局错误:在选项卡式内容中使用webview,flutter,webview,uitabcontroller,Flutter,Webview,Uitabcontroller,我是新来的flifter,看了两个教程,一个是关于创建选项卡式应用程序的,另一个是关于webview的。不幸的是,我无法让他们一起工作。我得到一个布局错误 这是我的密码: import 'dart:io'; import 'package:flutter/material.dart'; import 'package:webview_flutter/webview_flutter.dart'; void main() => runApp(MyApp()); class MyApp e

我是新来的flifter,看了两个教程,一个是关于创建选项卡式应用程序的,另一个是关于webview的。不幸的是,我无法让他们一起工作。我得到一个布局错误

这是我的密码:

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: DefaultTabController(
        length: choices.length,
        child: Scaffold(
          appBar: AppBar(
            title: const Text('Hydra Sense Control'),
            bottom: TabBar(
              isScrollable: true,
              tabs: choices.map<Widget>((Choice choice) {
                return Tab(
                  text: choice.title,
                  icon: Icon(choice.icon),
                );
              }).toList(),
            ),
          ),
          body: TabBarView(
            children: choices.map((Choice choice) {
              return Padding(
                padding: const EdgeInsets.all(20.0),
                child: ChoicePage(
                  choice: choice,
                ),
              );
            }).toList(),
          ),
        ),
      ),
    );
  }
}

class Choice {
  final String title;
  final IconData icon;
  final String link;
  const Choice({this.title, this.icon, this.link});
}

const List<Choice> choices = <Choice>[
  Choice(
      title: 'DuetWebControl',
      icon: Icons.settings,
      link: 'https://google.com'),
  Choice(title: 'Cameras', icon: Icons.videocam, link: 'https://yahoo.com'),
  Choice(
      title: 'Thingiverse',
      icon: Icons.cloud_download,
      link: 'https://thingiverse.com'),
  Choice(
      title: 'HevORT Forums',
      icon: Icons.description,
      link: 'https://forums.hevort.com'),
  Choice(title: 'About Hydra', icon: Icons.info, link: 'https://youtube.com'),
];

class ChoicePage extends StatelessWidget {
  const ChoicePage({Key key, this.choice}) : super(key: key);
  final Choice choice;

  @override
  Widget build(BuildContext context) {
    final TextStyle textStyle = Theme.of(context).textTheme.headline4;
    return Card(
      color: Colors.white,
      child: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Icon(
              choice.icon,
              size: 150.0,
              color: textStyle.color,
            ),
            Text(
              choice.title,
              style: textStyle,
            ),
            WebView(
                initialUrl: choice.link,
                javascriptMode: JavascriptMode.unrestricted)
          ],
        ),
      ),
    );
  }
}
导入'dart:io';
进口“包装:颤振/材料.省道”;
导入“package:webview_flatter/webview_flatter.dart”;
void main()=>runApp(MyApp());
类MyApp扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回材料PP(
debugShowCheckedModeBanner:false,
主页:DefaultTabController(
长度:选择。长度,
孩子:脚手架(
appBar:appBar(
标题:常量文本(“Hydra Sense Control”),
底部:选项卡栏(
isScrollable:是的,
选项卡:选项.map((选项){
返回选项卡(
text:choice.title,
图标:图标(choice.icon),
);
}).toList(),
),
),
正文:选项卡视图(
子项:choices.map((Choice-Choice){
返回填充(
填充:常数边集全部(20.0),
孩子:唱诗班(
选择:选择,,
),
);
}).toList(),
),
),
),
);
}
}
班级选择{
最后的字符串标题;
最终的Iconda图标;
最后的字符串链接;
常量选项({this.title,this.icon,this.link});
}
常量列表选项=[
选择(
标题:“DuetWebControl”,
图标:Icons.settings,
链接:'https://google.com'),
选择(标题:“摄像机”,图标:Icons.videocam,链接:'https://yahoo.com'),
选择(
标题:“Thingiverse”,
icon:Icons.cloud_下载,
链接:'https://thingiverse.com'),
选择(
标题:“HevORT论坛”,
图标:Icons.description,
链接:'https://forums.hevort.com'),
选择(标题:“关于Hydra”,图标:Icons.info,链接:'https://youtube.com'),
];
类ChoicePage扩展了无状态小部件{
const ChoicePage({Key-Key,this.choice}):super(Key:Key);
最终选择;
@凌驾
小部件构建(构建上下文){
final TextStyle TextStyle=Theme.of(context).textTheme.headline4;
回程卡(
颜色:颜色,白色,
儿童:中心(
子:列(
mainAxisSize:mainAxisSize.min,
crossAxisAlignment:crossAxisAlignment.center,
儿童:[
图标(
choice.icon,
尺寸:150.0,
颜色:textStyle.color,
),
正文(
选择题,
风格:textStyle,
),
网络视图(
initialUrl:choice.link,
javascriptMode:javascriptMode.unrestricted)
],
),
),
);
}
}
此外,我还想添加一些功能来刷新页面或像在ios中一样来回移动。向左轻扫可返回,向右轻扫可前进,向下轻扫可刷新


只是一个noob试图制作一个小应用程序。

为了防止出现这种错误,您可以简单地将该WebView包装在扩展的小部件中,如下所示:

Expanded(
              child: WebView(
                  initialUrl: choice.link,
                  javascriptMode: JavascriptMode.unrestricted),
            )

顺便说一下,确切的错误是:在布局过程中,RenderUiKitView对象的大小是无限的。