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