Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- Snapshot
- changenotifier
- enum
- setstate
- Navigator
- Firebase
- switch
- swift 문법
- changenotifierprovider
- runTransaction
- globalkey
- provider
- Stream
- Swift
- ListView.builder
- 문법
- transform
- reference
- datetime
- multiprovider
- snackbar
- borderRadius
- controller
- user
- consumer
- platformexception
- divider
- Camera
- signout
- permission
Archives
- Today
- Total
코딩하는 제리
[Flutter/Project](Instagram Clone) follow 화면 레이아웃 본문
Flutter/Project_InstaClone(완)
[Flutter/Project](Instagram Clone) follow 화면 레이아웃
JerryCho 2021. 2. 2. 09:45아이폰 시뮬레이터의 속도가 느려서 안드로이드 에뮬레이터로 대체.
소스코드 및 pubspec.yaml
// screens/search_screen.dart
import 'package:flutter/material.dart';
import 'package:flutter_project_IJ/widgets/rounded_avatar.dart';
class SearchScreen extends StatefulWidget {
@override
_SearchScreenState createState() => _SearchScreenState();
}
class _SearchScreenState extends State<SearchScreen> {
// 30개의 아이템마다 false를 리턴
List<bool> followings = List.generate(30, (index) => false);
@override
Widget build(BuildContext context) {
return SafeArea(
child: ListView.separated(
// 30개의 아이템
itemCount: 30,
itemBuilder: (context, index) {
return ListTile(
onTap: () {
setState(() {
// 클릭마다 followings의 반대 값을 넣음(true or false)
followings[index] = !followings[index];
});
},
leading: RoundedAvatar(),
title: Text('username $index'),
subtitle: Text('user vio number $index'),
trailing: Container(
height: 30,
width: 80,
// Container 중앙정렬
alignment: Alignment.center,
decoration: BoxDecoration(
// 배경색
color: followings[index] ? Colors.red[50] : Colors.blue[50],
// 테두리 모양
border: Border.all(
color: followings[index] ? Colors.red : Colors.blue,
width: 0.5),
// 모서리 둥글기
borderRadius: BorderRadius.circular(8),
),
child: Text(
'following',
style: TextStyle(fontWeight: FontWeight.bold),
),
),
);
},
separatorBuilder: (context, builder) {
return Divider(
// 구분선
color: Colors.grey,
);
}),
);
}
}
'Flutter > Project_InstaClone(완)' 카테고리의 다른 글
[Flutter/Project](Instagram Clone) Firebase auth 상태 파일 (0) | 2021.02.02 |
---|---|
[Flutter/Project](Instagram Clone) Firebase 프로젝트 생성 (0) | 2021.02.02 |
[Flutter/Project](Instagram Clone) 갤러리 이미지 BoxFit 및 scale 축소 추가 (0) | 2021.02.01 |
[Flutter/Project](Instagram Clone) 갤러리 사진 선택 미리보기 (0) | 2021.02.01 |
[Flutter/Project](Instagram Clone) 카메라 갤러리 가져오기 (0) | 2021.01.31 |
Comments