Flutter 嗯?显示的动画与android native中的动画不同。@chitgoks这可能是因为Flatter使用了自己的组件,而不是android拥有的本机视图元素。因此,可以使用RotateBox将三个点显示在堆栈中。EJ:RotatedBox(四分之一圈:1
Flutter 嗯?显示的动画与android native中的动画不同。@chitgoks这可能是因为Flatter使用了自己的组件,而不是android拥有的本机视图元素。因此,可以使用RotateBox将三个点显示在堆栈中。EJ:RotatedBox(四分之一圈:1,flutter,dart,Flutter,Dart,嗯?显示的动画与android native中的动画不同。@chitgoks这可能是因为Flatter使用了自己的组件,而不是android拥有的本机视图元素。因此,可以使用RotateBox将三个点显示在堆栈中。EJ:RotatedBox(四分之一圈:1,子项:PopupMenuButton(…))关于RotatedBox-非常有用,谢谢。在目前的测试中,我发现它只对iOS是必要的。@Ondrej如果某些菜单选项有一些子菜单选项,如何使用它?非常感谢,这对我的问题非常有帮助 import 'p
嗯?显示的动画与android native中的动画不同。@chitgoks这可能是因为Flatter使用了自己的组件,而不是android拥有的本机视图元素。因此,可以使用RotateBox将三个点显示在堆栈中。EJ:RotatedBox(四分之一圈:1,子项:PopupMenuButton(…))关于
RotatedBox
-非常有用,谢谢。在目前的测试中,我发现它只对iOS是必要的。@Ondrej如果某些菜单选项有一些子菜单选项,如何使用它?非常感谢,这对我的问题非常有帮助
import 'package:flutter/material.dart';
import 'package:settings_button/Constants.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,)
,
home: new MyHomePage(title: 'Flutter Demo Home Page'),);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({
Key key, this.title
})
: super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
actions: <Widget>[
PopupMenuButton<String>(
onSelected: choiceAction,
itemBuilder: (BuildContext context){
return Constants.choices.map((String choice){
return PopupMenuItem<String>(
value: choice,
child: Text(choice),);
})
.toList();
}
,)]
,)
,
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(
'Body',)
,]
,)
,)
,);
}
void choiceAction(String choice){
if(choice == Constants.Settings){
print('Settings');
}
else if(choice == Constants.Subscribe){
print('Subscribe');
}
else if(choice == Constants.SignOut){
print('SignOut');
}
}
}
class Constants{
static const String fund = 'Fund';
// static const String Settings = 'Settings';
static const String SignOut = 'Sign out';
static const List<String> choices = <String>[
fund,`enter code here`
SignOut
];
}
appBar: AppBar(
title: Text('Homepage'),
actions: <Widget>[
PopupMenuButton<String>(
onSelected: handleClick,
itemBuilder: (BuildContext context) {
return {'Logout', 'Settings'}.map((String choice) {
return PopupMenuItem<String>(
value: choice,
child: Text(choice),
);
}).toList();
},
),
],
),
void handleClick(String value) {
switch (value) {
case 'Logout':
break;
case 'Settings':
break;
}
}
PopupMenuButton(onSelected: menuAction, itemBuilder: (BuildContext itemBuilder) => {'Opt 1', 'Opt 2'}.map((value) => PopupMenuItem(child: Text(value), value: value,)).toList())
void menuAction(String value) {
switch (value) {
case 'Opt 1':
print('Hello');
break;
}
}