i have the NoSuchMethodError by simulation my App. NoSuchMethodError (NoSuchMethodError: The method '>=' was called on null. Receiver: null Tried calling: >=(55)) The Error is schowing when I simulation my app.
Can someone help me?
my full code in this file:
class GameEN extends StatefulWidget {
//Game({Key key}) : super(key: key);
@override
_GameENState createState() => _GameENState();
}
class _GameENState extends State<GameEN> {
int _counterK;
int _pktK;
@override
void initState() {
_subscription =
super.initState();
_loadCounterK();
}
@override
void dispose() {
_subscription.cancel();
super.dispose();
}
//Loading counter value on start (load)
_loadCounterK() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
_counterK = (prefs.getInt('counterK') ?? 1);
_pktK = (prefs.getInt('pktK') ?? 0);
print(Text("Load number is: $_counterK"));
print(Text("Load pkt is: $_pktK"));
});
}
@override
Widget build(BuildContext context) {
return new WillPopScope(
onWillPop: () async => false,
child: Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
centerTitle: true,
title: Text(
'ToolQuiz',
style: TextStyle(
fontStyle: FontStyle.italic,
color: Colors.black,
),
),
actions: <Widget>[
Padding(
padding: EdgeInsets.only(right: 15.0),
child: IconButton(
padding: EdgeInsets.all(0),
icon: Icon(
Icons.settings,
color: Colors.black,
),
onPressed: () {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) {
return Einstellungen();
},
),
);
}),
)
],
),
body: Center(
child: Container(
decoration: BoxDecoration(),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
//Küchenutensilien
GestureDetector(
onTap: () {
_interstitialAd.show();
_interstitialAd.dispose();
// _incrementCounterRightAnsK();
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) {
if (56 <= _counterK)
return KuechenutensilienEnd();
else
return KuechenutensilienStart();
},
transitionsBuilder:
(context, animation1, animation2, child) {
return FadeTransition(
opacity: animation1,
child: child,
);
},
transitionDuration: Duration(milliseconds: 500),
),
);
},
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.brown[600],
Colors.brown[700]
],
begin: Alignment.bottomLeft,
end: Alignment.topRight,
),
border:
Border.all(width: 2, color: Colors.black54),
borderRadius: const BorderRadius.all(
const Radius.circular(20))),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Container(
child: Column(
children: <Widget>[
Container(
alignment: Alignment.center,
child: Text('Küchenutensilien',
style: Theme.of(context)
.textTheme
.headline5
.copyWith(color: Colors.black)),
),
Container(
alignment: Alignment.center,
child: Text(
_pktK.toString() + ' ' + 'Punkte',
),
),
Container(
alignment: Alignment.center,
child: Text(() {
if (_counterK >= 55) {
return 'Level ' + '55' + '/55';
}
return 'Level ' +
_counterK.toString() +
'/55';
}()),
),
],
),
),
],
))),
],
),
),
))));
}
}
The error is showing me by all: if....>= I dont find my problem :(
Thanks for your help