import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class GameQuiz extends StatefulWidget {
const GameQuiz({Key? key}) : super(key: key);
@override
_GameQuizState createState() => _GameQuizState();
}
class _GameQuizState extends State<GameQuiz> {
List options = ["option 1", "option 2", "option 3", "option 4"];
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
width: MediaQuery.of(context).size.width,
decoration: const BoxDecoration(
color: Colors.deepPurple,
image: DecorationImage(
image: AssetImage(
"assets/images/background.jpg",
),
fit: BoxFit.cover),
),
child: Padding(
padding: const EdgeInsets.fromLTRB(20, 100, 20, 0),
child: Column(children: [
Text(
"Animal Kingdom Quiz",
style: GoogleFonts.fredokaOne(
color: Colors.white,
fontSize: 40,
fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
Padding(
padding: const EdgeInsets.fromLTRB(20, 60, 20, 20),
child: Container(
width: MediaQuery.of(context).size.width - 40,
decoration:
BoxDecoration(color: Colors.purple.withOpacity(0.3)),
child: Padding(
padding: const EdgeInsets.only(top: 30),
child: Column(
children: [
Text(
"My Question",
style: GoogleFonts.fredokaOne(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold),
)
ListView.builder(
itemCount: options.length,
itemBuilder: (context , index){
return Text(options[index]);
}),
],
),
),
),
),
]),
),
),
);
}
}
CodePudding user response:
inside your ListView.builder use 'shrinkWrap: true' like this code snippet
CodePudding user response:
You can use shrinkWrap: true,
on ListView
.
),
ListView.builder(
itemCount: options.length,
shrinkWrap: true,
itemBuilder: (context, index) {
return Text(options[index]);
},
),
More about shrinkWrap
.