Card(
semanticContainer: true,
clipBehavior: Clip.antiAliasWithSaveLayer,
child: Image.network( 'https://placeimg.com/640/480/any',fit: BoxFit.fill),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
elevation: 5,
margin: EdgeInsets.all(10),
)
Run Code Online (Sandbox Code Playgroud) 我希望我的容器根据其内容(在本例中为文本)具有不同的大小,如果一个用户写入较长的文本,则容器会更大,如果另一个用户写入较短的文本,则容器会较小。
是否可以?如果没有,还有其他方法吗?
谢谢
我遇到了 GestureDeector 的 onTap 事件问题。我也尝试过卡但不起作用。当我点击 SizeBox 时没有任何反应。
GestureDetector(
onTap: () => GoToPage(),
child: SizedBox(
child: Card(
child: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
Image.asset(
"assets/png/icon2.png",
width: 64.0,
),
...
Run Code Online (Sandbox Code Playgroud)
谢谢。
flutter flutter-test flutter-layout flutter-widget flutter-card
我正在尝试构建一个列中的页面视图。页面视图将包含卡片。我希望页面视图的大小能够根据其内容(即卡片)动态变化,但我无法实现这一点。显然,卡中的列占用的空间超出了所需的空间。我已经和 flutter 检查员检查过,但我不明白为什么。任何帮助,将不胜感激。这是代码。
import 'package:cricket_app/util/colors.dart';
import 'package:flutter/material.dart';
import 'package:page_view_indicators/circle_page_indicator.dart';
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
PageController _controller = PageController(
initialPage: 0,
);
final _currentPageNotifier = ValueNotifier<int>(0);
final double _cardHeight = 200.0;
final double _teamIconSize = 50.0;
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: primaryColor,
elevation: 0,
// flexibleSpace: Container(
// decoration: BoxDecoration(
// gradient: LinearGradient(
// begin: Alignment.topLeft,
// end: …Run Code Online (Sandbox Code Playgroud) 我对 Flutter 还很陌生,正在尝试制作一个简单的应用程序,在其中使用 API 获取数据并尝试显示结果。
这个函数负责获取数据(这个函数工作正常,我获取数据):
Connection connection = Connection();
String textValue = '';
Future<void> createlist() async {
List<MoviesByTitle> movieTitle = [];
String response = await connection.getMovieByTitle();
var data = jsonDecode(response);
var results = data['results'];
for (int i = 0; i < results.length; i++) {
movieTitle.add(
MoviesByTitle(
movieId: results[i]['id'],
title: results[i]['original_title'],
shortDescription: results[i]['overview'],
year: results[i]['release_date'],
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
屏幕本身来了:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Movies app"),
),
body: Column(
children: [
TextField(
decoration: const …Run Code Online (Sandbox Code Playgroud)