From 5572c8bc62bdf736c240df097035eebe588e89ce Mon Sep 17 00:00:00 2001 From: bluesea <307723040@qq.com> Date: Sat, 11 May 2024 16:24:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=86=E5=A4=87=E9=A1=B6=E9=83=A8=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/pages/homepage/homepage_view.dart | 73 +++++++++++++++---- 1 file changed, 60 insertions(+), 13 deletions(-) diff --git a/wallpaper/lib/pages/homepage/homepage_view.dart b/wallpaper/lib/pages/homepage/homepage_view.dart index 7fe2c37..7444d9e 100644 --- a/wallpaper/lib/pages/homepage/homepage_view.dart +++ b/wallpaper/lib/pages/homepage/homepage_view.dart @@ -1,3 +1,4 @@ +// ignore_for_file: dead_code import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:transparent_image/transparent_image.dart'; @@ -8,6 +9,8 @@ class HomePageView extends GetView { @override Widget build(BuildContext context) { const title = "壁纸"; + final ListView headerView = getHeaderWidget(); + final GridView bodyView = getBodyWidget(); return MaterialApp( title: title, @@ -15,21 +18,65 @@ class HomePageView extends GetView { appBar: AppBar( title: const Text(title), ), - body: GridView.count( - // Create a grid with 2 columns. If you change the scrollDirection to - // horizontal, this produces 2 rows. - crossAxisCount: 2, - // Generate 100 widgets that display their index in the List. - children: List.generate(100, (index) { - return Center( - child: FadeInImage.memoryNetwork( - placeholder: kTransparentImage, - image: 'https://picsum.photos/250?image=9', - ), - ); - }), + body: Row( + children: [ + SizedBox( + width: 400, + height: 40, + child: headerView, + ), + // bodyView, + ], ), ), ); } + + //返回内容 + GridView getBodyWidget(){ + return GridView.count( + // Create a grid with 2 columns. If you change the scrollDirection to + // horizontal, this produces 2 rows. + crossAxisCount: 2, + // Generate 100 widgets that display their index in the List. + children: List.generate(100, (index) { + return Center( + child: FadeInImage.memoryNetwork( + placeholder: kTransparentImage, + image: 'https://picsum.photos/250?image=9', + ), + ); + }), + ); + } + + //初始化顶部数据 + ListView getHeaderWidget(){ + return ListView( + scrollDirection: Axis.horizontal, + children: [ + Container( + width: 160, + color: Colors.red, + ), + Container( + width: 160, + color: Colors.blue, + ), + Container( + width: 160, + color: Colors.green, + ), + Container( + width: 160, + color: Colors.yellow, + ), + Container( + width: 160, + color: Colors.orange, + ), + ], + ); + } + } \ No newline at end of file