-
-
Save angelabauer/1b8e0089c03f0e85e3f2eb1fa0aa68e2 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart'; | |
void main() => runApp( | |
MaterialApp( | |
home: BallPage(), | |
), | |
); | |
class BallPage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
backgroundColor: Colors.blue, | |
appBar: AppBar( | |
backgroundColor: Colors.blue.shade900, | |
title: Text('Ask Me Anything'), | |
), | |
body: Container(), | |
); | |
} | |
} |
This is my code!!
import 'package:flutter/material.dart';
import 'dart:math';
void main() {
runApp(MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.blue,
appBar: AppBar(
title: Text(
'Ask Me Anything',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.white,
fontFamily: 'SourceCodePro'),
),
centerTitle: true,
backgroundColor: Colors.blue.shade900,
),
body: Ball())));
}
class Ball extends StatefulWidget {
const Ball({super.key});
@OverRide
State createState() => _BallState();
}
class _BallState extends State {
@OverRide
int Magicball = 1;
void randomAnswerGenerator() {
setState(() {
Magicball = Random().nextInt(5) + 1;
});
}
Widget build(BuildContext context) {
return TextButton(
onPressed: () {
randomAnswerGenerator();
},
child: Center(child: Image.asset('images/ball$Magicball.png')),
);
}
}
//
//
import 'package:flutter/material.dart';
void main() => runApp(
MaterialApp(
home: BallPage(),
),
);
class BallPage extends StatelessWidget {
const BallPage({super.key});
@OverRide
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blue,
appBar: AppBar(
backgroundColor: Colors.blue.shade900,
title: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
'Ask Me Anything',
style: TextStyle(
fontSize: 22.0,
fontWeight: FontWeight.bold,
color: Colors.white,
//padding: EdgeInsets.all(20),
),
// color: Colors.blue,
),
],
)),
body: Center(
child: Container(),
));
}
}
import 'package:flutter/material.dart';
import 'dart:math';
void main() {
return runApp(
MaterialApp(
home: Scaffold(
backgroundColor: Colors.blue[500],
appBar: AppBar(
title: Text(
'Ask Me Anything',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
backgroundColor: Colors.blue[800],
),
body:
magicBall(), // call back function that is calling the build function.
),
),
);
}
you should comment on github with this quote : ```
and close the sytnx with the quote like AAA your code AAA
replace AAA quote
the result dont forget to make it beutifully i think on save will auto format by vscode instead
import 'package:flutter/material.dart';
import 'dart:math';
void main() {
return runApp(
Hi though I'm viewing these lectures quite a bit late, but here's my code
import 'package:flutter/material.dart';
void main() => runApp(
MaterialApp(
home: BallPage(),
),
);
class BallPage extends StatelessWidget {
const BallPage({super.key});
@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Ask Me Anything'),
foregroundColor: Colors.white,
backgroundColor: Colors.blueAccent,
),
backgroundColor: Colors.blue.shade900,
body: Container(),
);
}
}
Thanks Angela for this amazing course
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(home: BallPage()));
}
class BallPage extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.cyan,
appBar: AppBar(
backgroundColor: Colors.cyan.shade800,
title: Center(child: Text('Ask Me Anything',
style: TextStyle(
color: Colors.white,
),),
),
),
body: Ball(),
);
}
}
// Creates a Stateful widget
class Ball extends StatefulWidget {
const Ball({Key? key}) : super(key: key);
@OverRide
_BallState createState() => _BallState();
}
class _BallState extends State {
int ballNumber = 1;
@OverRide
Widget build(BuildContext context) {
return Center(
child: TextButton(
onPressed: () {
setState(() {
// Random.nextInt(n) returns a random integer from 0 to n-1
ballNumber = Random().nextInt(5) + 1;
});
},
// Adding images
child: Image.asset('images/ball$ballNumber.png'),
),
);
}
}
Here is the Magic 8 Ball code.
Enjoying everybit of this course.
Thank You,
import 'package:flutter/material.dart';
void main() => runApp(
MaterialApp(
home: Ball_page(),
),
);
class Ball_page extends StatelessWidget {
const Ball_page({super.key});
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.blue,
appBar: AppBar(
backgroundColor: Colors.blue[900],
title: Text(
'Ask me anything',
style: TextStyle(color: Colors.white),
),
),
),
);
}
}
I have successfully completed the assignment to create a stateless widget as taught by Angela Yu in the Flutter development course on Udemy.
Overall, this assignment has been a valuable learning opportunity, allowing me to practice creating stateless widgets and improving my skills in customizing widget behavior and appearance. I am excited to continue exploring Flutter development through this course and further expand my knowledge.
I wish to connecting with other flutter developers