I am trying to make a quiz app in which i want to call QuestionDisplay()
on a drop down onchanged
function but it is giving error "can't be assigned to the parameter type string"
, what does it mean?
I just want to display random question on a tap on drop-down item, like question and something else, but it is not going to the way i just want it to go, kindly guide me that how can it will b possible to display random question on a drop down tap that on tap it will display a random question that i want to define in QuestionDisplay
class?
import 'package:flutter/material.dart';
import 'dart:math';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
theme: new ThemeData(primarySwatch: Colors.blue),
home: new LoginPage(),
);
}
}
class LoginPage extends StatefulWidget {
@override
State createState() => new LoginPageState();
}
class LoginPageState extends State<LoginPage>
with SingleTickerProviderStateMixin {
Animation<double> _iconAnimation;
AnimationController _iconAnimationController;
String selectedValues;
@override
void initState() {
super.initState();
_iconAnimationController = new AnimationController(
vsync: this, duration: new Duration(milliseconds: 500));
_iconAnimation = new CurvedAnimation(
parent: _iconAnimationController,
curve: Curves.bounceOut,
);
_iconAnimation.addListener(() => this.setState(() {}));
_iconAnimationController.forward();
}
//Background Image Code Starts From here
@override
Widget build(BuildContext context) {
return new Scaffold(
backgroundColor: Colors.white,
body: new Stack(fit: StackFit.expand, children: <Widget>[
new Image(
image: new AssetImage('asset/bg.png'),
fit: BoxFit.cover,
),
new Theme(
child: Container(
padding: const EdgeInsets.fromLTRB(100.0, 10.0, 100.0, 00.0),
decoration: BoxDecoration(
image: DecorationImage(
image: new AssetImage('asset/I2.png'),
alignment: Alignment.topRight,
),
),
),
data: new ThemeData(
canvasColor: Colors.blue.shade200,
brightness: Brightness.dark,
inputDecorationTheme: new InputDecorationTheme()),
isMaterialAppTheme: true,
),
new Column(
children: <Widget>[
new Padding(
padding: new EdgeInsets.fromLTRB(0.0, 350.0, 200.0, 0.0)),
new Text(
QuestionDisplay(),
style: TextStyle(
fontSize: 24.0,
fontWeight: FontWeight.w900,
fontFamily: "Georgia",
color: Colors.grey[300],
),
),
new Padding(padding: new EdgeInsets.only(top: 50.0,)),
new DropdownButton<String>(
hint: new Text('Select Type'),
value: selectedValues,
items: <String>[
"Questions",
"Something else",
].map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (String value) {
setState(() {
QuestionDisplay();
// selectedValues = value.toString();
});
},
),
],
),
ImageRotate(),
]),
);
}
}
class ImageRotate extends StatefulWidget {
@override
_ImageRotateState createState() => new _ImageRotateState();
}
class _ImageRotateState extends State<ImageRotate>
with SingleTickerProviderStateMixin {
AnimationController animationController;
static var rng = new Random();
double random_number = 0.0;
@override
void initState() {
super.initState();
animationController = new AnimationController(
vsync: this,
duration: Duration(seconds: random_number.toInt()),
);
}
void move() {
double random_number = (5 +
((rng.nextInt((5 - 1).ceil() * 1000) +
rng.nextInt((30 - 10).ceil() * 1000) +
rng.nextInt((30 - 10).ceil() * 1000) +
rng.nextInt((30 - 10).ceil())) /
4000.0));
double random_number1 = (4 +
((rng.nextInt((5 - 1).ceil() * 1000) +
rng.nextInt((30 - 10).ceil() * 1000) +
rng.nextInt((30 - 10).ceil() * 1000) +
rng.nextInt((30 - 10).ceil())) /
4000.0));
animationController.duration = Duration(seconds: random_number.toInt());
animationController.forward(from: -1.0);
animationController.repeat();
print(animationController.value);
print(animationController.value * random_number1);
animationController.addListener(() {
this.setState(() {
animationController.forward();
});
});
}
@override
Widget build(BuildContext context) {
double random_number3 = (60 +
((rng.nextInt((5 - 1).ceil() * 1000) +
rng.nextInt((30 - 10).ceil() * 1000) +
rng.nextInt((30 - 10).ceil() * 1000) +
rng.nextInt((30 - 10).ceil())) /
4000.0));
return new Container(
height: 150.0,
width: 150.0,
padding: new EdgeInsets.fromLTRB(110.0, 150.0, 100.0, 420.0),
alignment: Alignment.bottomCenter,
child: new AnimatedBuilder(
animation: animationController,
child: new GestureDetector(
child: new Image.asset('asset/5.png'),
onTap: () {
move();
},
),
builder: (BuildContext context, Widget _widget) {
return new Transform.rotate(
angle: animationController.value * random_number3.toInt(),
child: _widget,
);
},
),
);
}
}
//Animation code Ends from here
class QuestionDisplay extends StatefulWidget {
@override
_QuestionDisplayState createState() => _QuestionDisplayState();
}
class _QuestionDisplayState extends State<QuestionDisplay> {
@override
Widget build(BuildContext context) {
new Padding(padding: new EdgeInsets.only(bottom: 200.0,));
return new Text(
"HEllo World"
);
}
}