We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
i'm new the flutter environment i was watching a course and this works for the guy and not for me the code :
import 'package:flutter/material.dart'; import './question.dart'; import './Answer.dart';
void main() { runApp(Myapp()); }
class Myapp extends StatefulWidget { @OverRide State createState() { return _MyappState(); } }
class _MyappState extends State { var questionindex = 0;
void answerTheq() { setState(() { if (questionindex >= 2) { questionindex = 0; } else { questionindex += 1; print('hi answer '); } }); }
@OverRide Widget build(BuildContext context) { var questions = [ { 'question text': 'what's your fav color : ', 'answers': ['blue', 'green', 'red', 'yellow'] }, { 'question text': 'what's your fav animal : ', 'answers': ['cat', 'dog', 'lion', 'zebra'] }, { 'question text ': 'what's your fav team : ', 'answers': ['rca', 'wac', 'far', 'mat'] }, ];
return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('My app'), backgroundColor: Colors.blue, ), body: Column( children: [ Question(questions[questionindex]['question text ']), ...(questions[questionindex]['answer'] as List<String>) .map((answer) { return Answer(answerTheq, answer); })?.toList() ?? [] ], )), );
} }
import 'package:flutter/material.dart';
class Answer extends StatelessWidget { final Function getthefucntiondata; final String answertext;
Answer(this.getthefucntiondata, this.answertext);
@OverRide Widget build(BuildContext context) { return Container( width: double.infinity, child: RaisedButton( color: Colors.blue, child: Text(answertext), onPressed: getthefucntiondata, )); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
i'm new the flutter environment
i was watching a course
and this works for the guy and not for me
the code :
import 'package:flutter/material.dart';
import './question.dart';
import './Answer.dart';
void main() {
runApp(Myapp());
}
class Myapp extends StatefulWidget {
@OverRide
State createState() {
return _MyappState();
}
}
class _MyappState extends State {
var questionindex = 0;
void answerTheq() {
setState(() {
if (questionindex >= 2) {
questionindex = 0;
} else {
questionindex += 1;
print('hi answer ');
}
});
}
@OverRide
Widget build(BuildContext context) {
var questions = [
{
'question text': 'what's your fav color : ',
'answers': ['blue', 'green', 'red', 'yellow']
},
{
'question text': 'what's your fav animal : ',
'answers': ['cat', 'dog', 'lion', 'zebra']
},
{
'question text ': 'what's your fav team : ',
'answers': ['rca', 'wac', 'far', 'mat']
},
];
}
}
import 'package:flutter/material.dart';
class Answer extends StatelessWidget {
final Function getthefucntiondata;
final String answertext;
Answer(this.getthefucntiondata, this.answertext);
@OverRide
Widget build(BuildContext context) {
return Container(
width: double.infinity,
child: RaisedButton(
color: Colors.blue,
child: Text(answertext),
onPressed: getthefucntiondata,
));
}
}
The text was updated successfully, but these errors were encountered: