我作為flutter的初學者,正在開發一個報價應用程式。我曾使用一個堆疊小部件在我的螢屏中央使用影像和文本。現在我想添加一個頁面視圖小部件,以滾動并登陸到下一頁。
class OverviewScreen extends StatefulWidget {
@override
_OverviewScreenState createState() => _OverviewScreenState();
}
class _OverviewScreenState extends State< OverviewScreen> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home:Scaffold(
extendBodyBehindAppBar: true。
appBar: AppBar(
標題。Text("Hu R Rehman",
風格。TextStyle(fontFamily: "MonteCarlo"),) 。
centerTitle: true。
領導。Icon(Icons.menu)。
shape: RoundedRectangleBorder(
borderRadius: borderRadius.vertical(底部。Radius.round(16)
),
backgroundColor: Colors.transparent,
仰角。0,
),
身體。
堆疊(
children:<Widget>[
影像(
image:AssetImage('Image/soc1.jpg'/span>)。
fit:BoxFit.cover。
width: double.infinity,
高度。double.infinity。
),
Align(alignment: Alignment.center,
孩子。Text(' This is my text '.
,樣式。TextStyle(fontSize: 30.0。
fontFamily:"MonteCarlo"。
color: Colors.white,
fontWeight: FontWeight.w700 ) )
)
],
)
),
);
}
}
uj5u.com熱心網友回復:
如果能解決你的問題,請查看這個:
class MyHomePage extends StatefulWidget{
const MyHomePage({Key? key,}) : super(key: key);
_MyHomePageState createState() => _MyHomePageState()。
}
class _MyHomePageState extends State< MyHomePage> {
final _pageController = PageController();
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
標題。Text('Title'),
),
body: 中心(
孩子。堆疊(
對齊。Alignment.center,
兒童。[
PageView(
控制器。_pageController,
children:[
Image(image: AssetImage('Location of your image'))。
/Add more Image Widgets。
]
),
const Text(
'Add you Text here',
),
],
),
),
);
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/313111.html
標籤:
上一篇:父級小部件沒有使用繼承來更新
