-
-
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(), | |
); | |
} | |
} |
import 'dart:math';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(
MaterialApp(
home: Center(
child: Scaffold(
appBar: AppBar(
title: Text('Ask me Anything',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 28,
),),
backgroundColor: Colors.blue.shade600,
),
backgroundColor: Colors.blue.shade400,
body: MagicBall(),
),
),
)
);
class MagicBall extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {
return Ball();
}
}
class Ball extends StatefulWidget {
@OverRide
State createState() => _BallState();
}
class _BallState extends State {
int ballNumber = 0;
@OverRide
Widget build(BuildContext context) {
ballNumber = Random().nextInt(5) + 1;
return Center(
child: Row(
children: [
Expanded(
child: FlatButton(
onPressed: (){
setState(() {
ballNumber = Random().nextInt(5) + 1;
print('You Clicked me left One');
});
},
child: Image.asset('images/ball$ballNumber.png')),
),
],
),
);
}
}
**import 'dart:math';
import 'package:flutter/material.dart';
void main() {
return runApp(
const MaterialApp(
debugShowCheckedModeBanner: false,
home: AmaMagicBall(),
),
);
}
class AmaMagicBall extends StatefulWidget {
const AmaMagicBall({Key? key}) : super(key: key);
@OverRide
State createState() => _AmaMagicBallState();
}
class _AmaMagicBallState extends State {
int amaBall = 1;
updAmaBall() {
setState(() {
amaBall = Random().nextInt(5) + 1;
});
}
@OverRide
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color.fromARGB(255, 3, 132, 132),
appBar: AppBar(
title: const Center(child: Text('AMA Magic Ball')),
backgroundColor: const Color.fromARGB(255, 3, 124, 112),
),
body: Center(
child: Expanded(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.transparent,
shadowColor: Colors.transparent,
),
onPressed: () {
updAmaBall();
print('Ball clicked!');
},
child: Image.asset('images/ball$amaBall.png'),
),
),
),
),
);
}
}**
import 'package:flutter/material.dart';
import 'dart:math';
void main() {
runApp(
MagicBall(),
);
}
class MagicBall extends StatefulWidget {
@OverRide
_MagicBallState createState() => _MagicBallState();
}
class _MagicBallState extends State {
int ans = 1;
void pressed() {
setState(() {
ans = Random().nextInt(5) + 1;
});
}
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Ask Me Anything'),
backgroundColor: Colors.blue[900],
),
backgroundColor: Colors.blue,
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
onPressed: () {
pressed();
},
child: Image(
image: AssetImage('images/ball$ans.png'),
),
),
],
),
),
);
}
}
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
runApp(
MagicBall(),
);
}
class MagicBall extends StatefulWidget {
const MagicBall({Key? key}) : super(key: key);
@OverRide
State createState() => _MagicBallState();
}
class _MagicBallState extends State {
int num = Random().nextInt(5) + 1;
void pressed() {
setState(() {
num = 1 + Random().nextInt(5);
});
}
@OverRide
Widget build(BuildContext context) {
var ans;
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: Text('Ask me anything'),
backgroundColor: Colors.blue.shade900,
centerTitle: true,
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
onPressed: () {
pressed();
},
child: Image(
image: AssetImage('image/ball$num.png'),
),
),
],
),
),
);
}
}
@OverRide
Widget build(BuildContext context) {
// TODO: implement build
throw UnimplementedError();
}
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
home: Scaffold(
backgroundColor: Colors.lime,
appBar: AppBar(
title: const Center(
child: Text(
'Ask Me every thing',
),
),
),
body: const MyApp(),
),
),
);
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@OverRide
State createState() => _MyAppState();
}
class _MyAppState extends State {
int a = 1;
void gd(){
setState(() {
a=Random().nextInt(5)+1;
});
}
@OverRide
Widget build(BuildContext context) {
return Center(
child: Row(
children: [
Expanded(
child: TextButton(
onPressed: () {
gd();
},
child: Image.asset('images/ball$a.png'),
),
),
],
),
);
}
}
// This is my WhatsApp number for connection
import 'package: flutter/material.dart';
void main() => runApp(
MaterialApp(
home: BallPage(),
),
);
class BallPage extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.red,
appBar: AppBar(
backgroundColor: Colors.red.Shade700,
title: Text('Uforo Ekong is my name'),
),
body: Container(),
);
}
}
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
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';
void main() => runApp(
MaterialApp(
home: BollPage(),
),
);
class BollPage extends StatelessWidget {
const BollPage({Key key}) : super(key: key);
@OverRide
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blue,
appBar: AppBar(
backgroundColor: Colors.blue[900],
title: Text('Ask Me Any thing'),
),
body: Container(),
);
}
}