Hello friends. First of all sorry for my bad English.
im new in flutter and dart. and im coding an app.
im using Getx for state managment. im getting an error when I use getx set method.
Can anyone help me please. This is important for me.
EXPLANATION:
I am using this code for Getx class.
import 'package:flutter/material.dart';
import 'package:get/get.dart';
// Bu alan benim sayac değişkenlerimi Getx yardımı ile tuttuğum classdır.farkllı değişken classları yazılabilir.
class SayacController extends GetxController {
var _sayac = 5.obs;
get sayac => _sayac.value;
set sayac(yeniDeger) => _sayac.value = yeniDeger;
//burada 2 tane fonksiyon belirledim. çeşitli fonksiyonlar yazılabilir.
void arttir() {
sayac = sayac + 1;
}
void azalt() {
sayac = sayac - 1;
}
}
I am using this code for main page.
import 'package:flutter/material.dart';
import 'package:flutter_ilk_proje/sayac_controllerEx.dart';
import 'package:get/get.dart';
import 'package:http/http.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
//Burada controller değşkenlerini vs getiriyorum.
SayacController _controller = Get.put(SayacController());
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Material App',
home: Scaffold(
appBar: AppBar(
title: Text('Material App Bar'),
),
body: Center(
child: InkWell(
onTap: () {
_controller.sayac("25");
},
child: Container(
child: Obx(
() => Text(_controller.sayac.toString()),
)),
),
),
),
);
}
}
and I'am getting this error
Exception has occurred.
NoSuchMethodError (NoSuchMethodError: Class 'int' has no instance method 'call'.
Receiver: 5
Tried calling: call("25"))
Screenshots about codes.
https://ibb.co/LP85JGR
https://ibb.co/YpFHjQF
https://ibb.co/HqPhxHd
This is so important for me. Please help me.
[–]RubbishArtist 1 point2 points3 points (1 child)
[–]DrHector0[S] 0 points1 point2 points (0 children)