Skip to content

Instantly share code, notes, and snippets.

@kt-aakash
Created August 9, 2020 17:41
Show Gist options
  • Save kt-aakash/1615ab4c592b38bd92c09bb720f3c949 to your computer and use it in GitHub Desktop.
Save kt-aakash/1615ab4c592b38bd92c09bb720f3c949 to your computer and use it in GitHub Desktop.
Flutter Version : 1.20
import 'package:flutter/material.dart';
void main() => runApp(Quizzler());
class Quizzler extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.grey.shade900,
body: SafeArea(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 10.0),
child: QuizPage(),
),
),
),
);
}
}
class QuizPage extends StatefulWidget {
@override
_QuizPageState createState() => _QuizPageState();
}
class _QuizPageState extends State<QuizPage> {
List<Icon> scoreKeeper = [
Icon(
Icons.check,
color: Colors.green,
),
Icon(
Icons.close,
color: Colors.red,
),
];
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Expanded(
flex: 5,
child: Padding(
padding: EdgeInsets.all(10.0),
child: Center(
child: Text(
'This is where the question text will go.',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 25.0,
color: Colors.white,
),
),
),
),
),
Expanded(
child: Padding(
padding: EdgeInsets.all(15.0),
child: FlatButton(
textColor: Colors.white,
color: Colors.green,
child: Text(
'True',
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
),
),
onPressed: () {
//The user picked true.
},
),
),
),
Expanded(
child: Padding(
padding: EdgeInsets.all(15.0),
child: FlatButton(
color: Colors.red,
child: Text(
'False',
style: TextStyle(
fontSize: 20.0,
color: Colors.white,
),
),
onPressed: () {
//The user picked false.
},
),
),
),
Row(
children: scoreKeeper,
),
],
);
}
}
@kt-aakash
Copy link
Author

kt-aakash commented Aug 9, 2020

Update:

The solution was :
Either:
Restart Android Studio and run it again
Else:
Adding final keyword to the list i.e :
Replace line no: 29 with:
final List scoreKeeper = [

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment