【发布时间】:2021-11-26 20:26:08
【问题描述】:
我正在开发一个报价应用程序作为颤振的初学者。我的应用程序中有多个页面。现在我想创建一个图标按钮,它将作为用户的书签(标记为 fabourite)。所以我添加了我的应用程序中的颤振 fabourite 按钮。最初它保持白色,当我触摸它时,它变成红色,这是我想要的。但是当我移动到另一个页面并返回上一个页面(添加了 fabourite 图标的位置)按钮变成白色...我希望它保持红色,除非用户再次触摸它。我只想将它用作标记为 fabourite 的图标...我现在该怎么办?
class p1 extends StatefulWidget {
@override
_p1State createState() => _p1State();
}
class _p1State extends State<p1> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body:Stack(
children:<Widget>[
Image(
image:AssetImage("Image/Chowsun1.jpg"),
fit:BoxFit.cover,
width: double.infinity,
height: double.infinity,
),
Align(alignment: Alignment.center,
child: Text(' Hello world '
,style: TextStyle(fontSize: 35.0,
color: Colors.white,
fontFamily: "Explora",
fontWeight: FontWeight.w900 ) )
),
Align(
alignment: Alignment.bottomLeft,
child: const Text(' 1 ',
style: TextStyle(
fontSize: 25.0,
fontFamily: "MonteCarlo",
color: Colors.white,
fontWeight: FontWeight.w900),
),
),
Align(
alignment: Alignment.bottomCenter,
child: FavoriteButton(
isFavorite: true,
iconSize: 40,
iconDisabledColor: Colors.red,
iconColor: Colors.white,
// iconDisabledColor: Colors.white,
valueChanged: (_isFavorite) {},
)
)])
),
);
}
}
【问题讨论】:
-
能否指定数据的存储方式?
-
兄弟我是初学者...我只能说它只是存储在本地数据库中...我没有使用 firestore