我可以添加第二个浮动操作按钮作为缺口吗?我制作了一个图像来显示我想要的东西。
PS:我尝试了一些方法(包装堆栈或行小部件等,但结果是;
而且我也需要我的底部栏按钮,我发现浮动按钮总是覆盖它的方法。
我目前的代码是:
import 'package:flutter/cupertino.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
appBar: AppBar(
title: Text('Welcome to Flutter'),
),
body: Center(
child: Text('Hello World'),
),
bottomNavigationBar: Container(
height: 50,
child: BottomAppBar(
color: Colors.black,
shape: CircularNotchedRectangle(),
clipBehavior: Clip.antiAlias,
child: RaisedButton(onPressed: () {},
child: new Text('Details',
style: TextStyle(fontSize: 16.0),
),
),
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
floatingActionButton: new FloatingActionButton(
child: Icon(Icons.home, …Run Code Online (Sandbox Code Playgroud) 我有一个应用程序,它使用来自 api 后端的随机数据,并且有一个浮动操作按钮来将当前数据添加到收藏夹,当我单击收藏夹按钮时,图标需要根据 bool 值进行更改(它在我的中名为 Recorded())例如),但我只能使用 setState(重建页面)来做到这一点,但这次整个页面的数据正在改变,因为我的 api 答案是随机的,具有相同的 url,我的意思是每当我添加或删除当前数据时,页面都会重新加载另一个随机数据数据,我需要绕过此数据重新加载(我的示例中的 getData() 部分)并刷新我最喜欢的按钮的图标,有什么方法可以做到这一点,我尝试使用另一个 FutureBuilder 作为 floataction 按钮,并仅使用 setState 记录() 但结果还是一样?
我的构建树是这样的:
@override
Widget build(BuildContext context) {
return Material(
child: FutureBuilder<Payload>(
future: getData(_name),
builder: (context, snapshot) {
Future<bool> recorded()async {
var checkFavs = await favoriteDao.findRecordById(snapshot.data.id);
return checkFavs == null ? Future<bool>.value(true) : Future<bool>.value(false);
}
if (snapshot.connectionState != ConnectionState.done && firstRun == true)
return Center(child: Image.asset("images/dice.gif"));
if (snapshot.connectionState == ConnectionState.done)
if (snapshot.hasError)
{
return Scaffold(...) // error page
}
return Scaffold(..
....
.... …Run Code Online (Sandbox Code Playgroud)