Listview aşşağı kaymıyor.

mail@pastecode.io avatar
unknown
dart
2 years ago
5.7 kB
6
Indexable
Never
import 'package:flutter/material.dart';

class RealHomePage extends StatefulWidget {
  const RealHomePage({super.key});
  static String kRealHomePage = "/kRealHomepage";
  @override
  State<RealHomePage> createState() => _RealHomePageState();
}

class _RealHomePageState extends State<RealHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Column(children: [
          Container(
            margin: EdgeInsets.all(20),
            child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Column(
                  children: [
                    Text(
                      "Good Morning!",
                      style: TextStyle(
                          color: Colors.black87,
                          fontSize: 20,
                          fontWeight: FontWeight.w700),
                    ),
                    Row(
                      children: [
                        Icon(
                          Icons.location_on_outlined,
                          color: Colors.black45,
                        ),
                        SizedBox(width: 3),
                        Text(
                          "648 Bridge Street",
                          style: TextStyle(
                              color: Colors.grey, fontWeight: FontWeight.w500),
                        )
                      ],
                    )
                  ],
                ),
                CircleAvatar(
                  child: ClipOval(
                      child: Image.asset("assets/images/starbucks.jpg")),
                  radius: 25,
                )
              ],
            ),
          ),

          SizedBox(
            height: 20,
          ),
          SizedBox(
              width: MediaQuery.of(context).size.width,
              height: 35,
              child: ListView(
                scrollDirection: Axis.horizontal,
                children: [
                  textTaskReal("all"),
                  textTaskReal("coffe"),
                  textTaskReal("tea"),
                  textTaskReal("Iced Blended"),
                  textTaskReal("juice"),
                ],
              )),

          SizedBox(
            height: 30,
          ),
          SizedBox(height: MediaQuery.of(context).size.height, width: 500,
          
            child: ListView(           
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  children: [
                    containerTemplate(context),
                    containerTemplate(context),
                  ],
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  children: [
                    containerTemplate(context),
                    containerTemplate(context),
                  ],
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  children: [
                    containerTemplate(context),
                    containerTemplate(context),
                  ],
                ),
              ],
            ),
          ),
        ]),
      ),
    );
  }
}

Container textTaskReal(String textnot) {
  return Container(
    alignment: Alignment.center,
    padding: EdgeInsets.fromLTRB(20, 10, 20, 10),
    margin: EdgeInsets.symmetric(horizontal: 10),
    child: Text(
      textnot,
      style: TextStyle(
          fontWeight: FontWeight.w500, color: Colors.white, fontSize: 12),
    ),
    decoration: BoxDecoration(
        color: Color.fromARGB(255, 0, 127, 83),
        borderRadius: BorderRadius.circular(24)),
  );
}

Container containerTemplate(BuildContext context) {
  return Container(
    width: 150,
    height: 225,
    child: ListView(
      children: [
        Container(
          child: Column(children: [
            Image.asset("assets/images/americano.png"),
            Container(
              margin: EdgeInsets.all(10),
              child: Column(
                children: [
                  Align(
                      alignment: Alignment.centerLeft,
                      child: Text(
                        "Mocha",
                        style: TextStyle(
                            color: Colors.white,
                            fontWeight: FontWeight.w600,
                            fontSize: 20),
                      )),
                  SizedBox(
                    height: 3,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text(
                        "5.99₺",
                        style: TextStyle(
                            color: Colors.white, fontWeight: FontWeight.w400),
                      ),
                      ClipOval(
                          child: Container(
                              color: Colors.white,
                              padding: EdgeInsets.all(2),
                              child: Icon(
                                Icons.add,
                              )))
                    ],
                  ),
                ],
              ),
            )
          ]),
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(16),
            color: Color.fromARGB(255, 0, 127, 83),
          ),
        )
      ],
    ),
  );
}