Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

윤정하_week6-7 #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

윤정하_week6-7 #29

wants to merge 1 commit into from

Conversation

urlotus
Copy link
Contributor

@urlotus urlotus 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

@urlotus urlotus 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