4일차 과제 - rlatkddbs99/Flutter GitHub Wiki

  1. localhost 컴퓨터 네트워크에서 사용하는 루프백 호스트명으로, 자신의 컴퓨터를 의미 localhost는 말 그대로 해석하면 지역(local)+호스트(host)로 IT에서 말하는 localhost는 네트워크 상에서 자신의 컴퓨터의 주소를 뜻한다. localhost는 자신의 컴퓨터를 뜻하고, 다른 컴퓨터에서는 이 주소에 접근할 수는 없다. 로컬호스트의 IPv4에서의 IP 주소는 127.0.0.1이다

  2. PageView나 ListView는 유저의 행동에 따라서 작동됩니다.**

    • 만약 유저의 행동을 제한하고 싶으면 어떤 속성 값을 설정해야하는지 정리하세요.
    • 예를들어, PageView는 페이지 변경을 제한하고, ListView는 스크롤이 안되게 제한합니다.

physics: 이 속성을 이용하여 행동을 설정할 수 있다. ListView -> const NeverScrollableScrollPhysics() -> 스크롤이 안되도록 PageView -> ScrollPhysics : 커스텀 스크롤 동작을 정의할 수 있습니다. AlwaysScrollableScrollPhysics BouncingScrollPhysics : ClampingScrollPhysics : FixedExtentScrollPhysics NeverScrollableScrollPhysics: 스크롤 안됨.. 스크롤 막음. PageScrollPhysics

  1. 캡처 실행하면 The relevant error-causing widget was ListView 이런 오류가 뜨게 된다. 세로 방향으로 확장을 시도하는데 ListView의 높이를 지정해주지 않는 다면 뜨게 된다고 한다. 해결 방법으로는 expanded()로 ListView를 감싸거나 sizedbox로 높이를 지정 또는 ListView의 속성인 shrinkWrap의 기본값인 false에서 true로 바꾼다면 해결된다.

'''

import 'package:flutter/material.dart';

void main() { runApp(const MyApp()); }

class MyApp extends StatelessWidget { const MyApp({super.key});

@override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: ListView( shrinkWrap: true, children: [ Text('안녕 난 1번 ListView의 자식이다'), Text('나도! 1번 ListView의 자식이야'), ListView( shrinkWrap: true, children: [ Text('난 2번의 자식임'), Text('나도 2번의 자식임'), ], ), Text('난 멀리 떨어져있지만 1번의 자식이야'), ]), ), ); } }

'''

  1. 캡처1

'''

import 'package:flutter/material.dart';

void main() { runApp(const MyApp()); }

class MyApp extends StatelessWidget { const MyApp({super.key});

@override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: PageView( children: [ Container( color: Colors.blue, ), Container( color: Colors.red, ), Container( color: Colors.orange, ), Container( color: Colors.green, ), Container( color: Colors.purple, ), ], )), ); } }

'''

  1. 캡처3

'''

import 'package:flutter/material.dart';

void main() { runApp(const MyApp()); }

class MyApp extends StatelessWidget { const MyApp({super.key});

@override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: SafeArea( child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "오늘의 하루는", style: TextStyle(fontSize: 25, color: Colors.black), ), Text( "어땠나요?", style: TextStyle(fontSize: 15, color: Colors.grey), ), Container( width: 150, height: 50, child: PageView( children: [ Container( decoration: BoxDecoration( gradient: LinearGradient( colors: [Colors.blue, Colors.red], ), borderRadius: BorderRadius.circular(50), ), child: Text("좋음", textAlign: TextAlign.center), ), Container( decoration: BoxDecoration( gradient: LinearGradient( colors: [Colors.green, Colors.purple]), borderRadius: BorderRadius.circular(50), ), child: Text("나쁨", textAlign: TextAlign.center), ), Container( decoration: BoxDecoration( gradient: LinearGradient( colors: [Colors.deepOrange, Colors.lime]), borderRadius: BorderRadius.circular(50), ), child: Text("졸림", textAlign: TextAlign.center), ), ], ), ) ], ), ), )), ); } }

'''