【发布时间】:2021-01-24 15:56:26
【问题描述】:
我已经制作了一个我想用于导航的自定义按钮,我已经设置了它,以便您可以将它作为一个小部件调用,并为它提供一个标题和一个应该引导的路径,但它没有似乎接受路径作为给出错误的字符串。
class NavigationButton extends StatelessWidget {
NavigationButton({@required this.path, @required this.btnTitle});
final String path;
final String btnTitle;
@override
Widget build(BuildContext context) {
return BouncingWidget(
duration: Duration(milliseconds: 50),
scaleFactor: 1.5,
child: GestureDetector(
onTap: () {
Navigator.of(context)
.pushReplacementNamed(path);
},
child: Container(
margin: const EdgeInsets.only(left: 10.0 , right: 10.0 , top : 5.0 , bottom: 5.0 ),
constraints: BoxConstraints.expand(),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/home-btn.png"),
fit: BoxFit.fill)),
child: Center(
child: Text(
this.btnTitle,
style: TextStyle(color: Colors.white, fontSize: 20.0),
),
)
),
)
);
}
}
然后我试着这样称呼它
NavigationButton(
path: "(context, /gjuhaime)",
btnTitle: "Gjuha ime"
),
但我不断收到此错误 在 _WidgetsAppState 中找不到路由 RouteSettings("/gjuhaime", null) 的生成器。
【问题讨论】:
标签: java android flutter dart mobile