플러터 기초

2022. 10. 29. 21:49· Project/후크(Flutter)

앱바안에 텍스트 넣는법/설정 등등, 바틈네비게이션 크기조절하는법,

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('앱바'),
          centerTitle: false,
          elevation: 0.0,
        ),
        body:Text('안녕'),
        bottomNavigationBar: BottomAppBar(
          elevation: 1,
          child: SizedBox(
            height: 50,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: const [
                Icon(Icons.phone),
                Icon(Icons.message),
                Icon(Icons.contact_page),
              ],

            ),
          ),
        )
      )
    );
  }
}

데코

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('앱')),
        body: Align(
          alignment: Alignment.bottomCenter,
          child: Container(
            width: double.infinity, height: 50,
            margin: EdgeInsets.fromLTRB(0,30,0,0),
            decoration: BoxDecoration(
              border: Border.all(color: Colors.black),color:Colors.blue
            ),
            child: Text('ddddd')
          ),
        ),

      )
    );
  }
}

텍스트 스타일

import 'dart:html';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('앱임',
          style: TextStyle(
          color: Colors.red,

        ),
        ),
        ),
        body: Container(

          child: Text('안녕하세요',
            style: TextStyle(
              color: Color.fromRGBO(21, 85, 224, 0.3),
              fontSize:30,
              fontWeight: FontWeight.w900
              ),
            ),

        ),
        ),
      );

  }
}

리딩이랑 액션 버튼

import 'dart:html';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('앱임',
          style: TextStyle(
          color: Colors.red,
          ),
        ),
          leading: Icon(Icons.star
          ),
          actions: [Icon(Icons.star),Icon(Icons.star)],
        ),
        body: SizedBox(
          child: ElevatedButton(
            child: Image.asset('pic1'),
            onPressed: (){},

          ),
        )
        ),
      );

  }
}

당근마켓 페이지 따라 만들기

 

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main(){
  runApp(Myapp());
}

class Myapp extends StatelessWidget {
  const Myapp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
          appBar: AppBar(
            elevation: 0.3,
            backgroundColor: Colors.white,
            title: Row(
                children : [Text('금호동3가',style: TextStyle(color: Colors.black),),IconButton(
                  visualDensity: VisualDensity(horizontal: -4.0,vertical: -4.0),
                  icon : Icon(Icons.expand_more,color: Colors.black,),
                  onPressed: (){},)]
            ),
            actions: [IconButton(
              visualDensity: VisualDensity(horizontal: -4.0,vertical: -4.0),
              icon : Icon(Icons.search,color: Colors.black,),
              onPressed: (){},),IconButton(
              visualDensity: VisualDensity(horizontal: -4.0,vertical: -4.0),
              icon : Icon(Icons.menu,color: Colors.black,),
              onPressed: (){},),IconButton(
              visualDensity: VisualDensity(horizontal: -4.0,vertical: -4.0),
              icon : Icon(Icons.add_alert,color: Colors.black,),
              onPressed: (){},)],


          ),
          body: Container(
            margin: EdgeInsets.all(8.0),
            padding: EdgeInsets.all(8.0),
            child: Column(
              children: [Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [Flexible(child: Image.asset('pic1.png'),flex: 3,),Flexible(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [Text('BDSR 후드티(자수프린팅, 멋있음)',style: TextStyle(fontWeight: FontWeight.w800,fontSize: 15),),
                      Text('금정구 장전동 끌올 10분전',style: TextStyle(fontSize: 10),),
                      Text('43,900원',style: TextStyle(fontWeight: FontWeight.w800,fontSize: 15),),
                      Row(mainAxisAlignment: MainAxisAlignment.end,
                        children: [IconButton(onPressed: (){}, icon: Icon(Icons.favorite_outline_sharp),iconSize: 18,),Text('4')],
                      ),],
                  ),flex: 7
                  ,)],
              ),
                Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [Flexible(child: Image.asset('pic1.png'),flex: 3,),Flexible(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [Text('BDSR 후드티(자수프린팅, 멋있음)',style: TextStyle(fontWeight: FontWeight.w800,fontSize: 15),),
                        Text('금정구 장전동 끌올 10분전',style: TextStyle(fontSize: 10),),
                        Text('43,900원',style: TextStyle(fontWeight: FontWeight.w800,fontSize: 15),),
                        Row(mainAxisAlignment: MainAxisAlignment.end,
                          children: [IconButton(onPressed: (){}, icon: Icon(Icons.favorite_outline_sharp),iconSize: 18,),Text('4')],
                        ),],
                    ),flex: 7
                    ,)],
                )],

            ),
          ),
        )
    );

  }
}

커스텀위젯

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(),
        body: ShopItem(),
      ),
    );
  }
}

class ShopItem extends StatelessWidget {
  const ShopItem({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      child: Text("안녕"),
    );
  }
}

숙제

 

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(),
        body: ListView(
          children: [hong(),hong(),hong()
          ],
        ),
        bottomNavigationBar: bottom(),
      ),
    );
  }
}
class hong extends StatelessWidget {
  const hong({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 40,
      child: Row(

        children: [Icon(Icons.person,size: 40,),SizedBox(width: 5,),Text('홍길동',style:TextStyle(
          fontSize: 18
        ) ,)],
      ),
    );
  }
}

class bottom extends StatelessWidget {
  const bottom({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return BottomAppBar(
      elevation: 1,
      child: SizedBox(
        height: 50,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [IconButton(onPressed: null, icon: Icon(Icons.call)),
            IconButton(onPressed: null, icon: Icon(Icons.message)),
            IconButton(onPressed: null, icon: Icon(Icons.contact_page)),],
        ),
      ),
    );
  }
}

 

윤재에요
윤재에요
윤재에요
yunzae.log
윤재에요
전체
오늘
어제
  • 분류 전체보기 (438)
    • Computer Science (115)
      • 데이터베이스 (50)
      • 네트워크 (18)
      • 소프트웨어 공학 (1)
      • 알고리즘 (10)
      • 자료구조 (9)
      • 컴퓨터구조 (0)
      • 운영체제 (0)
      • 데이터 통신 (16)
      • 프로그래밍언어론 (11)
    • Project (20)
      • 후크(Flutter) (1)
      • BDSR로그북(App,BackEnd) (2)
      • 나만의 주점(STM32,Arduino,androi.. (9)
      • 공다(App,BackEnd) (2)
      • 카카오쇼핑 클론코딩 (4)
      • 암호화폐자동매매 (2)
    • Problem Solving (208)
      • 자바 문법 (20)
      • 파이썬 문법,함수 (6)
      • 그리디 (5)
      • 구현 (43)
      • DFS (3)
      • BFS (17)
      • 정렬 (15)
      • 이진 탐색 (16)
      • 다이나믹 프로그래밍 (6)
      • 최단 경로 (5)
      • 그래프 (1)
      • 자료구조 (5)
      • 투포인터 (15)
      • SQL (44)
      • 구간합 (7)
    • I leaned (78)
      • 스프링,스프링부트 (31)
      • Git (6)
      • JAVA (5)
      • Etc (30)
    • 취업 (15)
      • PT면접 (6)
      • 기술면접 (9)
      • 인성면접 (0)
    • log (0)

블로그 메뉴

  • 홈
  • 태그
  • 방명록
  • 글쓰기

공지사항

인기 글

태그

  • E-R Model
  • 이것이 코딩테스트다.
  • 기수정렬
  • weak entity
  • 다이나믹
  • 최단거리
  • 다익스트라
  • Relationship model
  • 다이어그램
  • 제약 사항
  • DP
  • 그리디
  • 다이나믹프로그래밍
  • 카카오테크캠퍼스
  • 개미전사
  • 이것이 코딩테스트다
  • 플로이드 워셜
  • 효율적인화폐구성
  • 먀
  • 교환정렬
  • 재시도
  • UML
  • 이것이코딩테스트다
  • 참조 무결성
  • 힙큐
  • 데이터베이스
  • 최단 거리
  • 계수정렬
  • 파이썬
  • 부품찾기

최근 댓글

최근 글

hELLO · Designed By 정상우.v4.2.2
윤재에요
플러터 기초
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.