dlcodns / OSP_Prediction

GNU General Public License v2.0
1 stars 2 forks source link

무언가에 가려져 보이지 않는 오류 #45

Closed dlcodns closed 1 year ago

dlcodns commented 1 year ago

이런 식으로 나타내려고 합니다.

코드는 flex로 1:1 나눠서 세로 두 줄을 먼저 만들고 row로 묶어줘 위 대시보드 모양을 만들려고 했습니다. 마지막으로 listview로 colunm대신 감싸주어 스크롤 하려고 했는데 화면이 텅 비어보입니다

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());  //앱 시작해주세요!, MyApp(메인페이지 주소)
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'review_2',
      home: Scaffold(
        backgroundColor: const Color(0xffE3DCFF),
        appBar: AppBar(
          backgroundColor: Color(0xffE3DCFF),
          title: Row(
            children: const [
              Icon(Icons.settings_backup_restore,color: Color(0xff404040),              ),
              Text('  다시 보기',
                style: TextStyle(
                    fontSize: 24,
                    color: Color(0xff404040),
                    fontWeight: FontWeight.bold
                ),)
            ],
          ),
        ),
        body: HomeApp(),
      ),
    );
  }
}

class HomeApp extends StatelessWidget{
  @override
  Widget build(BuildContext context){
    var m = MediaQuery.of(context);
    print("넓이 : ${m.size.width}");
    print("높이 : ${m.size.height}");
    return Column(
      children: [
        Flexible(
          flex: 1,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Row(
                  children:[
                    SizedBox(width: MediaQuery.of(context).size.width*0.02),
                    IconButton(
                        padding: EdgeInsets.zero,
                        onPressed: (){
                          //home
                        },
                        icon: const Icon(Icons.keyboard_backspace,
                            color: Color(0xffFFFFFF),
                            size: 40
                        )
                    ),
                  ]
              ),
              Align(
                alignment: Alignment(0.0,0.8),
                child: Row(
                  children: [
                    IconButton(
                        padding: EdgeInsets.zero,
                        constraints: BoxConstraints(),
                        onPressed: (){
                          //review_1
                        },
                        icon: const Icon(Icons.view_agenda,
                            color: Color(0xffFFFFFF),
                            size: 20
                        )
                    ),
                    IconButton(
                        padding: EdgeInsets.zero,
                        constraints: BoxConstraints(),
                        onPressed: (){
                          //noting
                        },
                        icon: const Icon(Icons.dashboard,
                            color: Color(0xffFFFFFF),
                            size: 20
                        )
                    ),
                    SizedBox(width: MediaQuery.of(context).size.width*0.02),
                  ],
                ),
              ),
            ],
          ),
        ),
        Flexible(
          fit: FlexFit.loose,
          flex: 12,
          child: Center(
            child: Stack(children: [
              Container(
                decoration: BoxDecoration(
                  color: Color(0xffEEEAFF),
                  borderRadius: BorderRadius.circular(10),
                  border: Border.all(width:10,color: Color(0xffEEEAFF)
                  ),
                ),
              ),
              ListView(
                  children: [
                    Row(
                       mainAxisAlignment: MainAxisAlignment.center,
                       children: [
                         Flexible(
                           flex:1,
                           child: Column(
                               crossAxisAlignment: CrossAxisAlignment.center,
                               children:[
                                 Flexible(fit: FlexFit.loose,
                                   child: Container(decoration: BoxDecoration(
                                     borderRadius: BorderRadius.circular(10),
                                     border: Border.all(width:10,color: Color(0xffEEEAFF)
                                     ),
                                   ), child: Image.asset('miso.jpg',fit: BoxFit.contain)),
                                 ),
                                 Container(
                                     decoration: BoxDecoration(
                                       borderRadius: BorderRadius.circular(10),
                                       border: Border.all(width:10,color: Color(0xffEEEAFF)
                                       ),
                                     ),
                                     child: Image.asset('TY.png',fit: BoxFit.contain)
                                 ),
                               ]
                           ),
                         ),
                         Flexible(
                           flex:1,
                           child: Column(
                               crossAxisAlignment: CrossAxisAlignment.center,
                               children:[
                                 Flexible(fit: FlexFit.loose,
                                   child: Container(decoration: BoxDecoration(
                                     borderRadius: BorderRadius.circular(10),
                                     border: Border.all(width:10,color: Color(0xffEEEAFF)
                                     ),
                                   ), child: Image.asset('heart.jpg',fit: BoxFit.contain)),
                                 ),
                                 Container(
                                     decoration: BoxDecoration(
                                       borderRadius: BorderRadius.circular(10),
                                       border: Border.all(width:10,color: Color(0xffEEEAFF)
                                       ),
                                     ),
                                     child: Image.asset('kitty.png',fit: BoxFit.contain)
                                 ),
                               ] ),
                         ),
                       ],
                     ),
                   ]
                ),
            ]
              ),
            ),
          ),
      ],
    );
  }
}
troymerai commented 1 year ago

container 위젯 크기 지정안해줘서 안보이는거 아닌가요?

dlcodns commented 1 year ago

방금 다시 해봤는데 각각 컨테이너 감쌌던 flexible 없애니까 됐습니다!

ListView(children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Flexible(
                      flex:1,
                      child: Column(
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children:[
                            Container(
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(10),
                                  border: Border.all(width:10,color: Color(0xffEEEAFF)
                                  ),
                                ),
                                child: Image.asset('miso.jpg',fit: BoxFit.contain)),
                            Container(
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(10),
                                  border: Border.all(width:10,color: Color(0xffEEEAFF)
                                  ),
                                ),
                                child: Image.asset('TY.png',fit: BoxFit.contain)
                            ),
                            Container(decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(10),
                              border: Border.all(width:10,color: Color(0xffEEEAFF)
                              ),
                            ), child: Image.asset('heart.jpg',fit: BoxFit.contain)),
                          ]
                      ),
                    ),
                    Flexible(
                      flex:1,
                      child: Column(
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children:[
                            Container(decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(10),
                              border: Border.all(width:10,color: Color(0xffEEEAFF)
                              ),
                            ), child: Image.asset('heart.jpg',fit: BoxFit.contain)),

                            Container(
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(10),
                                  border: Border.all(width:10,color: Color(0xffEEEAFF)
                                  ),
                                ),
                                child: Image.asset('kitty.png',fit: BoxFit.contain)
                            ),
                            Container(
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(10),
                                  border: Border.all(width:10,color: Color(0xffEEEAFF)
                                  ),
                                ),
                                child: Image.asset('TY.png',fit: BoxFit.contain)
                            ),
                          ] ),
                    ),
                  ],
                ),
              ]
              ),