Skip to content

윤정하_week6-7#29

Open
jeongha-daisy wants to merge 1 commit intoGDSCPKNU:mainfrom
jeongha-daisy:main
Open

윤정하_week6-7#29
jeongha-daisy wants to merge 1 commit intoGDSCPKNU:mainfrom
jeongha-daisy:main

Conversation

@jeongha-daisy
Copy link
Contributor

@jeongha-daisy jeongha-daisy commented Jun 19, 2023

✍️ 미션

글 작성하기

Simulator Screen Recording - iPhone 14 Pro Max - 2023-06-19 at 14 38 03

List<Post> _postList = [];

void addPost(Post _post) {
  _postList.add(_post);
}

글 확인하기

Simulator Screen Recording - iPhone 14 Pro Max - 2023-06-19 at 14 38 13

//Stateful 위젯
class ShowPost extends StatefulWidget{
  const ShowPost({super.key});

  @override
  State<ShowPost> createState() => _ShowPostState();
}

class _ShowPostState extends State<ShowPost>{

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      itemCount: _postList.length,
      itemBuilder: (context, index){
        return ListTile(
          onTap: (){
            Navigator.push(
                context, MaterialPageRoute(builder: (context) => ViewPage(index: index))).then((value) => setState(() {}));
          },
          title: Text(_postList[index].title),
        );
      },
    );
  }
}

글 수정하기

Simulator Screen Recording - iPhone 14 Pro Max - 2023-06-19 at 14 38 31

Post _post = new Post(
                    title: _titleController.text,
                    contents: _contentsControler.text
                  );
                  editPost(_post, widget.index);
void editPost(Post _post, int index){
  _postList[index] = _post;
}

글 삭제하기

Simulator Screen Recording - iPhone 14 Pro Max - 2023-06-19 at 14 38 50

void deletePost(int index){
  _postList.removeAt(index);
}



👀 TMI

@jeongha-daisy jeongha-daisy self-assigned this Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant