본문 바로가기

Flutter

flutter) Container 사용하여 gradient 먹이기

728x90

구조를 모르니까 

메소드 헬퍼를 못 부르겠네요...

 

 

import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.red,
        body: Container(
          decoration: BoxDecoration(
            gradient: LinearGradient(
              colors: [Colors.blue,Colors.red]
            )
          ),
          child: Center(
            child: Text("Hello World!"),
          ),
          
        ),
      ),
    ),
  );
}

 

 

 

 

Container 컴포넌트는

html로 치면 div와 같은 역할이지 않을까 하는 생각이 드네요

 

구조를 트리로 나타내보면 아래와 같습니다.

 

 

body

- Container

    -decoration

        - BoxDecoration

            - gradient

- child

    - Center

 

 

 

 

 

'Flutter' 카테고리의 다른 글

flutter) 위젯을 분리해보자  (0) 2024.02.10
flutter) graident 원하는 방향으로 효과주기  (0) 2024.02.10
flutter) backgroundcolor 적용하기  (0) 2024.02.10
flutter) flutter 개행 하는 법  (0) 2024.02.09
flutter) const 란  (0) 2024.02.09