【发布时间】:2018-10-16 12:55:56
【问题描述】:
如何使 Stylish 下拉并从该下拉列表中获取数据并将其显示为文本。我怎样才能完成这项任务?这是我的代码,我在其中制作了一个旋转瓶游戏的颤振应用程序。我已经在其中做了一个下拉菜单,但是,如何获取它的值并在屏幕上打印为文本:
import 'package:flutter/material.dart';
import 'dart:math';
List<DropdownMenuItem<String>> listDrop = [];
loadData() {
listDrop = [];
listDrop.add(new DropdownMenuItem(
child: new Text('Item 1'),
value: "1",
));
listDrop.add(new DropdownMenuItem(
child: new Text('Item 2'),
value: "2",
));
listDrop.add(new DropdownMenuItem(
child: new Text('Item 3'),
value: "3",
));
}
class ImageRotate extends StatefulWidget {
@override
_ImageRotateState createState() => new _ImageRotateState();
}
class _ImageRotateState extends State<ImageRotate>
with SingleTickerProviderStateMixin {
AnimationController animationController;
static var rng = new Random();
double random_number = 0.0;
);
} }
new Container(
alignment: Alignment.centerRight,
padding: new EdgeInsets.only(top: 200.0, right: 100.0),
child: new DropdownButton(
style: new TextStyle(
color: Colors.redAccent,
fontWeight: FontWeight.bold,
),
items: listDrop,
hint: new Text(
"Select"
),
onChanged: loadData(),
),
),
【问题讨论】:
标签: android dart flutter flutter-layout