Reputation: 163
i try to create a function to simply add a data to list this is my function implementation
void addNumbers() {
numbers.add(numberController.value);
numberController.clear();
print(numbers);
}
this is view page
Obx((){
return RaisedButton(
child: Text("ADD",style: TextStyle(fontSize: 20)),
onPressed: MessageContoller.addNumbers(),
);
});
but it show to error like "Instance member 'addNumbers' can't be accessed using static"
Upvotes: 0
Views: 34
Reputation: 482
Create an instance of MessageController in your Stateful/stateless widget
like
MessageController messageController = Get.put(MessageController())
Then use it like messageController.addNumbers() on your button onTap
Upvotes: 0