准备header

This commit is contained in:
bluesea 2024-05-11 16:41:58 +08:00
parent 5572c8bc62
commit 3983d553a9

View File

@ -1,4 +1,6 @@
// ignore_for_file: dead_code // ignore_for_file: dead_code
// import 'dart:js';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:transparent_image/transparent_image.dart'; import 'package:transparent_image/transparent_image.dart';
@ -9,7 +11,7 @@ class HomePageView extends GetView {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
const title = "壁纸"; const title = "壁纸";
final ListView headerView = getHeaderWidget(); final SizedBox headerView = getHeaderWidget(context);
final GridView bodyView = getBodyWidget(); final GridView bodyView = getBodyWidget();
return MaterialApp( return MaterialApp(
@ -20,11 +22,7 @@ class HomePageView extends GetView {
), ),
body: Row( body: Row(
children: [ children: [
SizedBox( headerView,
width: 400,
height: 40,
child: headerView,
),
// bodyView, // bodyView,
], ],
), ),
@ -51,32 +49,40 @@ class HomePageView extends GetView {
} }
// //
ListView getHeaderWidget(){ SizedBox getHeaderWidget(BuildContext context){
return ListView( final size = MediaQuery.of(context).size;
final cw = 80.0;
return SizedBox(
width: size.width,
height: 40,
child: ListView(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
children: <Widget>[ children: <Widget>[
Container( Container(
width: 160, width: cw,
color: Colors.red, color: Colors.red,
), ),
Container( Container(
width: 160, width: cw,
color: Colors.blue, color: Colors.blue,
), ),
Container( Container(
width: 160, width: cw,
color: Colors.green, color: Colors.green,
), ),
Container( Container(
width: 160, width: cw,
color: Colors.yellow, color: Colors.yellow,
), ),
Container( Container(
width: 160, width: cw,
color: Colors.orange, color: Colors.orange,
), ),
], ],
),
); );
} }
} }