当我运行我的flutter应用程序时,它会显示"等待另一个flutter命令释放启动锁..."这条消息并没有继续进行.
我有两个容器,两个容器都有GestureDetector。第一个容器的OnTap工作正常,但不能与另一个容器一起使用。第一个容器是图像,第二个容器是部分在第一个容器上对齐的绿色背景。
new Stack(
alignment: Alignment(0.0, 1.44),
children: <Widget>[
GestureDetector(
onTap: () => _openImage(context),
child: Container(
width: 340.0,
foregroundDecoration: new BoxDecoration(
color: Color.fromRGBO(155, 85, 250, 0.55)),
height: 240.0,
child: FadeInImage.assetNetwork(
placeholder: 'assets/dimlight.png',
image: post.imageUrl,
fit: BoxFit.cover,
),
),
),
new GestureDetector(
child: new Container(
color: Colors.green,
child: Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
SizedBox(width: 7.0),
CircleAvatar(
backgroundImage:
new AssetImage("assets/boy.png")
radius: 30.0,
),
SizedBox(
width: 7.0,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new SizedBox(
height: 20.0,
),
Text(
post.user.name,
style: TextStyle(fontWeight: FontWeight.bold),
), …
Run Code Online (Sandbox Code Playgroud) 我试图从对话框返回一个布尔值,但我不明白为什么该值没有根据需要返回。我尝试返回作为未来值,并在弹出对话框后将值与上下文一起返回。
final bool delete = await _showDialog();
print(delete);
Future<bool> _showDialog() {
bool result;
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Delete Appointment'),
content: Text(
'Are you sure? \nThis action cannot undo.',
style: TextStyle(
color: Colors.red,
fontSize: 20
),
),
actions: <Widget>[
FlatButton(
color: Colors.blue,
child: Text(
'CANCEL',
style: TextStyle(
color: Colors.white,
fontSize: 20
),
),
onPressed: () {
setState(() => result = false);
//print(result);
Navigator.pop(context, result);
return Future.value(result);
},
),
SizedBox(
width: 50,
),
FlatButton(
color: Colors.red, …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 flutter 中生成一个列表,它会在一些延迟后延迟每个项目。我尝试使用FutureBuilder
,AnimatedList
但我没有得到它。
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main(){
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Example(),
);
}
}
class Example extends StatefulWidget {
@override
_ExampleState createState() => new _ExampleState();
}
class _ExampleState extends State<Example> with TickerProviderStateMixin{
AnimationController listViewController;
final Animation listView;
Duration duration = new Duration(seconds: 3);
Timer _timer;
@override
void initState() {
listViewController = new AnimationController(
duration: new Duration(seconds: 2),
vsync: this
); …
Run Code Online (Sandbox Code Playgroud) @override
Widget build(BuildContext context) {
return Card(
elevation: 6,
margin: EdgeInsets.all(20),
child: Padding(
padding: EdgeInsets.all(10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: groupedTransactionValues.map((data) {
return Flexible(
fit: FlexFit.tight,
child: ChartBar(
data['day'],
data['amount'],
(data['amount'] as double) / totalSpending,
),
);
}).toList(),
),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)