Question: I need to filter data in my app but its showing error this is how I am doing.

Its printing `[Instance of 'Post']` now I need to print all values

```
class _FilterScreenState extends State<FilterScreen> {

List showPost;

  @override
  void initState(){
    super.initState();
    print(widget.id);
    showPost = posts.where((i) => i.id == widget.id).toList();
    print(showPost);

  }

```

I need to filter my array which `id` is equal to my `widget.id`

On other file, data look like this

```
final List<Post> posts = [
  Post(
    id: 0,
    authorName: 'Umaiz Khan',
    authorImageUrl: 'assets/images/user0.png',
    timeAgo: '5 min',
    imageUrl: 'assets/images/post0.jpg',
  ),
  Post(
    id: 1,
    authorName: 'Saad ahmed',
    authorImageUrl: 'assets/images/user1.png',
    timeAgo: '10 min',
    imageUrl: 'assets/images/post1.jpg',
  ),
  Post(
    id: 2,
    authorName: 'Hiba',
    authorImageUrl: 'assets/images/user4.png',
    timeAgo: '10 min',
    imageUrl: 'assets/images/post2.jpg',
  ),
];

```

Answer: 
I think you want to use the `void * ptr` as a general pointer to any data types.
The problem in your code is as below.

```
int main()
{
    char prenume[] = "Alexandru";
    char* name = prenume;
    int age = 33;
    float height = 1.81; //<=== this line will cause a truncation warning at compile time

    void* ptr;
    ptr = name;
    printf("My name is %s", *((char*)ptr)); // <======= this line will cause access violation error at runtime
    ptr = &age;
    printf("\nAge:%d", *((int*)ptr));
    ptr = &height;
    printf("\nHeight:%2.2f", *((float*)ptr));
    return 0;  
}

```

You should use `((char*)ptr)` (remove the leading `*`). This expression resolve to the **address** of the `A`. Because `%s` expects the start address of a string.

If you use `*((char*)ptr)`, it resolves to the **char value** `A`. The ASCII value of `A` is `0x41`, which is not an address you can usually access. And below debug message shows that it is the address `0x41` is causing access violation.

[![enter image description here](https://i.stack.imgur.com/zZt8z.png)](https://i.stack.imgur.com/zZt8z.png)

After making above changes, your code can run like below:

[![enter image description here](https://i.stack.imgur.com/nAGvV.png)](https://i.stack.imgur.com/nAGvV.png)

And btw, C is a dangerous beauty...
Your code is inconsistent. You're getting the address of `age` and `height` and putting it into `ptr`, but you put `name`'s value directly. Getting the address of a value adds a level of indirection (as in, using `&` on a `char*` gives you not `char*` but `char**`, the address of an address of a char).

Fixing your code to make it consistent:

```
void* ptr;
ptr = &name; //Added &.
printf("My name is %s", *((char**)ptr));
ptr = &age;
printf("\nAge:%d", *((int*)ptr));
ptr = &height;
printf("\nHeight:%2.2f", *((float*)ptr));

```

And it should now work. You can also rid yourself of that extra level of indirection (`&` and `*`) for less confusion.