读取数据在面板上滑动,面板颤振



我在主类中使用了SlidingUpPanel。在主类中,我有一个底部表单,然后点击底部表单图标,加载页面。现在当我使用SlidingUpPanel时,我在正文中加载页面时遇到了问题。谁能帮助我如何在SlidingUpPanel的主体加载底部导航页面?

Widget build(BuildContext context) {
var pageWidth = MediaQuery.of(context).size.width;
return Scaffold(
body: SlidingUpPanel(
controller: _pc,
panelBuilder: (sc) {
if (!isCollapsed) _pc.hide();
return Container(
child: Center(child: Text("Panel")),
);
},
body: //here I want to load click bottom navigation page
),
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
onTap: (index) {
switch (index) {
case 0:
{
Navigator.pushReplacementNamed(context, '/'); 
break;
}
case 1:
{
Navigator.pushNamed(context, '/search');
break;
}
case 2:
{
Navigator.pushNamed(context, '/library');
break;
}
case 3:
{
Navigator.pushNamed(context, '/profile');
break;
}
}
},           
items[...]   
),
);
}
有谁能帮帮我吗?

尝试下面的代码,您可以根据BottomNavigationBar项单击

更改页面
import 'package:flutter/material.dart';
import 'package:sliding_up_panel/sliding_up_panel.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final widgets = [
Container(color: Colors.red),
Container(color: Colors.green),
Container(color: Colors.yellow),
];
int currentIndex = 0;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: SlidingUpPanel(
panel: Center(
child: Text("This is the sliding Widget"),
),
body: widgets[currentIndex],
),
bottomNavigationBar: BottomNavigationBar(
items: [
BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
BottomNavigationBarItem(
icon: Icon(Icons.settings), label: 'Settings'),
BottomNavigationBarItem(icon: Icon(Icons.person), label: 'About'),
],
currentIndex: currentIndex,
onTap: (index) {
setState(() {
currentIndex = index;
});
},
),
);
}
}