我已经创建了一个社交媒体应用程序,现在我正在尝试自定义我的应用程序,我添加了一个搜索、聊天图标,我希望搜索图标路由到Search
应用程序中存在的页面。我实现MaterialPageRoute
了,但它只返回一个黑屏(带有细的绿色边框)。
调试控制台中没有错误或日志
Flutter 医生报告
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel dev, 1.24.0-10.2.pre, on Microsoft Windows [Version 10.0.19041.630], locale en-GB)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[√] Android Studio (version 4.1.0)
[√] VS Code (version 1.51.1)
[√] Connected device (1 available)
• No issues found
标题小部件代码:现在我正在尝试将路线添加到Icon(Icons.search),
图标
import 'package:flutter/material.dart';
import 'package:findemed/pages/search.dart';
class Search extends StatefulWidget {
@override
__SearchState createState() => __SearchState();
}
class __SearchState extends State<Search> {
Future<List> users;
@override
Widget build(BuildContext context) {
return Container();
}
}
AppBar header(context,
{bool isAppTitle = false,
String titleText,
removeBackButton = false}) {
return AppBar(
//APPBAR CODE WITH ICONS
automaticallyImplyLeading: removeBackButton ? false : true,
title:
Text(isAppTitle ? "FindeMed" : titleText),
leading: GestureDetector(
onTap: () {/* Write listener code here */},
child: Icon(
Icons.menu, // add custom icons also
),
),
actions: <Widget>[
Padding(
padding: EdgeInsets.only(right: 20.0),
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Search()
),
);
},
child: Icon(
Icons.search,
size: 25.0,
),
)),
Padding(
padding: EdgeInsets.only(right: 20.0),
child: GestureDetector(
onTap: () {},
child: Icon(
Icons.chat_bubble_outline,
size: 20.0,
),
)),
Padding(
padding: EdgeInsets.only(right: 20.0),
child: GestureDetector(
onTap: () {},
child: Icon(Icons.notifications),
)),
],
);
}