repo_id
stringlengths 21
168
| file_path
stringlengths 36
210
| content
stringlengths 1
9.98M
| __index_level_0__
int64 0
0
|
---|---|---|---|
mirrored_repositories/flutter-basics/dice_roller | mirrored_repositories/flutter-basics/dice_roller/lib/HomePage.dart | import 'package:flutter/material.dart';
import 'dart:math';
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
AssetImage one = AssetImage('images/one.png');
AssetImage two = AssetImage('images/two.png');
AssetImage three = AssetImage('images/three.png');
AssetImage four = AssetImage('images/four.png');
AssetImage five = AssetImage('images/five.png');
AssetImage six = AssetImage('images/six.png');
AssetImage diceImage;
// method to show image whenever application load first time
@override
void initState() {
super.initState();
setState(() {
diceImage = one;
});
}
void rollDice() {
int random = (1 + Random().nextInt(6));
AssetImage newImage;
switch (random) {
case 1:
newImage = one;
break;
case 2:
newImage = two;
break;
case 3:
newImage = three;
break;
case 4:
newImage = four;
break;
case 5:
newImage = five;
break;
case 6:
newImage = six;
break;
}
setState(() {
diceImage = newImage;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Dice Roller'),
),
body: Container(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image(
image: diceImage,
width: 200,
height: 200,
),
Container(
margin: EdgeInsets.only(top: 100),
child: RaisedButton(
padding: EdgeInsets.fromLTRB(30, 15, 30, 15),
onPressed: rollDice,
child: Text(
'Roll Dice!',
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
),
color: Colors.yellow,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30)),
),
)
],
))),
);
}
}
| 0 |
mirrored_repositories/flutter-basics/dice_roller | mirrored_repositories/flutter-basics/dice_roller/lib/main.dart | import 'package:flutter/material.dart';
import 'HomePage.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Dice Roller',
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.yellow),
home: HomePage(),
);
}
}
| 0 |
mirrored_repositories/flutter-basics/dice_roller | mirrored_repositories/flutter-basics/dice_roller/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:dice_roller/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/flutter-basics/firebaselogin | mirrored_repositories/flutter-basics/firebaselogin/lib/SigninPage.dart | import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
class SigninPage extends StatefulWidget {
@override
_SigninPageState createState() => _SigninPageState();
}
class _SigninPageState extends State<SigninPage> {
final FirebaseAuth _auth = FirebaseAuth.instance;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
String _email, _password;
checkAuthentication() async {
_auth.onAuthStateChanged.listen((user) async {
if (user != null) {
Navigator.pushReplacementNamed(context, '/');
}
});
}
navigateToSignupScreen() {
Navigator.pushReplacementNamed(context, '/SignupPage');
}
@override
void initState() {
super.initState();
this.checkAuthentication();
}
void signin() async {
if (_formKey.currentState.validate()) {
_formKey.currentState.save();
try {
AuthResult user = await _auth.signInWithEmailAndPassword(
email: _email, password: _password);
} catch (e) {
showError(e.message);
}
}
}
showError(String errorMessage) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Error'),
content: Text(errorMessage),
actions: <Widget>[
FlatButton(
child: Text('OK'),
onPressed: () {
Navigator.of(context).pop();
},
)
],
);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('SignIn'),
),
body: Container(
child: Center(
child: ListView(
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(10, 50, 10, 50),
child: Image(
image: AssetImage('assets/logo.png'),
width: 100,
height: 100,
),
),
Container(
padding: EdgeInsets.all(15),
child: Form(
key: _formKey,
child: Column(
children: <Widget>[
//email
Container(
padding: EdgeInsets.only(top: 10),
child: TextFormField(
validator: (input) {
if (input.isEmpty) {
return 'Enter email';
}
},
decoration: InputDecoration(
labelText: 'Email',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5)),
),
onSaved: (input) => _email = input,
),
),
//Password
Container(
padding: EdgeInsets.only(top: 10),
child: TextFormField(
validator: (input) {
if (input.length < 6) {
return 'Password should be atleast 6 char';
}
},
decoration: InputDecoration(
labelText: 'Password',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5)),
),
onSaved: (input) => _password = input,
obscureText: true,
),
),
//submit
Container(
padding: EdgeInsets.fromLTRB(0, 20, 0, 40),
child: RaisedButton(
padding: EdgeInsets.fromLTRB(100, 20, 100, 20),
color: Colors.blue,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5)),
onPressed: signin,
child: Text(
'Sign In',
style: TextStyle(color: Colors.white, fontSize: 20),
),
),
),
//redirect to sign up page
GestureDetector(
onTap: navigateToSignupScreen,
child: Text(
'Create an account?',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20),
),
)
],
),
),
)
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/flutter-basics/firebaselogin | mirrored_repositories/flutter-basics/firebaselogin/lib/HomePage.dart | import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final FirebaseAuth _auth = FirebaseAuth.instance;
FirebaseUser user;
bool isSignedIn = false;
checkAuthentication() async {
_auth.onAuthStateChanged.listen((user) async {
if (user == null) {
Navigator.pushReplacementNamed(context, '/SigninPage');
}
});
}
getUser() async {
FirebaseUser firebaseUser = await _auth.currentUser();
// ISSUE: https://github.com/flutter/flutter/issues/19746
await firebaseUser?.reload();
firebaseUser = await _auth.currentUser();
if (firebaseUser != null) {
setState(() {
this.user = firebaseUser;
isSignedIn = true;
});
}
print(this.user);
}
sigOut() async {
_auth.signOut();
}
@override
void initState() {
super.initState();
this.checkAuthentication();
this.getUser();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Home'),
),
body: Container(
child: Center(
child: !isSignedIn
? CircularProgressIndicator()
: Column(
children: <Widget>[
Container(
padding: EdgeInsets.all(50),
child: Image(
image: AssetImage('assets/logo.png'),
width: 100,
height: 100,
),
),
Container(
padding: EdgeInsets.all(50),
child: Text(
'Hello ${user.displayName} you are logged in as ${user.email}',
style: TextStyle(fontSize: 20),
),
),
Container(
padding: EdgeInsets.all(20),
child: RaisedButton(
color: Colors.blue,
padding: EdgeInsets.fromLTRB(100, 20, 100, 20),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5)),
onPressed: sigOut,
child: Text(
'Sign Out',
style: TextStyle(color: Colors.white, fontSize: 20),
),
),
),
],
)),
),
);
}
}
| 0 |
mirrored_repositories/flutter-basics/firebaselogin | mirrored_repositories/flutter-basics/firebaselogin/lib/SingnupPage.dart | import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
class SignupPage extends StatefulWidget {
@override
_SignupPageState createState() => _SignupPageState();
}
class _SignupPageState extends State<SignupPage> {
final FirebaseAuth _auth = FirebaseAuth.instance;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
String _name, _email, _password;
checkAuthentication() async {
_auth.onAuthStateChanged.listen((user) {
if (user != null) {
Navigator.pushReplacementNamed(context, '/');
}
});
}
navigateToSigninScreen() {
Navigator.pushReplacementNamed(context, '/SigninPage');
}
@override
void initState() {
super.initState();
checkAuthentication();
}
signUp() async {
if (_formKey.currentState.validate()) {
_formKey.currentState.save();
try {
AuthResult user = await _auth.createUserWithEmailAndPassword(
email: _email, password: _password);
if (user != null) {
UserUpdateInfo updateUser = UserUpdateInfo();
updateUser.displayName = _name;
print(_name);
// user.updateProfile(updateUser);
}
} catch (e) {
showError(e.message);
}
}
}
showError(String errorMessage) {
return showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Error'),
content: Text(errorMessage),
actions: <Widget>[
FlatButton(
child: Text('OK'),
onPressed: () {
Navigator.of(context).pop();
},
)
],
);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('SignUp'),
),
body: Container(
child: Center(
child: ListView(
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(10, 50, 10, 50),
child: Image(
image: AssetImage('assets/logo.png'),
width: 100,
height: 100,
),
),
Container(
padding: EdgeInsets.all(15),
child: Form(
key: _formKey,
child: Column(
children: <Widget>[
// display name
Container(
padding: EdgeInsets.only(top: 10),
child: TextFormField(
validator: (input) {
if (input.isEmpty) {
return 'Enter name';
}
},
decoration: InputDecoration(
labelText: 'Name',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5)),
),
onSaved: (input) => _name = input,
),
),
//email
Container(
padding: EdgeInsets.only(top: 10),
child: TextFormField(
validator: (input) {
if (input.isEmpty) {
return 'Enter email';
}
},
decoration: InputDecoration(
labelText: 'Email',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5)),
),
onSaved: (input) => _email = input,
),
),
//Password
Container(
padding: EdgeInsets.only(top: 10),
child: TextFormField(
validator: (input) {
if (input.length < 6) {
return 'Password should be atleast 6 char';
}
},
decoration: InputDecoration(
labelText: 'Password',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5)),
),
onSaved: (input) => _password = input,
obscureText: true,
),
),
//submit
Container(
padding: EdgeInsets.fromLTRB(0, 20, 0, 20),
child: RaisedButton(
padding: EdgeInsets.fromLTRB(100, 20, 100, 20),
color: Colors.blue,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5)),
onPressed: signUp,
child: Text(
'Sign Up',
style: TextStyle(color: Colors.white, fontSize: 20),
),
),
),
//redirect to sign up page
GestureDetector(
onTap: navigateToSigninScreen,
child: Text(
'Sign In?',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20),
),
)
],
),
),
)
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/flutter-basics/firebaselogin | mirrored_repositories/flutter-basics/firebaselogin/lib/main.dart | import 'package:flutter/material.dart';
import 'HomePage.dart';
import 'SigninPage.dart';
import 'SingnupPage.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Firebase login',
home: HomePage(),
routes: <String, WidgetBuilder>{
'/SigninPage': (BuildContext context) => SigninPage(),
'/SignupPage': (BuildContext context) => SignupPage(),
},
);
}
}
| 0 |
mirrored_repositories/flutter-basics/firebaselogin | mirrored_repositories/flutter-basics/firebaselogin/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:firebaselogin/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/flutter-basics/calculatorApp | mirrored_repositories/flutter-basics/calculatorApp/lib/HomePage.dart | import 'package:flutter/material.dart';
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
var num1 = 0, num2 = 0, sum = 0;
double divide = 0.0;
final TextEditingController t1 = TextEditingController(text: '');
final TextEditingController t2 = TextEditingController(text: '');
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.red,
title: Text(
'Calculator',
style: TextStyle(color: Colors.white),
),
),
body: Container(
padding: EdgeInsets.all(40),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Output:$sum',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.purple),
),
TextField(
keyboardType: TextInputType.number,
decoration: InputDecoration(
hintText: 'Enter Number 1',
),
controller: t1,
),
TextField(
keyboardType: TextInputType.number,
decoration: InputDecoration(
hintText: 'Enter Number 2',
),
controller: t2,
),
Padding(padding: EdgeInsets.all(20)),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
MaterialButton(
onPressed: () {
debugPrint('Add button clicked');
doAddition();
},
child: Text(
'+',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
color: Colors.greenAccent,
),
MaterialButton(
onPressed: () {
debugPrint('Sub button clicked');
doSubtraction();
},
child: Text(
'-',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
color: Colors.greenAccent,
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
MaterialButton(
onPressed: () {
debugPrint('Mul button clicked');
doMultiply();
},
child: Text(
'*',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
color: Colors.greenAccent,
),
MaterialButton(
onPressed: () {
debugPrint('Div button clicked');
doDivide();
},
child: Text(
'/',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
),
color: Colors.greenAccent,
)
],
),
Padding(padding: EdgeInsets.only(top: 10)),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
onPressed: () {
debugPrint('clear button clicked');
doClear();
},
child: Text(
'Clear',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
color: Colors.greenAccent,
)
],
)
],
),
),
);
}
void doAddition() {
num1 = int.parse(t1.text);
num2 = int.parse(t2.text);
setState(() {
sum = num1 + num2;
});
}
void doSubtraction() {
num1 = int.parse(t1.text);
num2 = int.parse(t2.text);
setState(() {
sum = num1 - num2;
});
}
void doMultiply() {
num1 = int.parse(t1.text);
num2 = int.parse(t2.text);
setState(() {
sum = num1 * num2;
});
}
void doDivide() {
num1 = int.parse(t1.text);
num2 = int.parse(t2.text);
setState(() {
sum = num1 ~/ num2;
});
}
void doClear() {
setState(() {
t1.text = '0';
t2.text = '0';
sum = 0;
});
}
}
| 0 |
mirrored_repositories/flutter-basics/calculatorApp | mirrored_repositories/flutter-basics/calculatorApp/lib/main.dart | import 'package:flutter/material.dart';
import 'HomePage.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Calculator',
debugShowCheckedModeBanner: false,
home: HomePage(),
);
}
}
| 0 |
mirrored_repositories/flutter-basics/calculatorApp | mirrored_repositories/flutter-basics/calculatorApp/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:calculatorApp/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/flutter-basics/simple_SI_calculator | mirrored_repositories/flutter-basics/simple_SI_calculator /lib/main.dart | import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
title: 'Simple Interest Calculator',
debugShowCheckedModeBanner: false,
home: SiForm(),
theme: ThemeData(
primaryColor: Colors.indigo,
accentColor: Colors.indigoAccent,
brightness: Brightness.dark),
));
}
class SiForm extends StatefulWidget {
@override
_SiFormState createState() => _SiFormState();
}
class _SiFormState extends State<SiForm> {
var _formKey = GlobalKey<FormState>();
final _minPadding = 5.0;
var _currencies = ['Rupees', 'Dollar', 'Pounds'];
var _currentItemSelected = '';
@override
void initState() {
super.initState();
_currentItemSelected = _currencies[0];
}
TextEditingController principalController = TextEditingController();
TextEditingController roiController = TextEditingController();
TextEditingController termController = TextEditingController();
String displayResult = '';
@override
Widget build(BuildContext context) {
TextStyle textStyle = Theme.of(context).textTheme.headline6;
return Scaffold(
appBar: AppBar(
title: Text('Simple Interest calculator'),
),
body: Form(
key: _formKey,
child: Padding(
padding: EdgeInsets.all(_minPadding * 2),
child: ListView(
children: <Widget>[
getAssetImage(),
Padding(
padding:
EdgeInsets.only(top: _minPadding, bottom: _minPadding),
child: TextFormField(
controller: principalController,
keyboardType: TextInputType.number,
style: textStyle,
decoration: InputDecoration(
errorStyle: TextStyle(
color: Colors.yellowAccent,
fontSize: 15.0,
),
labelText: 'Principal',
labelStyle: textStyle,
hintText: 'Enter Principal e.g. 1200',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5))),
validator: (String value) {
if (value.isEmpty) {
return 'Please enter Principal amount';
} else if (double.tryParse(value) == null) {
return 'Please enter valid Principal Amount';
}
},
),
),
Padding(
padding:
EdgeInsets.only(top: _minPadding, bottom: _minPadding),
child: TextFormField(
controller: roiController,
keyboardType: TextInputType.number,
style: textStyle,
validator: (String value) {
if (value.isEmpty) {
return 'Please enter Rate of Interest';
} else if (double.tryParse(value) == null) {
return 'Please enter valid Rate of Interest';
}
},
decoration: InputDecoration(
errorStyle: TextStyle(
color: Colors.yellow,
fontSize: 15.0,
),
labelText: 'Rate of Interest',
labelStyle: textStyle,
hintText: 'In percent',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5))),
),
),
Padding(
padding:
EdgeInsets.only(top: _minPadding, bottom: _minPadding),
child: Row(
children: <Widget>[
Expanded(
child: TextFormField(
validator: (String value) {
if (value.isEmpty) {
return 'Please enter Time';
} else if (double.tryParse(value) == null) {
return 'Please enter valid Time';
}
},
controller: termController,
keyboardType: TextInputType.number,
style: textStyle,
decoration: InputDecoration(
errorStyle: TextStyle(
color: Colors.yellowAccent,
fontSize: 15.0,
),
labelText: 'In Terms',
labelStyle: textStyle,
hintText: 'Time in years',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5))),
),
),
Container(
width: _minPadding * 5,
),
Expanded(
child: DropdownButton(
items: _currencies.map((String value) {
return DropdownMenuItem(
child: Text(value),
value: value,
);
}).toList(),
value: _currentItemSelected,
onChanged: (String newValueSelected) {
//your coede here
_onDropItemSelected(newValueSelected);
}),
)
],
),
),
Padding(
padding:
EdgeInsets.only(top: _minPadding, bottom: _minPadding),
child: Row(
children: <Widget>[
Expanded(
child: RaisedButton(
onPressed: () {
setState(() {
if (_formKey.currentState.validate()) {
this.displayResult = _calculateTotalreturns();
}
});
},
color: Theme.of(context).accentColor,
textColor: Theme.of(context).primaryColorDark,
child: Text(
'Calculate',
textScaleFactor: 1.5,
),
),
),
Expanded(
child: RaisedButton(
onPressed: () {
setState(() {
_reset();
});
},
color: Theme.of(context).primaryColorDark,
textColor: Theme.of(context).primaryColorLight,
child: Text(
'Reset',
textScaleFactor: 1.5,
),
),
)
],
),
),
Padding(
padding:
EdgeInsets.only(top: _minPadding, bottom: _minPadding),
child: Text(
displayResult,
style: textStyle,
),
)
],
)),
),
);
}
//Get image function
Widget getAssetImage() {
AssetImage assetImage = AssetImage('images/money.png');
Image image = Image(
image: assetImage,
width: 125,
height: 125,
);
return Container(
margin: EdgeInsets.all(_minPadding * 10),
child: image,
);
}
// Drop Down menu selected item function
void _onDropItemSelected(newValueSelected) {
setState(() {
this._currentItemSelected = newValueSelected;
});
}
// To calculate function
String _calculateTotalreturns() {
double principal = double.parse(principalController.text);
double roi = double.parse(roiController.text);
double term = double.parse(termController.text);
double totalAmountPayable = principal + (principal * roi * term) / 100;
String result =
'After $term years, your Investment wille be worth $totalAmountPayable $_currentItemSelected';
return result;
}
// Reset function
void _reset() {
principalController.text = '';
roiController.text = '';
termController.text = '';
displayResult = '';
_currentItemSelected = _currencies[0];
}
bool checkNumber(String value) {
try {
num.parse(value);
} on FormatException {
return true;
}
return false;
}
}
| 0 |
mirrored_repositories/flutter-basics/simple_SI_calculator | mirrored_repositories/flutter-basics/simple_SI_calculator /test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:simple_SI_calculator/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/flutter-basics/bg_change | mirrored_repositories/flutter-basics/bg_change/lib/main.dart | import 'package:flutter/material.dart';
import 'dart:math';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'BG Chnager',
debugShowCheckedModeBanner: false,
theme: ThemeData.dark(),
home: Scaffold(
appBar: AppBar(
title: Text('Random Background'),
),
body: HomePage(),
));
}
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
var colors = [
Colors.accents,
Colors.amber,
Colors.black38,
Colors.blue,
Colors.blueGrey,
Colors.brown,
Colors.cyan,
Colors.green,
Colors.yellow,
Colors.grey,
Colors.deepPurple,
Colors.pink
];
var currentColors = Colors.white;
@override
Widget build(BuildContext context) {
return Container(
color: currentColors,
child: Center(
child: RaisedButton(
onPressed: setRandomColor,
color: currentColors,
padding: EdgeInsets.fromLTRB(20, 10, 20, 10),
child: Text(
'Change !!',
style: TextStyle(
fontSize: 24, fontWeight: FontWeight.bold, color: Colors.black),
),
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
),
),
);
}
setRandomColor() {
var rnd = Random().nextInt(colors.length);
debugPrint(rnd.toString());
setState(() {
currentColors = colors[rnd];
});
}
}
| 0 |
mirrored_repositories/flutter-basics/bg_change | mirrored_repositories/flutter-basics/bg_change/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:bgchange/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/flutter-basics/signupApp | mirrored_repositories/flutter-basics/signupApp/lib/HomePage.dart | import 'package:flutter/material.dart';
class HomePage extends StatelessWidget {
final String name, password, email, mobile, college;
HomePage(
{Key key,
@required this.name,
this.password,
this.email,
this.mobile,
this.college})
: super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Info'),
),
body: Form(
child: Card(
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)),
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.all(10.0),
),
Image(
image: AssetImage('images/logo.png'),
),
ListTile(
leading: Icon(Icons.person),
title: Text(name),
),
ListTile(
leading: Icon(Icons.account_balance_wallet),
title: Text(password),
),
ListTile(
leading: Icon(Icons.email),
title: Text(email),
),
ListTile(
leading: Icon(Icons.mobile_screen_share),
title: Text(mobile),
),
ListTile(
leading: Icon(Icons.school),
title: Text(college),
),
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/flutter-basics/signupApp | mirrored_repositories/flutter-basics/signupApp/lib/main.dart | import 'package:flutter/material.dart';
import 'SignUpPage.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'user details app',
debugShowCheckedModeBanner: false,
theme: ThemeData.dark(),
home: SignUpPage(),
);
}
}
| 0 |
mirrored_repositories/flutter-basics/signupApp | mirrored_repositories/flutter-basics/signupApp/lib/SignUpPage.dart | import 'package:flutter/material.dart';
import 'package:signupApp/SignUpPage.dart';
import 'HomePage.dart';
class SignUpPage extends StatefulWidget {
@override
_SignUpPageState createState() => _SignUpPageState();
}
class _SignUpPageState extends State<SignUpPage> {
GlobalKey<FormState> _key = GlobalKey();
bool _autovalidate = false;
String name, password, email, mobile, college;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.orange,
appBar: AppBar(
title: Text('Sign up '),
),
body: SingleChildScrollView(
child: Form(
key: _key,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(35.0)),
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.all(10.0),
),
Image(
image: AssetImage('images/logo.png'),
width: 100.0,
height: 100.0,
),
ListTile(
leading: Icon(Icons.person),
title: TextFormField(
validator: (input) {
if (input.isEmpty) {
return 'Enter name';
}
},
decoration: InputDecoration(labelText: 'Name'),
onSaved: (input) => name = input,
),
),
ListTile(
leading: Icon(Icons.account_balance_wallet),
title: TextFormField(
validator: (input) {
if (input.isEmpty) {
return 'Enter Password';
}
},
decoration: InputDecoration(
labelText: 'Password',
),
onSaved: (input) => password = input,
obscureText: true,
),
),
ListTile(
leading: Icon(Icons.email),
title: TextFormField(
validator: (input) {
if (input.isEmpty) {
return 'Enter Email';
}
},
decoration: InputDecoration(labelText: 'Email'),
onSaved: (input) => email = input,
),
),
ListTile(
leading: Icon(Icons.mobile_screen_share),
title: TextFormField(
validator: (input) {
if (input.isEmpty) {
return 'Enter Mobile';
}
},
decoration: InputDecoration(labelText: 'Mobile'),
onSaved: (input) => mobile = input,
),
),
ListTile(
leading: Icon(Icons.school),
title: TextFormField(
validator: (input) {
if (input.isEmpty) {
return 'Enter College';
}
},
decoration: InputDecoration(labelText: 'College'),
onSaved: (input) => college = input,
),
),
Padding(
padding: EdgeInsets.all(10.0),
),
ButtonTheme(
height: 40.0,
minWidth: 200.0,
child: RaisedButton(
color: Colors.redAccent,
onPressed: _sendToNextScreen,
child: Text(
'Save',
style: TextStyle(color: Colors.white),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0)),
),
),
Padding(
padding: EdgeInsets.all(10.0),
),
],
),
),
),
),
);
}
_sendToNextScreen() {
if (_key.currentState.validate()) {
//saves to global key
_key.currentState.save();
//send to next screen
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => HomePage(
name: name,
password: password,
email: email,
mobile: mobile,
college: college,
)));
} else {
setState(() {
_autovalidate = true;
});
}
}
}
| 0 |
mirrored_repositories/flutter-basics/signupApp | mirrored_repositories/flutter-basics/signupApp/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:signupApp/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/flutter-basics/adobeXD01 | mirrored_repositories/flutter-basics/adobeXD01/lib/Card4.dart | import 'package:flutter/material.dart';
import './ViewAllButton.dart';
class Card4 extends StatelessWidget {
Card4({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
// Adobe XD layer: 'coding3' (shape)
Container(
width: 158.0,
height: 210.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: const Color(0xffffffff),
),
),
// Adobe XD layer: 'coding3' (shape)
Container(
width: 158.0,
height: 210.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
image: DecorationImage(
image: const AssetImage(''),
fit: BoxFit.cover,
),
),
),
Transform.translate(
offset: Offset(0.0, 14.0),
child: Text(
'Courses',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 16,
color: const Color(0xcb080000),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.left,
),
),
Transform.translate(
offset: Offset(0.0, 34.0),
child: Text(
'Courses for new\nstudent ',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 14,
color: const Color(0x80080000),
fontWeight: FontWeight.w500,
height: 1.2857142857142858,
),
textAlign: TextAlign.left,
),
),
Transform.translate(
offset: Offset(111.0, 172.0),
child:
// Adobe XD layer: 'ViewAllButton' (component)
ViewAllButton(),
),
Transform.translate(
offset: Offset(120.0, 172.0),
child: Text(
'View All',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 8,
color: const Color(0xffffffff),
fontWeight: FontWeight.w500,
height: 2.25,
),
textAlign: TextAlign.left,
),
),
],
);
}
}
| 0 |
mirrored_repositories/flutter-basics/adobeXD01 | mirrored_repositories/flutter-basics/adobeXD01/lib/Logo.dart | import 'package:flutter/material.dart';
class Logo extends StatelessWidget {
Logo({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
Text(
'C',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 32,
color: const Color(0xfff4b000),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.left,
),
Transform.translate(
offset: Offset(20.0, 4.0),
child: Text(
'ourses',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 28,
color: const Color(0xffffffff),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.left,
),
),
],
);
}
}
| 0 |
mirrored_repositories/flutter-basics/adobeXD01 | mirrored_repositories/flutter-basics/adobeXD01/lib/InputLabel.dart | import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
class InputLabel extends StatelessWidget {
InputLabel({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
Transform.translate(
offset: Offset(1.0, 58.0),
child:
// Adobe XD layer: 'text_path' (shape)
SvgPicture.string(
_svg_dkvulo,
allowDrawingOutsideViewBox: true,
),
),
Transform.translate(
offset: Offset(0.0, 24.0),
child:
// Adobe XD layer: 'input_text' (text)
Text(
'[email protected]',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 20,
color: const Color(0xbcf7f2f2),
fontWeight: FontWeight.w500,
height: 1.2,
),
textAlign: TextAlign.left,
),
),
// Adobe XD layer: 'single_line_input_l…' (text)
Text(
'Email:',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 20,
color: const Color(0xffffffff),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.left,
),
],
);
}
}
const String _svg_dkvulo =
'<svg viewBox="1.0 58.0 342.0 1.0" ><path transform="translate(0.0, -6.0)" d="M 0.9999999403953552 64 L 342.9999694824219 64" fill="none" stroke="#ffffff" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /></svg>';
| 0 |
mirrored_repositories/flutter-basics/adobeXD01 | mirrored_repositories/flutter-basics/adobeXD01/lib/InputForm.dart | import 'package:flutter/material.dart';
import './InputLabel.dart';
class InputForm extends StatelessWidget {
InputForm({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
Text(
'YOUR WORK EMAIL',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 28,
color: const Color(0xffffffff),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.left,
),
Transform.translate(
offset: Offset(0.0, 48.0),
child:
// Adobe XD layer: 'InputLabel' (component)
InputLabel(),
),
Transform.translate(
offset: Offset(0.0, 130.0),
child:
// Adobe XD layer: 'InputPasswordLabel' (component)
InputLabel(),
),
],
);
}
}
| 0 |
mirrored_repositories/flutter-basics/adobeXD01 | mirrored_repositories/flutter-basics/adobeXD01/lib/SearchField.dart | import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
class SearchField extends StatelessWidget {
SearchField({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
Transform.translate(
offset: Offset(0.0, 2.0),
child: Container(
width: 344.0,
height: 55.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.0),
color: const Color(0xffffffff),
border: Border.all(width: 1.0, color: const Color(0xff707070)),
),
),
),
Transform.translate(
offset: Offset(314.0, 17.0),
child: Container(
width: 1.0,
height: 4.0,
decoration: BoxDecoration(
color: const Color(0xff000000),
),
),
),
Transform.translate(
offset: Offset(286.0, 0.0),
child: Container(
width: 58.0,
height: 60.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(15.0),
bottomRight: Radius.circular(15.0),
),
color: const Color(0xff212226),
),
),
),
Transform.translate(
offset: Offset(296.0, 11.0),
child:
// Adobe XD layer: 'Icon awesome-search' (shape)
SvgPicture.string(
_svg_7bsvw1,
allowDrawingOutsideViewBox: true,
),
),
Transform.translate(
offset: Offset(26.0, 18.0),
child: Text(
'Looking For ..',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 18,
color: const Color(0x6c0b0000),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.left,
),
),
],
);
}
}
const String _svg_7bsvw1 =
'<svg viewBox="296.0 11.0 35.0 36.0" ><path transform="translate(296.0, 11.0)" d="M 34.71761322021484 31.12430381774902 L 27.86346054077148 24.11483192443848 C 27.55409812927246 23.7984561920166 27.13473701477051 23.62269401550293 26.69474983215332 23.62269401550293 L 25.57416152954102 23.62269401550293 C 27.47159767150879 21.14090347290039 28.59906196594238 18.01933288574219 28.59906196594238 14.62357139587402 C 28.59906196594238 6.545454978942871 22.19864845275879 0 14.29953098297119 0 C 6.400414943695068 0 0 6.545454978942871 0 14.62357139587402 C 0 22.70168876647949 6.400415420532227 29.24714279174805 14.29953098297119 29.24714279174805 C 17.62004852294922 29.24714279174805 20.67244911193848 28.09412956237793 23.09924507141113 26.15369415283203 L 23.09924507141113 27.29967880249023 C 23.09924507141113 27.7496337890625 23.2711124420166 28.17849540710449 23.58047866821289 28.494873046875 L 30.43462753295898 35.50434494018555 C 31.08085632324219 36.16521835327148 32.12582397460938 36.16521835327148 32.76517486572266 35.50434494018555 L 34.71073913574219 33.51469421386719 C 34.71073913574219 33.51469421386719 35.35696792602539 31.78517532348633 34.71761322021484 31.12430191040039 Z M 14.29953098297119 23.62269401550293 C 9.439064979553223 23.62269401550293 5.499820232391357 19.60120964050293 5.499820232391357 14.62357139587402 C 5.499820232391357 9.652963638305664 9.432190895080566 5.62445068359375 14.29953098297119 5.62445068359375 C 19.15999794006348 5.62445068359375 23.09924507141113 9.645933151245117 23.09924507141113 14.62357139587402 C 23.09924507141113 19.59418106079102 19.16687202453613 23.62269401550293 14.29953098297119 23.62269401550293 Z" fill="#ffffff" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /></svg>';
| 0 |
mirrored_repositories/flutter-basics/adobeXD01 | mirrored_repositories/flutter-basics/adobeXD01/lib/Appbar.dart | import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import './Logo.dart';
class Appbar extends StatelessWidget {
Appbar({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
// Adobe XD layer: 'Icon open-menu' (shape)
SvgPicture.string(
_svg_x11els,
allowDrawingOutsideViewBox: true,
),
Transform.translate(
offset: Offset(121.0, 0.0),
child:
// Adobe XD layer: 'Logo' (component)
Logo(),
),
Transform.translate(
offset: Offset(304.0, 0.0),
child:
// Adobe XD layer: 'peeps' (shape)
Container(
width: 40.0,
height: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.elliptical(20.0, 20.0)),
image: DecorationImage(
image: const AssetImage(''),
fit: BoxFit.cover,
),
),
),
),
],
);
}
}
const String _svg_x11els =
'<svg viewBox="0.0 0.0 30.0 30.0" ><path d="M 0 0 L 0 2.791385412216187 L 30 2.791385412216187 L 30 0 L 0 0 Z M 0 13.59855937957764 L 0 16.49063301086426 L 27.81631469726562 16.49063301086426 L 27.81631469726562 13.59855937957764 L 0 13.59855937957764 Z M 0 27.3344783782959 L 0 30.00000190734863 L 26.27934646606445 30.00000190734863 L 26.27934646606445 27.3344783782959 L 0 27.3344783782959 Z" fill="#ffffff" stroke="#ffffff" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" /></svg>';
| 0 |
mirrored_repositories/flutter-basics/adobeXD01 | mirrored_repositories/flutter-basics/adobeXD01/lib/LoginScreen.dart | import 'package:flutter/material.dart';
import './Logo.dart';
import './InputForm.dart';
import 'package:adobe_xd/page_link.dart';
import './PrimaryButton.dart';
import './CourcesScreen.dart';
import 'package:flutter_svg/flutter_svg.dart';
class LoginScreen extends StatelessWidget {
LoginScreen({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xff212226),
body: Stack(
children: <Widget>[
Transform.translate(
offset: Offset(137.0, 40.0),
child:
// Adobe XD layer: 'Logo' (component)
Logo(),
),
Transform.translate(
offset: Offset(85.0, 93.0),
child:
// Adobe XD layer: 'boy' (shape)
Container(
width: 206.0,
height: 350.6,
decoration: BoxDecoration(
image: DecorationImage(
image: const AssetImage(''),
fit: BoxFit.fill,
),
),
),
),
Transform.translate(
offset: Offset(16.0, 488.0),
child:
// Adobe XD layer: 'InputForm' (component)
InputForm(),
),
Transform.translate(
offset: Offset(195.0, 752.0),
child: PageLink(
links: [
PageLinkInfo(
transition: LinkTransition.SlideRight,
ease: Curves.easeOut,
duration: 0.3,
pageBuilder: () => CourcesScreen(),
),
],
child:
// Adobe XD layer: 'PrimaryButton' (component)
PrimaryButton(),
),
),
Transform.translate(
offset: Offset(18.0, 790.0),
child: SvgPicture.string(
_svg_l9x9yt,
allowDrawingOutsideViewBox: true,
),
),
],
),
);
}
}
const String _svg_l9x9yt =
'<svg viewBox="18.0 790.0 72.0 1.0" ><path transform="translate(18.0, 790.0)" d="M 0 0 L 7.03125 0 L 14.0625 0 L 21.87500190734863 0 L 25 0" fill="none" stroke="#ffffff" stroke-width="2" stroke-miterlimit="4" stroke-linecap="round" /><path transform="translate(55.0, 790.0)" d="M 0 0 L 4.21875 0 L 8.4375 0 L 13.12500190734863 0 L 15.00000095367432 0" fill="none" stroke="#ffffff" stroke-width="2" stroke-miterlimit="4" stroke-linecap="round" /><path transform="translate(80.0, 790.0)" d="M 0 0 L 2.812499761581421 0 L 5.624999523162842 0 L 8.750000953674316 0 L 10 0" fill="none" stroke="#ffffff" stroke-width="2" stroke-miterlimit="4" stroke-linecap="round" /></svg>';
| 0 |
mirrored_repositories/flutter-basics/adobeXD01 | mirrored_repositories/flutter-basics/adobeXD01/lib/Card3.dart | import 'package:flutter/material.dart';
import './ViewAllButton.dart';
class Card3 extends StatelessWidget {
Card3({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
// Adobe XD layer: 'coding2' (shape)
Container(
width: 158.0,
height: 210.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: const Color(0xffffffff),
),
),
// Adobe XD layer: 'coding2' (shape)
Container(
width: 158.0,
height: 210.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
image: DecorationImage(
image: const AssetImage(''),
fit: BoxFit.cover,
),
),
),
Transform.translate(
offset: Offset(0.0, 14.0),
child: Text(
'Courses',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 16,
color: const Color(0xcb080000),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.left,
),
),
Transform.translate(
offset: Offset(0.0, 34.0),
child: Text(
'Courses for new\nstudent ',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 14,
color: const Color(0x80080000),
fontWeight: FontWeight.w500,
height: 1.2857142857142858,
),
textAlign: TextAlign.left,
),
),
Transform.translate(
offset: Offset(111.0, 172.0),
child:
// Adobe XD layer: 'ViewAllButton' (component)
ViewAllButton(),
),
Transform.translate(
offset: Offset(120.0, 172.0),
child: Text(
'View All',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 8,
color: const Color(0xffffffff),
fontWeight: FontWeight.w500,
height: 2.25,
),
textAlign: TextAlign.left,
),
),
],
);
}
}
| 0 |
mirrored_repositories/flutter-basics/adobeXD01 | mirrored_repositories/flutter-basics/adobeXD01/lib/CourcesScreen.dart | import 'package:flutter/material.dart';
import './Appbar.dart';
import './SearchField.dart';
import './Card2.dart';
import './Card3.dart';
import './Card1.dart';
import './Card4.dart';
class CourcesScreen extends StatelessWidget {
CourcesScreen({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xff212226),
body: Stack(
children: <Widget>[
Transform.translate(
offset: Offset(320.0, 43.0),
child:
// Adobe XD layer: 'peeps' (shape)
Container(
width: 40.0,
height: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.elliptical(20.0, 20.0)),
color: const Color(0xffffffff),
),
),
),
Transform.translate(
offset: Offset(16.0, 40.0),
child:
// Adobe XD layer: 'Appbar' (component)
Appbar(),
),
Transform.translate(
offset: Offset(16.0, 90.0),
child: Text.rich(
TextSpan(
style: TextStyle(
fontFamily: 'Futura',
fontSize: 28,
color: const Color(0xffffffff),
),
children: [
TextSpan(
text: 'Hy ',
style: TextStyle(
fontWeight: FontWeight.w500,
),
),
TextSpan(
text: 'Mark',
style: TextStyle(
fontWeight: FontWeight.w700,
),
),
],
),
textAlign: TextAlign.left,
),
),
Transform.translate(
offset: Offset(16.0, 246.0),
child: Text.rich(
TextSpan(
style: TextStyle(
fontFamily: 'Futura',
fontSize: 24,
color: const Color(0xffffffff),
),
children: [
TextSpan(
text: 'Our Popular ',
style: TextStyle(
fontWeight: FontWeight.w500,
),
),
TextSpan(
text: 'Course',
style: TextStyle(
fontWeight: FontWeight.w700,
),
),
],
),
textAlign: TextAlign.left,
),
),
Transform.translate(
offset: Offset(16.0, 287.0),
child: Text(
'We would recommend these courses',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 14,
color: const Color(0xcbffffff),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.left,
),
),
Transform.translate(
offset: Offset(309.0, 252.0),
child: Text(
'View all',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 14,
color: const Color(0xffffffff),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.left,
),
),
Transform.translate(
offset: Offset(16.0, 156.0),
child:
// Adobe XD layer: 'SearchField' (component)
SearchField(),
),
Transform.translate(
offset: Offset(200.0, 357.0),
child:
// Adobe XD layer: 'Card2' (component)
Card2(),
),
Transform.translate(
offset: Offset(30.0, 569.0),
child:
// Adobe XD layer: 'Card3' (component)
Card3(),
),
Transform.translate(
offset: Offset(30.0, 343.0),
child:
// Adobe XD layer: 'Card1' (component)
Card1(),
),
Transform.translate(
offset: Offset(202.0, 583.0),
child:
// Adobe XD layer: 'Card4' (component)
Card4(),
),
],
),
);
}
}
| 0 |
mirrored_repositories/flutter-basics/adobeXD01 | mirrored_repositories/flutter-basics/adobeXD01/lib/PrimaryButton.dart | import 'package:flutter/material.dart';
class PrimaryButton extends StatelessWidget {
PrimaryButton({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
Container(
width: 180.0,
height: 60.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(60.0),
),
color: const Color(0xffffffff),
),
),
Transform.translate(
offset: Offset(53.0, 15.0),
child: Text(
'Sign In',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 24,
color: const Color(0xff000000),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.left,
),
),
],
);
}
}
| 0 |
mirrored_repositories/flutter-basics/adobeXD01 | mirrored_repositories/flutter-basics/adobeXD01/lib/Card2.dart | import 'package:flutter/material.dart';
import './ViewAllButton.dart';
class Card2 extends StatelessWidget {
Card2({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
// Adobe XD layer: 'coding1' (shape)
Container(
width: 160.0,
height: 210.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: const Color(0xffffffff),
),
),
// Adobe XD layer: 'coding1' (shape)
Container(
width: 160.0,
height: 210.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
image: DecorationImage(
image: const AssetImage(''),
fit: BoxFit.cover,
),
),
),
Transform.translate(
offset: Offset(0.0, 14.0),
child: Text(
'Courses',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 16,
color: const Color(0xcb080000),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.left,
),
),
Transform.translate(
offset: Offset(0.0, 30.0),
child: Text(
'Courses for new\nstudent ',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 14,
color: const Color(0x80080000),
fontWeight: FontWeight.w500,
height: 1.2857142857142858,
),
textAlign: TextAlign.left,
),
),
Transform.translate(
offset: Offset(106.0, 172.0),
child:
// Adobe XD layer: 'ViewAllButton' (component)
ViewAllButton(),
),
Transform.translate(
offset: Offset(115.0, 172.0),
child: Text(
'View All',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 8,
color: const Color(0xffffffff),
fontWeight: FontWeight.w500,
height: 2.25,
),
textAlign: TextAlign.left,
),
),
],
);
}
}
| 0 |
mirrored_repositories/flutter-basics/adobeXD01 | mirrored_repositories/flutter-basics/adobeXD01/lib/Card1.dart | import 'package:flutter/material.dart';
import './ViewAllButton.dart';
class Card1 extends StatelessWidget {
Card1({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
// Adobe XD layer: 'coding' (shape)
Container(
width: 158.0,
height: 210.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: const Color(0xffffffff),
),
),
Transform.translate(
offset: Offset(0.0, 14.0),
child:
// Adobe XD layer: 'coding' (shape)
Container(
width: 158.0,
height: 210.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
image: DecorationImage(
image: const AssetImage(''),
fit: BoxFit.cover,
),
),
),
),
Transform.translate(
offset: Offset(0.0, 14.0),
child: Text(
'Courses',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 16,
color: const Color(0xcb080000),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.left,
),
),
Transform.translate(
offset: Offset(0.0, 34.0),
child: Text(
'Courses for new\nstudent ',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 14,
color: const Color(0x80080000),
fontWeight: FontWeight.w500,
height: 1.2857142857142858,
),
textAlign: TextAlign.left,
),
),
Transform.translate(
offset: Offset(111.0, 172.0),
child:
// Adobe XD layer: 'ViewAllButton' (component)
ViewAllButton(),
),
Transform.translate(
offset: Offset(120.0, 172.0),
child: Text(
'View All',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 8,
color: const Color(0xffffffff),
fontWeight: FontWeight.w500,
height: 2.25,
),
textAlign: TextAlign.left,
),
),
// Adobe XD layer: 'coding' (shape)
Container(
width: 158.0,
height: 210.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: const Color(0xffffffff),
),
),
Transform.translate(
offset: Offset(0.0, 14.0),
child:
// Adobe XD layer: 'coding' (shape)
Container(
width: 158.0,
height: 210.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
image: DecorationImage(
image: const AssetImage(''),
fit: BoxFit.cover,
),
),
),
),
Transform.translate(
offset: Offset(0.0, 14.0),
child: Text(
'Courses',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 16,
color: const Color(0xcb080000),
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.left,
),
),
Transform.translate(
offset: Offset(0.0, 34.0),
child: Text(
'Courses for new\nstudent ',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 14,
color: const Color(0x80080000),
fontWeight: FontWeight.w500,
height: 1.2857142857142858,
),
textAlign: TextAlign.left,
),
),
Transform.translate(
offset: Offset(111.0, 172.0),
child:
// Adobe XD layer: 'ViewAllButton' (component)
ViewAllButton(),
),
Transform.translate(
offset: Offset(120.0, 172.0),
child: Text(
'View All',
style: TextStyle(
fontFamily: 'Futura',
fontSize: 8,
color: const Color(0xffffffff),
fontWeight: FontWeight.w500,
height: 2.25,
),
textAlign: TextAlign.left,
),
),
],
);
}
}
| 0 |
mirrored_repositories/flutter-basics/adobeXD01 | mirrored_repositories/flutter-basics/adobeXD01/lib/main.dart | import 'package:adobeXD01/LoginScreen.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
// This makes the visual density adapt to the platform that you run
// the app on. For desktop platforms, the controls will be smaller and
// closer together (more dense) than on mobile platforms.
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: LoginScreen(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
| 0 |
mirrored_repositories/flutter-basics/adobeXD01 | mirrored_repositories/flutter-basics/adobeXD01/lib/ViewAllButton.dart | import 'package:flutter/material.dart';
class ViewAllButton extends StatelessWidget {
ViewAllButton({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
Container(
width: 47.0,
height: 24.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: const Color(0xff000000),
),
),
],
);
}
}
| 0 |
mirrored_repositories/flutter-basics/adobeXD01 | mirrored_repositories/flutter-basics/adobeXD01/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:adobeXD01/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/flutter-basics/flutterChatApp | mirrored_repositories/flutter-basics/flutterChatApp/lib/ChatScreen.dart | import 'package:flutter/material.dart';
import 'chat_message.dart';
class ChatScreen extends StatefulWidget {
@override
_ChatScreenState createState() => _ChatScreenState();
}
class _ChatScreenState extends State<ChatScreen> {
TextEditingController _textController = TextEditingController();
final List<ChatMessage> _messages = <ChatMessage>[];
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Flexible(
child: ListView.builder(
padding: EdgeInsets.all(8),
reverse: true,
itemBuilder: (BuildContext context, int index) => _messages[index],
itemCount: _messages.length,
)),
Divider(
height: 1.0,
),
Container(
decoration: BoxDecoration(color: Theme.of(context).cardColor),
child: _textComposerWidget(),
)
],
);
}
Widget _textComposerWidget() {
return IconTheme(
data: IconThemeData(color: Colors.blue),
child: Container(
margin: EdgeInsets.symmetric(horizontal: 8.0),
//flexible use to cover entire width
child: Row(
children: <Widget>[
Flexible(
child: TextField(
decoration:
InputDecoration.collapsed(hintText: 'Send a message'),
controller: _textController,
onSubmitted: _handleSubmitted,
),
),
Container(
margin: EdgeInsets.symmetric(horizontal: 4.0),
child: IconButton(
icon: Icon(Icons.send),
onPressed: () {
return _handleSubmitted(_textController.text);
}),
)
],
),
),
);
}
void _handleSubmitted(String text) {
_textController.clear();
ChatMessage message = ChatMessage(
text: text,
);
setState(() {
_messages.insert(0, message);
});
}
}
| 0 |
mirrored_repositories/flutter-basics/flutterChatApp | mirrored_repositories/flutter-basics/flutterChatApp/lib/HomePage.dart | import 'package:flutter/material.dart';
import 'ChatScreen.dart';
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Frenzy Chat'),
),
body: ChatScreen());
}
}
| 0 |
mirrored_repositories/flutter-basics/flutterChatApp | mirrored_repositories/flutter-basics/flutterChatApp/lib/chat_message.dart | import 'package:flutter/material.dart';
const String _name = 'Prakash';
class ChatMessage extends StatelessWidget {
final String text;
ChatMessage({this.text});
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(vertical: 10.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: EdgeInsets.only(right: 16.0),
child: CircleAvatar(child: Text(_name[0])),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(_name, style: Theme.of(context).textTheme.subtitle1),
Container(
margin: EdgeInsets.only(top: 5.0),
child: Text(text),
)
],
)
],
),
);
}
}
| 0 |
mirrored_repositories/flutter-basics/flutterChatApp | mirrored_repositories/flutter-basics/flutterChatApp/lib/main.dart | import 'package:flutter/material.dart';
import 'HomePage.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Chat App',
home: HomePage(),
);
}
}
| 0 |
mirrored_repositories/flutter-basics/flutterChatApp | mirrored_repositories/flutter-basics/flutterChatApp/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutterChatApp/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/flutter-basics/randomusergenerator | mirrored_repositories/flutter-basics/randomusergenerator/lib/HomePage.dart | import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:convert';
import 'package:http/http.dart' as http;
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
List usersData;
bool isLoading = true;
final String url = 'https://randomuser.me/api/?results=50';
Future getData() async {
var response = await http
.get(Uri.encodeFull(url), headers: {'Accept': 'application/json'});
List data = json.decode(response.body)['results'];
setState(() {
usersData = data;
isLoading = false;
});
}
@override
void initState() {
super.initState();
this.getData();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Random Users'),
),
body: Center(
child: isLoading
? CircularProgressIndicator()
: ListView.builder(
itemCount: usersData == null ? 0 : usersData.length,
itemBuilder: (BuildContext context, int index) {
return Card(
child: Row(
children: <Widget>[
ClipOval(
child: Image(
width: 70,
height: 70,
image: NetworkImage(
usersData[index]['picture']['thumbnail']),
fit: BoxFit.cover,
),
),
Padding(padding: EdgeInsets.all(3)),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
usersData[index]['name']['title'] +
' ' +
usersData[index]['name']['first'] +
' ' +
usersData[index]['name']['last'],
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.bold),
),
Text('Phone: ${usersData[index]['phone']}'),
Text('Gender: ${usersData[index]['gender']}')
],
))
],
),
);
},
),
),
);
}
}
| 0 |
mirrored_repositories/flutter-basics/randomusergenerator | mirrored_repositories/flutter-basics/randomusergenerator/lib/main.dart | import 'package:flutter/material.dart';
import 'HomePage.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Random User Generator',
theme: ThemeData(primarySwatch: Colors.orange),
home: HomePage(),
);
}
}
| 0 |
mirrored_repositories/flutter-basics/randomusergenerator | mirrored_repositories/flutter-basics/randomusergenerator/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:randomusergenerator/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/flutter-basics/drawerApp | mirrored_repositories/flutter-basics/drawerApp/lib/MyHomePage.dart | import 'package:flutter/material.dart';
import 'Category.dart';
class MyhomePage extends StatefulWidget {
@override
_MyhomePageState createState() => _MyhomePageState();
}
class _MyhomePageState extends State<MyhomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Drawer App'),
),
drawer: Drawer(
child: ListView(
children: <Widget>[
UserAccountsDrawerHeader(
accountName: Text('Prakash'),
accountEmail: Text('[email protected]'),
currentAccountPicture: CircleAvatar(
backgroundColor: Colors.orange,
child: Text('PS'),
),
),
ListTile(
title: Text('Category'),
trailing: Icon(Icons.card_travel),
onTap: () => Navigator.of(context).pushNamed('/a'),
)
],
),
),
);
}
}
| 0 |
mirrored_repositories/flutter-basics/drawerApp | mirrored_repositories/flutter-basics/drawerApp/lib/Category.dart | import 'package:flutter/material.dart';
class Category extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Category'),
),
body: Center(
child: Text('This is category page'),
),
);
}
}
| 0 |
mirrored_repositories/flutter-basics/drawerApp | mirrored_repositories/flutter-basics/drawerApp/lib/main.dart | import 'package:flutter/material.dart';
import 'MyHomePage.dart';
import 'Category.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: ' Simple Drawer',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyhomePage(),
routes: <String, WidgetBuilder>{
"/a": (BuildContext context) => Category(),
},
);
}
}
| 0 |
mirrored_repositories/flutter-basics/drawerApp | mirrored_repositories/flutter-basics/drawerApp/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:drawerApp/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/flutter-basics/adobeXdDesign | mirrored_repositories/flutter-basics/adobeXdDesign/lib/XDColors.dart | import 'package:flutter/material.dart';
class XDColors {}
| 0 |
mirrored_repositories/flutter-basics/adobeXdDesign | mirrored_repositories/flutter-basics/adobeXdDesign/lib/main.dart | import 'package:flutter/material.dart';
import 'XD_iPhoneXRXSMax111.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
// This makes the visual density adapt to the platform that you run
// the app on. For desktop platforms, the controls will be smaller and
// closer together (more dense) than on mobile platforms.
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: XD_iPhoneXRXSMax111(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
| 0 |
mirrored_repositories/flutter-basics/adobeXdDesign | mirrored_repositories/flutter-basics/adobeXdDesign/lib/XD_iPhoneXRXSMax111.dart | import 'package:flutter/material.dart';
import 'dart:ui' as ui;
import 'package:flutter_svg/flutter_svg.dart';
class XD_iPhoneXRXSMax111 extends StatelessWidget {
XD_iPhoneXRXSMax111({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xffffffff),
body: Stack(
children: <Widget>[
Transform.translate(
offset: Offset(220.81, 172.36),
child: SvgPicture.string(
_shapeSVG_fc6cd6df4c4f4342b560670e8f7665b8,
allowDrawingOutsideViewBox: true,
),
),
Transform.translate(
offset: Offset(9.41, 51.78),
child: Stack(
children: <Widget>[
Transform.translate(
offset: Offset(276.64, 157.73),
child: Container(
width: 42.9,
height: 43.9,
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.elliptical(21.43, 21.93)),
color: const Color(0xffa0616a),
),
),
),
Transform.translate(
offset: Offset(245.42, 152.92),
child: SvgPicture.string(
_shapeSVG_d746baf3fd1c4d37bd15d3e26cb99e5a,
allowDrawingOutsideViewBox: true,
),
),
Transform.translate(
offset: Offset(306.49, 177.72),
child: Container(
width: 5.4,
height: 7.0,
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.elliptical(2.68, 3.52)),
color: const Color(0xffa0616a),
),
),
),
Transform.translate(
offset: Offset(0.0, 0.0),
child: SvgPicture.string(
_shapeSVG_5198e54f0b5e45ca9799e92cbdadc381,
allowDrawingOutsideViewBox: true,
),
),
Transform.translate(
offset: Offset(89.6, 55.1),
child: Container(
width: 45.4,
height: 46.5,
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.elliptical(22.7, 23.23)),
color: const Color(0xffffb9b9),
),
),
),
Transform.translate(
offset: Offset(44.3, 39.08),
child: SvgPicture.string(
_shapeSVG_e674c741e5dc4ea986b6425dcf161fee,
allowDrawingOutsideViewBox: true,
),
),
],
),
),
Transform.translate(
offset: Offset(0.0, 9.0),
child: Stack(
children: <Widget>[
Transform.translate(
offset: Offset(55.0, 370.0),
child: Text(
'MEETING APP',
style: TextStyle(
fontFamily: 'Geeza Pro',
fontSize: 44,
color: const Color(0xff6c63fc),
fontWeight: FontWeight.w700,
),
textAlign: TextAlign.left,
),
),
Transform.translate(
offset: Offset(44.0, 466.87),
child:
// Adobe XD layer: 'Email' (group)
Stack(
children: <Widget>[
Transform.translate(
offset: Offset(0.0, 34.13),
child: Container(
width: 327.0,
height: 1.0,
decoration: BoxDecoration(
color: const Color(0xff6c63fc),
),
),
),
Transform.translate(
offset: Offset(35.0, 0.13),
child: Text(
'[email protected]',
style: TextStyle(
fontFamily: 'Geeza Pro',
fontSize: 14,
color: const Color(0xff6c63fc),
),
textAlign: TextAlign.left,
),
),
Transform.translate(
offset: Offset(0.0, 4.13),
child:
// Adobe XD layer: 'Mail' (group)
SvgPicture.string(
_shapeSVG_ac1df27a9c114bb6bbad5fc1b942f9e7,
allowDrawingOutsideViewBox: true,
),
),
],
),
),
Transform.translate(
offset: Offset(44.0, 541.01),
child:
// Adobe XD layer: 'Password' (group)
Stack(
children: <Widget>[
Transform.translate(
offset: Offset(0.0, 33.99),
child: Container(
width: 327.0,
height: 1.0,
decoration: BoxDecoration(
color: const Color(0xff6c63fc),
),
),
),
Transform.translate(
offset: Offset(36.0, -0.01),
child: Text(
'●●●●●●●',
style: TextStyle(
fontFamily: 'Geeza Pro',
fontSize: 14,
color: const Color(0xff6c63fc),
),
textAlign: TextAlign.left,
),
),
Transform.translate(
offset: Offset(0.0, 0.99),
child:
// Adobe XD layer: 'Lock' (group)
Stack(
children: <Widget>[
Container(
width: 16.0,
height: 16.0,
decoration: BoxDecoration(),
),
Transform.translate(
offset: Offset(1.0, 0.0),
child: SvgPicture.string(
_shapeSVG_46438d9d58614ba8984fc764700753c7,
allowDrawingOutsideViewBox: true,
),
),
],
),
),
],
),
),
Transform.translate(
offset: Offset(44.0, 613.0),
child:
// Adobe XD layer: 'Continue' (group)
Stack(
children: <Widget>[
Container(
width: 327.0,
height: 48.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.0),
color: const Color(0xff6c63fc),
),
),
Transform.translate(
offset: Offset(132.0, 18.0),
child: SizedBox(
width: 64.0,
child: Text(
'CONTINUE',
style: TextStyle(
fontFamily: 'Geeza Pro',
fontSize: 10,
color: const Color(0xffffffff),
fontWeight: FontWeight.w700,
height: 1.2,
),
textAlign: TextAlign.center,
),
),
),
],
),
),
],
),
),
Transform.translate(
offset: Offset(0.0, 700.0),
child: Container(
width: 414.0,
height: 283.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.elliptical(207.0, 141.5)),
gradient: LinearGradient(
begin: Alignment(0.0, -0.46),
end: Alignment(0.0, 1.0),
colors: [const Color(0xff6c63fc), const Color(0xff36327e)],
stops: [0.0, 1.0],
),
border: Border.all(width: 1.0, color: const Color(0xff707070)),
),
),
),
Transform.translate(
offset: Offset(19.0, 265.0),
child:
// Adobe XD layer: 'Social' (group)
Stack(
children: <Widget>[
Transform.translate(
offset: Offset(144.0, 7.0),
child:
// Adobe XD layer: 'g+' (group)
Stack(
children: <Widget>[
Transform.translate(
offset: Offset(88.0, 449.0),
child: Container(
width: 56.0,
height: 56.0,
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.elliptical(28.0, 28.0)),
border: Border.all(
width: 1.0, color: const Color(0xffffffff)),
),
),
),
Transform.translate(
offset: Offset(108.0, 469.0),
child:
// Adobe XD layer: 'g+' (group)
Stack(
children: <Widget>[
Container(
width: 16.0,
height: 16.0,
decoration: BoxDecoration(),
),
Transform.translate(
offset: Offset(0.0, 3.0),
child: SvgPicture.string(
_shapeSVG_d3b8a614c5494a54b5b48376c5c2e143,
allowDrawingOutsideViewBox: true,
),
),
],
),
),
],
),
),
Transform.translate(
offset: Offset(0.0, 7.0),
child:
// Adobe XD layer: 'twitter' (group)
Stack(
children: <Widget>[
Transform.translate(
offset: Offset(180.0, 469.0),
child: Stack(
children: <Widget>[
Container(
width: 16.0,
height: 16.0,
decoration: BoxDecoration(),
),
Transform.translate(
offset: Offset(0.0, 2.0),
child: SvgPicture.string(
_shapeSVG_ef322ce8c41345588c217546eccfa06e,
allowDrawingOutsideViewBox: true,
),
),
],
),
),
Transform.translate(
offset: Offset(160.0, 449.0),
child: Container(
width: 56.0,
height: 56.0,
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.elliptical(28.0, 28.0)),
border: Border.all(
width: 1.0, color: const Color(0xffffffff)),
),
),
),
],
),
),
Transform.translate(
offset: Offset(-144.0, 7.0),
child:
// Adobe XD layer: 'facebook' (group)
Stack(
children: <Widget>[
Transform.translate(
offset: Offset(252.0, 469.0),
child: Stack(
children: <Widget>[
Container(
width: 16.0,
height: 16.0,
decoration: BoxDecoration(),
),
Transform.translate(
offset: Offset(4.0, 0.0),
child: SvgPicture.string(
_shapeSVG_397cfc2bbbe94ccb814c5dce693034c3,
allowDrawingOutsideViewBox: true,
),
),
],
),
),
Transform.translate(
offset: Offset(232.0, 449.0),
child: Container(
width: 56.0,
height: 56.0,
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.elliptical(28.0, 28.0)),
border: Border.all(
width: 1.0, color: const Color(0xffffffff)),
),
),
),
],
),
),
],
),
),
],
),
);
}
}
const String _shapeSVG_d746baf3fd1c4d37bd15d3e26cb99e5a =
'<svg viewBox="245.4 152.9 117.9 97.0" ><path transform="translate(-500.74, -393.43)" d="M 823.6882934570312 615.15869140625 L 785.4187622070312 619.07421875 C 788.956298828125 602.7815551757812 789.8136596679688 587.5599975585938 785.4187622070312 574.4373168945312 L 812.2075805664062 574.4373168945312 C 810.752197265625 585.3720092773438 816.1915893554688 599.75146484375 823.6882934570312 615.15869140625 Z" fill="#a0616a" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /><path transform="translate(-465.8, -421.65)" d="M 815.1594848632812 643.50341796875 C 814.6820678710938 653.0515747070312 814.1287841796875 662.44384765625 813.447021484375 671.59814453125 L 723.967041015625 671.59814453125 C 722.9082641601562 665.5540771484375 721.6209106445312 659.4717407226562 720.1049194335938 653.35107421875 C 719.11328125 649.396484375 721.0531616210938 645.2865600585938 724.6968383789062 643.6223754882812 L 727.5523071289062 642.3215942382812 L 752.7737426757812 630.8532104492188 L 753.0704345703125 630.9188232421875 L 763.489501953125 633.2001953125 L 781.8610229492188 628.5020751953125 L 782.181884765625 628.5677490234375 L 807.9367065429688 633.9592895507812 C 808.6983032226562 634.1201782226562 809.436767578125 634.3793334960938 810.1343994140625 634.7308349609375 C 813.3682861328125 636.369140625 815.3426513671875 639.8158569335938 815.1594848632812 643.5033569335938 Z" fill="#6c63ff" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /><path transform="translate(-564.47, -427.64)" d="M 927.8048095703125 677.5855102539062 L 908.4707641601562 677.5855102539062 L 905.0218505859375 639.9712524414062 C 914.14208984375 640.900634765625 921.6251220703125 647.7635498046875 923.5216674804688 656.9381713867188 L 927.8048095703125 677.5855102539062 Z" fill="#6c63ff" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /><path transform="translate(-455.96, -436.19)" d="M 719.9154052734375 686.140625 L 701.375244140625 686.140625 L 702.0410766601562 679.4892578125 C 702.2377319335938 669.2664794921875 708.394775390625 660.1565551757812 717.673583984375 656.3594970703125 L 717.7096557617188 656.8641967773438 L 719.9154052734375 686.140625 Z" fill="#6c63ff" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /><path transform="translate(-492.14, -354.31)" d="M 773.1970825195312 521.771728515625 C 782.8567504882812 516.1172485351562 792.529541015625 519.72998046875 802.2191772460938 535.1585083007812 L 804.2001953125 551.5935668945312 C 818.7425537109375 537.497802734375 818.0072631835938 518.2613525390625 801.698974609375 510.4373168945312 C 800.0956420898438 509.6681518554688 798.5420532226562 508.7932739257812 796.7971801757812 509.1024475097656 C 789.2545776367188 504.9698791503906 780.2369995117188 508.0737609863281 776.4578857421875 514.6929931640625 C 773.4448852539062 515.2268676757812 769.1253662109375 521.3514404296875 769.2808227539062 524.47607421875 L 773.1970825195312 521.771728515625 Z" fill="#2f2e41" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /></svg>';
const String _shapeSVG_5198e54f0b5e45ca9799e92cbdadc381 =
'<svg viewBox="0.0 0.0 235.2 174.2" ><path transform="translate(-176.03, -165.82)" d="M 404.4540405273438 339.9795532226562 L 182.7998657226562 339.9795532226562 C 179.0638732910156 339.9751892089844 176.0363464355469 336.8775939941406 176.0321044921875 333.05517578125 L 176.0321350097656 172.7440338134766 C 176.0363464355469 168.9215545654297 179.0638732910156 165.8239593505859 182.7998657226562 165.8196258544922 L 404.4540405273438 165.8196258544922 C 408.1900024414062 165.8239593505859 411.2175598144531 168.9215545654297 411.2217407226562 172.7440338134766 L 411.2218322753906 333.05517578125 C 411.2174987792969 336.8775939941406 408.1900024414062 339.9751892089844 404.4540100097656 339.9795532226562 Z" fill="#e6e6e6" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /><path transform="translate(-186.56, -176.13)" d="M 405.7513427734375 185.5708618164062 L 202.5555572509766 185.5708618164062 C 198.8181457519531 185.5757141113281 195.7895965576172 188.6744079589844 195.7847595214844 192.4983215332031 L 195.7847595214844 333.9219360351562 C 195.7895660400391 337.745849609375 198.8181457519531 340.8446044921875 202.5555572509766 340.8494567871094 L 405.7513427734375 340.8494567871094 C 409.4877319335938 340.8441467285156 412.5146179199219 337.7448425292969 412.5170288085938 333.9219360351562 L 412.5170288085938 192.4983215332031 C 412.5146789550781 188.6754455566406 409.4877319335938 185.5761566162109 405.7513732910156 185.5708618164062 Z" fill="#ffffff" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /><path transform="translate(-86.78, -60.8)" d="M 252.0176086425781 167.1123352050781 L 189.3457794189453 181.7864379882812 L 162.8659515380859 130.6882934570312 L 216.4553070068359 109.2820129394531 L 252.0176086425781 167.1123352050781 Z" fill="#2f2e41" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /></svg>';
const String _shapeSVG_e674c741e5dc4ea986b6425dcf161fee =
'<svg viewBox="44.3 39.1 273.9 179.4" ><path transform="translate(-285.46, -271.4)" d="M 395.1239013671875 423.6251525878906 L 450.2299499511719 415.48583984375 C 442.0038452148438 400.2521667480469 433.5226135253906 386.3682861328125 422.1243286132812 387.9206237792969 C 411.98388671875 380.6591491699219 411.3991088867188 368.9861145019531 413.9638366699219 355.8589782714844 L 386.3815002441406 363.4028930664062 C 388.8084716796875 371.4947814941406 387.8697204589844 378.6001586914062 381.4057312011719 384.0861511230469 C 390.4375305175781 397.0946044921875 396.2825622558594 410.2254028320312 395.1239013671875 423.6251525878906 Z" fill="#ffb9b9" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /><path transform="translate(-272.92, -299.78)" d="M 449.2866516113281 457.0693359375 L 362.0881652832031 457.0693359375 C 360.8524780273438 455.3713684082031 359.5385437011719 453.729248046875 358.1462097167969 452.1427612304688 C 358.0543212890625 452.0331115722656 357.9573059082031 451.9181518554688 357.8602600097656 451.8084411621094 L 360.2039794921875 417.9075317382812 L 360.43896484375 414.4803466796875 C 360.5595397949219 412.6900329589844 361.6944580078125 411.1383056640625 363.3392028808594 410.5150146484375 L 363.3442687988281 410.5150146484375 C 363.4752197265625 410.4579162597656 363.6100463867188 410.4107666015625 363.7476501464844 410.3739318847656 L 370.97802734375 408.3992004394531 L 371.697998046875 408.2006225585938 L 371.8001098632812 408.3260498046875 L 375.8595581054688 413.1428833007812 L 378.5709533691406 416.3663024902344 L 390.5602722167969 430.6027221679688 C 392.7348327636719 433.1842651367188 395.8262634277344 434.7714233398438 399.1488342285156 435.0120849609375 L 403.5862121582031 435.3307800292969 C 411.4394836425781 435.9002075195312 417.0001525878906 429.3959045410156 417.0001525878906 422.4944763183594 C 417.0021362304688 420.0708312988281 416.307861328125 417.7000122070312 415.0036315917969 415.6767578125 C 414.6784362792969 415.1592712402344 414.316650390625 414.6669006347656 413.9211120605469 414.2034606933594 L 418.966064453125 415.0341186523438 L 426.1964416503906 416.23046875 L 434.3458862304688 435.8323059082031 C 442.5363159179688 442.4777221679688 447.7088012695312 449.5306091308594 449.2866516113281 457.0693359375 Z" fill="#6c63ff" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /><path transform="translate(-50.53, -155.91)" d="M 121.7269134521484 283.3590698242188 L 132.6896667480469 303.6402282714844 L 126.5059356689453 309.52783203125 L 123.233039855957 312.6417541503906 L 94.82199096679688 312.6417541503906 L 111.8512420654297 294.105712890625 L 121.7269134521484 283.3590698242188 Z" fill="#ffb9b9" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /><path transform="translate(-342.6, -307.38)" d="M 524.9362182617188 464.4586181640625 L 498.1901245117188 464.4586181640625 L 495.356201171875 451.9776611328125 L 489.3155517578125 425.3699951171875 L 488.6466674804688 422.4234008789062 L 488.63134765625 422.3554992675781 L 494.9579162597656 422.7473754882812 C 502.1552429199219 423.1959228515625 508.5236206054688 427.6703796386719 511.5172729492188 434.382080078125 L 524.9362182617188 464.4586181640625 Z" fill="#6c63ff" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /><path transform="translate(-244.02, -302.19)" d="M 320.7420959472656 457.4939575195312 L 347.0495910644531 448.3813171386719 L 337.7742004394531 416.0939025878906 C 337.1539306640625 413.9346618652344 335.0928039550781 412.5559997558594 332.9108581542969 412.8408203125 L 332.9108581542969 412.8408203125 C 332.0174560546875 412.9573974609375 331.1792297363281 413.3469543457031 330.5054931640625 413.9584350585938 L 303.6314086914062 438.352783203125 C 308.7725524902344 447.0123596191406 314.2463684082031 447.229736328125 320.7420959472656 457.4939575195312 Z" fill="#6c63ff" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /><path transform="translate(-249.13, -211.51)" d="M 376.5058898925781 254.4269104003906 C 376.5058898925781 254.4269104003906 390.3892211914062 257.0987548828125 393.5998229980469 274.8145446777344 C 394.10205078125 277.8021545410156 394.193603515625 280.846923828125 393.8717346191406 283.8604736328125 C 393.5511169433594 287.2705383300781 394.01611328125 294.4730529785156 401.253173828125 302.9539794921875 C 405.9753112792969 308.45458984375 410.3753051757812 314.2362060546875 414.4302062988281 320.2684631347656 L 414.4302062988281 320.2684631347656 L 399.92333984375 324.2198181152344 L 393.4416809082031 299.6283264160156 C 390.29931640625 287.705810546875 385.4582214355469 276.3216552734375 379.0744018554688 265.8421020507812 L 378.9411010742188 265.623291015625 C 378.9411010742188 265.623291015625 374.1229248046875 278.7953796386719 361.2087707519531 280.6011352539062 L 365.1906433105469 275.2373352050781 C 365.1906433105469 275.2373352050781 350.0940246582031 284.1663208007812 341.5408630371094 286.8939514160156 C 339.5516662597656 287.5287475585938 338.0689392089844 289.2376098632812 337.688720703125 291.3338623046875 C 337.3085632324219 293.4300231933594 338.0932006835938 295.5693969726562 339.7274475097656 296.8921203613281 C 339.7881164550781 296.9410095214844 339.8499145507812 296.9898071289062 339.9128112792969 297.0386657714844 C 346.2037658691406 301.9275207519531 359.0379638671875 313.5927124023438 353.9675903320312 324.8772583007812 C 348.8972778320312 336.1617736816406 354.8100891113281 338.21923828125 354.8100891113281 338.21923828125 L 343.9068908691406 333.975341796875 L 338.9165344238281 331.7888488769531 L 339.4207763671875 335.5639953613281 L 315.0592346191406 336.0862426757812 C 315.0592346191406 336.0862426757812 308.4761047363281 336.0452880859375 320.1695556640625 318.0662536621094 C 320.1695556640625 318.0662536621094 322.9910583496094 311.3247680664062 320.6747741699219 306.1745300292969 C 318.8983764648438 302.2249755859375 317.7980041503906 297.9827575683594 317.9744873046875 293.6388244628906 C 318.7108459472656 275.5125122070312 326.174072265625 238.6363372802734 376.5058898925781 254.4269104003906 Z" fill="#2f2e41" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /><path transform="translate(-459.17, -247.33)" d="M 772.996337890625 354.711669921875 C 772.7752075195312 354.7113647460938 772.58447265625 354.5525207519531 772.539306640625 354.3309936523438 C 770.316650390625 343.392333984375 762.6249389648438 333.3398742675781 750.8817138671875 326.0251770019531 C 738.98388671875 318.6145629882812 723.707763671875 314.5331726074219 707.8677368164062 314.5331726074219 C 707.6098022460938 314.5331726074219 707.4007568359375 314.3191223144531 707.4007568359375 314.05517578125 C 707.4007568359375 313.7912292480469 707.6098022460938 313.5771484375 707.8677368164062 313.5771484375 C 723.8765258789062 313.5771484375 739.3251342773438 317.7080993652344 751.3675537109375 325.2088012695312 C 763.3342895507812 332.6623229980469 771.177978515625 342.9358825683594 773.4544067382812 354.1363830566406 C 773.4827880859375 354.2772827148438 773.4478759765625 354.423828125 773.3590087890625 354.5353698730469 C 773.270263671875 354.6469116210938 773.136962890625 354.7117004394531 772.996337890625 354.7117004394531 Z" fill="#3f3d56" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /><path transform="translate(-352.36, -125.36)" d="M 661.2810668945312 229.8953094482422 L 666.8748168945312 237.5184326171875 L 670.5311889648438 228.7510375976562 L 661.2810668945312 229.8953094482422 Z" fill="#3f3d56" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /><path transform="translate(-322.59, -389.26)" d="M 516.6799926757812 607.705078125 C 500.671142578125 607.705078125 485.2226257324219 603.57421875 473.1803283691406 596.0732421875 C 461.2132873535156 588.6195068359375 453.3695068359375 578.3463745117188 451.0934753417969 567.1453857421875 C 451.0410766601562 566.886962890625 451.2033386230469 566.634033203125 451.4559631347656 566.580322265625 C 451.7085571289062 566.5267944335938 451.955810546875 566.6927490234375 452.0082092285156 566.9512329101562 C 454.2308654785156 577.8899536132812 461.9224853515625 587.9421997070312 473.6661682128906 595.2568969726562 C 485.5640869140625 602.6676025390625 500.8401489257812 606.7490844726562 516.6799926757812 606.7490844726562 C 516.9378662109375 606.7490844726562 517.14697265625 606.9630737304688 517.14697265625 607.2271118164062 C 517.14697265625 607.4910278320312 516.9378662109375 607.705078125 516.6799926757812 607.705078125 Z" fill="#3f3d56" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /><path transform="translate(-142.14, -212.35)" d="M 276.0041809082031 395.0981750488281 L 270.4104614257812 387.4750671386719 L 266.7539672851562 396.2424011230469 L 276.0041809082031 395.0981750488281 Z" fill="#3f3d56" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /></svg>';
const String _shapeSVG_fc6cd6df4c4f4342b560670e8f7665b8 =
'<svg viewBox="220.8 172.4 184.7 136.8" ><g transform="translate(9.41, 51.78)"><path transform="translate(-417.16, -327.42)" d="M 807.9612426757812 584.7850952148438 L 633.8742065429688 584.7850952148438 C 630.9398803710938 584.7816772460938 628.5621337890625 582.3488159179688 628.558837890625 579.3467407226562 L 628.558837890625 453.4384155273438 C 628.5621337890625 450.436279296875 630.9398803710938 448.0033874511719 633.8742065429688 448.0000915527344 L 807.9612426757812 448.0000915527344 C 810.8953857421875 448.0033874511719 813.2733154296875 450.436279296875 813.2765502929688 453.4384155273438 L 813.2765502929688 579.3468017578125 C 813.2733154296875 582.3488159179688 810.8953857421875 584.78173828125 807.9612426757812 584.7850952148438 Z" fill="#e6e6e6" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /><path transform="translate(-425.42, -335.52)" d="M 808.9801635742188 463.5126342773438 L 649.3903198242188 463.5126342773438 C 646.4549560546875 463.5164794921875 644.0762939453125 465.9502258300781 644.0724487304688 468.9534606933594 L 644.072509765625 580.0274047851562 C 644.0762939453125 583.0306396484375 646.4549560546875 585.4644775390625 649.3903198242188 585.4682006835938 L 808.9801635742188 585.4682006835938 C 811.9146118164062 585.4639892578125 814.2919921875 583.0299072265625 814.2938842773438 580.0274047851562 L 814.2938842773438 468.9534606933594 C 814.2919921875 465.9509582519531 811.9146118164062 463.5167846679688 808.9801635742188 463.5126342773438 Z" fill="#ffffff" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /></g></svg>';
const String _shapeSVG_ac1df27a9c114bb6bbad5fc1b942f9e7 =
'<svg viewBox="0.0 4.1 16.0 12.0" ><g transform="translate(0.0, 4.13)"><path d="M 14 2 L 2 2 L 8 7 L 14 2 Z M 0 2 C 0 0.8999999761581421 0.8999999761581421 0 2 0 L 14 0 C 15.10000038146973 0 16 0.8999999761581421 16 2 L 16 10 C 16 11.10000038146973 15.10000038146973 12 14 12 L 2 12 C 0.8999999761581421 12 0 11.10000038146973 0 10 L 0 2 Z" fill="#6c63fc" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /></g></svg>';
const String _shapeSVG_46438d9d58614ba8984fc764700753c7 =
'<svg viewBox="1.0 0.0 14.0 16.0" ><path transform="translate(1.0, 0.0)" d="M 7 8 C 8.100000381469727 8 9 8.899999618530273 9 10 C 9 11.10000038146973 8.100000381469727 12 7 12 C 5.899999618530273 12 5 11.10000038146973 5 10 C 5 8.899999618530273 5.900000095367432 8 7 8 Z M 7 2 C 5.900000095367432 2 5 2.900000095367432 5 4 L 9 4 C 9 2.900000095367432 8.100000381469727 2 7 2 Z M 12 16 L 2 16 C 0.8999999761581421 16 0 15.10000038146973 0 14 L 0 6 C 0 4.900000095367432 0.8999999761581421 4 2 4 L 3 4 C 3 1.799999952316284 4.800000190734863 0 7 0 C 9.199999809265137 0 11 1.799999952316284 11 4 L 12 4 C 13.10000038146973 4 14 4.900000095367432 14 6 L 14 14 C 14 15.10000038146973 13.10000038146973 16 12 16 Z" fill="#6c63fc" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /></svg>';
const String _shapeSVG_d3b8a614c5494a54b5b48376c5c2e143 =
'<svg viewBox="0.0 3.0 16.0 10.2" ><path transform="translate(0.0, 3.0)" d="M 16 4.400000095367432 L 16 5.900000095367432 L 14.5 5.900000095367432 L 14.5 7.400000095367432 L 13 7.400000095367432 L 13 5.800000190734863 L 11.5 5.800000190734863 L 11.5 4.400000095367432 L 13 4.400000095367432 L 13 2.900000095367432 L 14.5 2.900000095367432 L 14.5 4.400000095367432 L 16 4.400000095367432 Z M 5.099999904632568 4.400000095367432 L 9.899999618530273 4.400000095367432 C 9.899999618530273 4.700000286102295 10 4.900000095367432 10 5.200000286102295 C 10 8.100000381469727 8.100000381469727 10.20000076293945 5.099999904632568 10.20000076293945 C 2.299999952316284 10.19999980926514 0 7.900000095367432 0 5.099999904632568 C 0 2.299999952316284 2.299999952316284 0 5.099999904632568 0 C 6.5 0 7.599999904632568 0.5 8.5 1.299999952316284 L 7.099999904632568 2.700000047683716 C 6.699999809265137 2.299999952316284 6.099999904632568 1.900000095367432 5.099999904632568 1.900000095367432 C 3.399999856948853 1.900000095367432 1.899999856948853 3.300000190734863 1.899999856948853 5.100000381469727 C 1.899999856948853 6.90000057220459 3.299999713897705 8.300000190734863 5.099999904632568 8.300000190734863 C 7.099999904632568 8.300000190734863 7.899999618530273 6.900000095367432 8 6.100000381469727 L 5.099999904632568 6.100000381469727 L 5.099999904632568 4.400000095367432 Z" fill="#ffffff" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /></svg>';
const String _shapeSVG_ef322ce8c41345588c217546eccfa06e =
'<svg viewBox="0.0 2.0 16.0 13.0" ><path transform="translate(-38.0, 0.0)" d="M 43.06666564941406 14.97777557373047 C 49.11111068725586 14.97777557373047 52.39999771118164 9.999998092651367 52.39999771118164 5.644444465637207 C 52.39999771118164 5.466666698455811 52.39999771118164 5.377777576446533 52.39999771118164 5.199999809265137 C 53.02222061157227 4.755555629730225 53.5555534362793 4.133333683013916 53.99999618530273 3.51111102104187 C 53.37777328491211 3.777777910232544 52.75555038452148 3.955555438995361 52.13333129882812 4.044444561004639 C 52.84444427490234 3.599999904632568 53.28888702392578 2.977777719497681 53.5555534362793 2.266666889190674 C 52.93333053588867 2.622222185134888 52.22222137451172 2.888888597488403 51.5111083984375 3.066666603088379 C 50.88888549804688 2.355555534362793 49.99999618530273 2 49.11111068725586 2 C 47.33333206176758 2 45.82221984863281 3.511110782623291 45.82221984863281 5.288888454437256 C 45.82221984863281 5.555554866790771 45.82221984863281 5.822221279144287 45.91110610961914 5.999999523162842 C 43.15555572509766 5.822221755981445 40.75555419921875 4.57777738571167 39.15555572509766 2.53333306312561 C 38.88888931274414 2.977777481079102 38.71110916137695 3.599999666213989 38.71110916137695 4.222221851348877 C 38.71110916137695 5.377777576446533 39.33333206176758 6.355555057525635 40.13333129882812 6.977777004241943 C 39.59999847412109 6.977777004241943 39.06666564941406 6.799999237060547 38.62221908569336 6.533332824707031 C 38.62221908569336 6.533332824707031 38.62221908569336 6.533332824707031 38.62221908569336 6.533332824707031 C 38.62221908569336 8.133332252502441 39.77777481079102 9.46666431427002 41.28888702392578 9.733331680297852 C 41.02222061157227 9.822220802307129 40.75555419921875 9.822220802307129 40.39999771118164 9.822220802307129 C 40.22221755981445 9.822220802307129 39.95555114746094 9.822220802307129 39.77777481079102 9.733331680297852 C 40.22221755981445 11.06666469573975 41.37777328491211 11.95555305480957 42.88888549804688 12.04444122314453 C 41.73332977294922 12.93333053588867 40.31110763549805 13.46666431427002 38.79999923706055 13.46666431427002 C 38.53333282470703 13.46666431427002 38.26666641235352 13.46666431427002 37.99999618530273 13.37777423858643 C 39.42222213745117 14.44444179534912 41.19999694824219 14.97777557373047 43.06666564941406 14.97777557373047" fill="#ffffff" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /></svg>';
const String _shapeSVG_397cfc2bbbe94ccb814c5dce693034c3 =
'<svg viewBox="4.0 0.0 8.4 16.0" ><path transform="translate(-76.0, 0.0)" d="M 85.42222595214844 16 L 85.42222595214844 8.711111068725586 L 87.91111755371094 8.711111068725586 L 88.26667785644531 5.8666672706604 L 85.42222595214844 5.8666672706604 L 85.42222595214844 4.088889122009277 C 85.42222595214844 3.288889169692993 85.68890380859375 2.666667222976685 86.84445190429688 2.666667222976685 L 88.35556030273438 2.666667222976685 L 88.35556030273438 0.08888889104127884 C 88 0.08888889104127884 87.11111450195312 0 86.13333129882812 0 C 84 0 82.4888916015625 1.333333373069763 82.4888916015625 3.733333110809326 L 82.4888916015625 5.866666793823242 L 80 5.866666793823242 L 80 8.711111068725586 L 82.4888916015625 8.711111068725586 L 82.4888916015625 16 L 85.42222595214844 16 Z" fill="#ffffff" stroke="none" stroke-width="1" stroke-miterlimit="4" stroke-linecap="butt" /></svg>';
| 0 |
mirrored_repositories/flutter-basics/adobeXdDesign | mirrored_repositories/flutter-basics/adobeXdDesign/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:adobeXdDesign/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/flutter-basics/notekeeper | mirrored_repositories/flutter-basics/notekeeper/lib/main.dart | import 'package:flutter/material.dart';
import 'package:notekeeper/screens/note_details.dart';
import 'screens/note_list.dart';
import 'dart:async';
import 'package:sqflite/sqflite.dart';
import 'package:notekeeper/models/note.dart';
import 'package:notekeeper/utils/database_helper.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Notekeeper',
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.deepPurple),
home: NoteList(),
);
}
}
| 0 |
mirrored_repositories/flutter-basics/notekeeper/lib | mirrored_repositories/flutter-basics/notekeeper/lib/models/note.dart | class Note {
int _id;
String _title;
String _description;
String _date;
int _priority;
Note(this._title, this._date, this._priority, [this._description]);
Note.withId(this._id, this._title, this._date, this._priority,
[this._description]);
int get id => _id;
String get title => _title;
String get description => _description;
String get date => _date;
int get priority => _priority;
set title(String newTitle) {
if (newTitle.length <= 255) {
this._title = newTitle;
}
}
set description(String newDescription) {
if (newDescription.length <= 255) {
this._title = newDescription;
}
}
set priority(int newPriority) {
if (newPriority >= 1 && newPriority <= 2) {
this._priority = newPriority;
}
}
set date(String newDate) {
this._date = newDate;
}
// convert note object to map object
Map<String, dynamic> toMap() {
var map = Map<String, dynamic>();
if (id != null) {
map['id'] = _id;
}
map['title'] = _title;
map['description'] = _description;
map['priority'] = _priority;
map['date'] = _date;
return map;
}
//extract note object from map object
Note.fromMapObject(Map<String, dynamic> map) {
this._id = map['id'];
this._title = map['title'];
this._description = map['description'];
this._priority = map['priority'];
this._date = map['date'];
}
}
| 0 |
mirrored_repositories/flutter-basics/notekeeper/lib | mirrored_repositories/flutter-basics/notekeeper/lib/utils/database_helper.dart | import 'package:sqflite/sqflite.dart';
import 'dart:async';
import 'dart:io';
import 'package:path_provider/path_provider.dart';
import "package:notekeeper/models/note.dart";
class DatabaseHelper {
static DatabaseHelper _databaseHelper; // singleton database helper
static Database _database; // create singleton database
String noteTable = 'note_table';
String colId = 'id';
String colTitle = 'title';
String colDescription = 'description';
String colPriority = 'priority';
String colDate = 'date';
DatabaseHelper._createInstance(); // named constructor to create instance
factory DatabaseHelper() {
if (_databaseHelper == null) {
_databaseHelper = DatabaseHelper._createInstance();
}
return _databaseHelper;
}
Future<Database> get database async {
if (_database == null) {
_database = await initializeDatabase();
}
return _database;
}
Future<Database> initializeDatabase() async {
// Get the directory path for both android and ios to store database
Directory directory = await getApplicationDocumentsDirectory();
String path = directory.path + 'notes.db';
//open/create database at given path
var notesDatabase =
await openDatabase(path, version: 1, onCreate: _createDb);
return notesDatabase;
}
void _createDb(Database db, int newVersion) async {
await db.execute(
'CREATE TABLE $noteTable($colId INTEGER PRIMARY KEY AUTOINCREMENT,'
'$colTitle TEXT,$colDescription Text, $colPriority INTEGER, $colDate TEXT )');
}
// Fetch operation: Get all note object from database
Future<List<Map<String, dynamic>>> getNoteMapList() async {
Database db = await this.database;
var result = await db.query(noteTable, orderBy: '$colPriority ASC');
return result;
}
// INsert operation: Insert a Note object to Database
Future<int> insertNote(Note note) async {
Database db = await this.database;
var result = await db.insert(noteTable, note.toMap());
return result;
}
// Upate operation: Update a note and save it to database
Future<int> updaeNote(Note note) async {
var db = await this.database;
var result = await db.update(noteTable, note.toMap(),
where: '$colId = ?', whereArgs: [note.id]);
return result;
}
// Delete operation: delete a note object from database
Future<int> deleteNote(int id) async {
var db = await this.database;
int result =
await db.rawDelete('DELETE FROM $noteTable where $colId = $id');
return result;
}
// Get number of note objects from database
Future<int> getCount() async {
Database db = await this.database;
List<Map<String, dynamic>> x =
await db.rawQuery('SELECT COUNT (x) FROM $noteTable');
int result = Sqflite.firstIntValue(x);
return result;
}
//get the 'Map List' [List<Map>] and convert it to 'Note List'[List<Note>]
Future<List<Note>> getNoteList() async {
var noteMapList = await getNoteMapList(); // get 'Map List from database
int count = noteMapList.length; // count the no of map entries in db
List<Note> notelist = List<Note>();
//for loop to create 'Note List' froma 'Map List'
for (var i = 0; i < count; i++) {
notelist.add(Note.fromMapObject(noteMapList[i]));
}
return notelist;
}
}
| 0 |
mirrored_repositories/flutter-basics/notekeeper/lib | mirrored_repositories/flutter-basics/notekeeper/lib/screens/note_details.dart | import "package:flutter/material.dart";
import 'dart:async';
import 'package:notekeeper/models/note.dart';
import 'package:notekeeper/utils/database_helper.dart';
import 'package:intl/intl.dart';
import 'package:sqflite/sqflite.dart';
class NoteDetails extends StatefulWidget {
final String appBarTitle;
final Note note;
NoteDetails(this.note, this.appBarTitle);
@override
_NoteDetailsState createState() =>
_NoteDetailsState(this.note, this.appBarTitle);
}
class _NoteDetailsState extends State<NoteDetails> {
var _formKey = GlobalKey<FormState>();
static var _priorities = ['High', 'Low'];
DatabaseHelper helper = DatabaseHelper();
TextEditingController titleController = TextEditingController();
TextEditingController descriptionController = TextEditingController();
Note note;
String appBarTitle;
_NoteDetailsState(this.note, this.appBarTitle);
@override
Widget build(BuildContext context) {
TextStyle textStyle = Theme.of(context).textTheme.headline6;
titleController.text = note.title;
descriptionController.text = note.description;
return WillPopScope(
onWillPop: () {
moveToLastScreen();
return Future.value(true);
},
child: Scaffold(
appBar: AppBar(
title: Text(appBarTitle),
leading: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {
moveToLastScreen();
}),
),
body: Form(
key: _formKey,
child: Padding(
padding: EdgeInsets.only(top: 15.0, left: 10.0, right: 10.0),
child: ListView(
children: <Widget>[
ListTile(
title: DropdownButton(
items: _priorities.map((String dropDownStringItem) {
return DropdownMenuItem<String>(
value: dropDownStringItem,
child: Text(dropDownStringItem),
);
}).toList(),
style: textStyle,
value: getPriorityAsString(note.priority),
onChanged: (valueSelectedByUser) {
setState(() {
debugPrint('User Selected $valueSelectedByUser');
updatePriorityAInt(valueSelectedByUser);
});
}),
),
//Second element
Padding(
padding: const EdgeInsets.only(top: 15.0, bottom: 15),
child: TextFormField(
validator: (String value) {
if (value.isEmpty) {
return 'Please Enter Title';
}
},
controller: titleController,
style: textStyle,
onChanged: (value) {
debugPrint('Something is chnaged in title text field');
updateTitle();
},
decoration: InputDecoration(
labelText: 'Title',
labelStyle: textStyle,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0),
),
errorStyle: TextStyle(color: Colors.red, fontSize: 15)),
),
),
//Third element
Padding(
padding: EdgeInsets.only(top: 15, bottom: 15),
child: TextField(
controller: descriptionController,
style: textStyle,
onChanged: (value) {
debugPrint(
'Something is changed in Description text field ');
updateDescription();
},
decoration: InputDecoration(
labelText: 'Description',
labelStyle: textStyle,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5))),
),
),
//fourth element
Padding(
padding: EdgeInsets.only(top: 15, bottom: 15),
child: Row(
children: <Widget>[
Expanded(
child: RaisedButton(
color: Theme.of(context).primaryColorDark,
textColor: Theme.of(context).primaryColorLight,
child: Text(
'Save',
textScaleFactor: 1.5,
),
onPressed: () {
setState(() {
if (_formKey.currentState.validate()) {
debugPrint('save button clicked');
_save();
}
});
},
),
),
Container(width: 5.0),
Expanded(
child: RaisedButton(
color: Theme.of(context).primaryColorDark,
textColor: Theme.of(context).primaryColorLight,
child: Text(
'Delete',
textScaleFactor: 1.5,
),
onPressed: () {
setState(() {
debugPrint('Delete button clicked');
_delete();
});
},
),
)
],
),
)
],
),
),
),
),
);
}
// function to go back to last screen
void moveToLastScreen() {
Navigator.pop(context, true);
}
//convert the String priority in the form of integer before saving it to Database
void updatePriorityAInt(String value) {
switch (value) {
case 'High':
note.priority = 1;
break;
case 'Low':
note.priority = 2;
break;
}
}
//convert int property to string property and display it to user in dropdown
String getPriorityAsString(int value) {
String priority;
switch (value) {
case 1:
priority = _priorities[0];
break;
case 2:
priority = _priorities[1];
break;
}
return priority;
}
//update note title
void updateTitle() {
note.title = titleController.text;
}
//update note description
void updateDescription() {
note.description = descriptionController.text;
}
// save database
void _save() async {
moveToLastScreen();
note.date = DateFormat.yMMMd().format(DateTime.now());
int result;
if (note.id != null) {
// case 1: update operation
result = await helper.updaeNote(note);
} else {
//case 2: insert operation
result = await helper.insertNote(note);
}
if (result != 0) {
//success
_showAlertDialog('Status', 'Note Saved Successfully');
} else {
//failure
_showAlertDialog('Status', 'Problem Saving Note');
}
}
// delete a note
void _delete() async {
moveToLastScreen();
// case 1: if a user is trying to delete a NEW NOTE ie. he has to come to
// details page by pressing the FAB of Notelist page
if (note.id == null) {
_showAlertDialog('Status', "No Note was Deleted");
return;
}
// case 2: user is trying to delete the old note that has valid id
int result = await helper.deleteNote(note.id);
if (result != 0) {
_showAlertDialog('Status', 'Note Deleted Successfully');
} else
(_showAlertDialog('Status', 'Error occured While deleting Note '));
}
void _showAlertDialog(String title, String message) {
AlertDialog alertDialog = AlertDialog(
title: Text(title),
content: Text(message),
);
showDialog(context: context, builder: (_) => alertDialog);
}
}
| 0 |
mirrored_repositories/flutter-basics/notekeeper/lib | mirrored_repositories/flutter-basics/notekeeper/lib/screens/note_list.dart | import 'package:flutter/material.dart';
import 'package:notekeeper/screens/note_details.dart';
import 'dart:async';
import 'package:sqflite/sqflite.dart';
import 'package:notekeeper/models/note.dart';
import 'package:notekeeper/utils/database_helper.dart';
class NoteList extends StatefulWidget {
@override
_NoteListState createState() => _NoteListState();
}
class _NoteListState extends State<NoteList> {
DatabaseHelper databaseHelper = DatabaseHelper();
List<Note> noteList;
int count = 0;
@override
Widget build(BuildContext context) {
if (noteList == null) {
noteList = List<Note>();
}
return Scaffold(
appBar: AppBar(
title: Text('Notes'),
),
body: getNoteListView(),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
tooltip: 'Add note',
onPressed: () {
debugPrint('floating action button tapped');
navigateToDetail(Note('', '', 2), 'Add Note');
},
),
);
}
ListView getNoteListView() {
TextStyle titlestyle = Theme.of(context).textTheme.subtitle1;
return ListView.builder(
itemCount: count,
itemBuilder: (BuildContext context, int position) {
return Card(
color: Colors.white,
elevation: 2.0,
child: ListTile(
leading: CircleAvatar(
backgroundColor:
getpriorityColor(this.noteList[position].priority),
child: getPriorityIcon(this.noteList[position].priority),
),
title: Text(
this.noteList[position].title,
style: titlestyle,
),
subtitle: Text(this.noteList[position].date, style: titlestyle),
trailing: GestureDetector(
child: Icon(
Icons.delete,
color: Colors.grey,
),
onTap: () {
_delete(context, noteList[position]);
},
),
onTap: () {
debugPrint('List tile press');
navigateToDetail(this.noteList[position], 'Edit Note');
},
),
);
},
);
}
//Return priority color
Color getpriorityColor(int priority) {
switch (priority) {
case 1:
return Colors.red;
break;
case 2:
return Colors.yellow;
break;
default:
return Colors.yellow;
}
}
// return priority icon
Icon getPriorityIcon(int priority) {
switch (priority) {
case 1:
return Icon(Icons.play_arrow);
break;
case 2:
return Icon(Icons.keyboard_arrow_right);
break;
default:
return Icon(Icons.keyboard_arrow_right);
}
}
//Function to delte a listview
void _delete(BuildContext context, Note note) async {
int result = await databaseHelper.deleteNote(note.id);
if (result != 0) {
_showSnackbar(context, 'Note Deleted Successfully');
updateListView();
}
}
void _showSnackbar(BuildContext context, String message) {
final snackbar = SnackBar(content: Text(message));
Scaffold.of(context).showSnackBar(snackbar);
}
// function to go to next screen
void navigateToDetail(Note note, String title) async {
bool result = await Navigator.push(
context,
(MaterialPageRoute(builder: (context) {
return NoteDetails(note, title);
})));
if (result == true) {
updateListView();
}
}
void updateListView() {
final Future<Database> dbFuture = databaseHelper.initializeDatabase();
dbFuture.then((database) {
Future<List<Note>> noteListFuture = databaseHelper.getNoteList();
noteListFuture.then((noteList) {
setState(() {
this.noteList = noteList;
this.count = noteList.length;
});
});
});
}
}
| 0 |
mirrored_repositories/flutter-basics/notekeeper | mirrored_repositories/flutter-basics/notekeeper/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:notekeeper/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/filter_listview_example | mirrored_repositories/filter_listview_example/lib/main.dart | import 'package:filter_listview_example/page/filter_local_list_page.dart';
import 'package:filter_listview_example/page/filter_network_list_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
static final String title = 'Filter & Search ListView';
@override
Widget build(BuildContext context) => MaterialApp(
debugShowCheckedModeBanner: false,
title: title,
theme: ThemeData(primarySwatch: Colors.blue),
home: MainPage(),
);
}
class MainPage extends StatefulWidget {
@override
_MainPageState createState() => _MainPageState();
}
class _MainPageState extends State<MainPage> {
int index = 0;
@override
Widget build(BuildContext context) => Scaffold(
bottomNavigationBar: buildBottomBar(),
body: buildPages(),
);
Widget buildBottomBar() {
final style = TextStyle(color: Colors.white);
return BottomNavigationBar(
backgroundColor: Theme.of(context).primaryColor,
selectedItemColor: Colors.white,
unselectedItemColor: Colors.white70,
currentIndex: index,
items: [
BottomNavigationBarItem(
icon: Text('Filter List', style: style),
title: Text('Local'),
),
BottomNavigationBarItem(
icon: Text('Filter List', style: style),
title: Text('Network'),
),
],
onTap: (int index) => setState(() => this.index = index),
);
}
Widget buildPages() {
switch (index) {
case 0:
return FilterLocalListPage();
case 1:
return FilterNetworkListPage();
default:
return Container();
}
}
}
| 0 |
mirrored_repositories/filter_listview_example/lib | mirrored_repositories/filter_listview_example/lib/page/filter_local_list_page.dart | import 'package:filter_listview_example/data/book_data.dart';
import 'package:filter_listview_example/main.dart';
import 'package:filter_listview_example/model/book.dart';
import 'package:filter_listview_example/widget/search_widget.dart';
import 'package:flutter/material.dart';
class FilterLocalListPage extends StatefulWidget {
@override
FilterLocalListPageState createState() => FilterLocalListPageState();
}
class FilterLocalListPageState extends State<FilterLocalListPage> {
late List<Book> books;
String query = '';
@override
void initState() {
super.initState();
books = allBooks;
}
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: Text(MyApp.title),
centerTitle: true,
),
body: Column(
children: <Widget>[
buildSearch(),
Expanded(
child: ListView.builder(
itemCount: books.length,
itemBuilder: (context, index) {
final book = books[index];
return buildBook(book);
},
),
),
],
),
);
Widget buildSearch() => SearchWidget(
text: query,
hintText: 'Title or Author Name',
onChanged: searchBook,
);
Widget buildBook(Book book) => ListTile(
leading: Image.network(
book.urlImage,
fit: BoxFit.cover,
width: 50,
height: 50,
),
title: Text(book.title),
subtitle: Text(book.author),
);
void searchBook(String query) {
final books = allBooks.where((book) {
final titleLower = book.title.toLowerCase();
final authorLower = book.author.toLowerCase();
final searchLower = query.toLowerCase();
return titleLower.contains(searchLower) ||
authorLower.contains(searchLower);
}).toList();
setState(() {
this.query = query;
this.books = books;
});
}
}
| 0 |
mirrored_repositories/filter_listview_example/lib | mirrored_repositories/filter_listview_example/lib/page/filter_network_list_page.dart | import 'dart:async';
import 'package:filter_listview_example/api/books_api.dart';
import 'package:filter_listview_example/main.dart';
import 'package:filter_listview_example/model/book.dart';
import 'package:filter_listview_example/widget/search_widget.dart';
import 'package:flutter/material.dart';
class FilterNetworkListPage extends StatefulWidget {
@override
FilterNetworkListPageState createState() => FilterNetworkListPageState();
}
class FilterNetworkListPageState extends State<FilterNetworkListPage> {
List<Book> books = [];
String query = '';
Timer? debouncer;
@override
void initState() {
super.initState();
init();
}
@override
void dispose() {
debouncer?.cancel();
super.dispose();
}
void debounce(
VoidCallback callback, {
Duration duration = const Duration(milliseconds: 1000),
}) {
if (debouncer != null) {
debouncer!.cancel();
}
debouncer = Timer(duration, callback);
}
Future init() async {
final books = await BooksApi.getBooks(query);
setState(() => this.books = books);
}
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: Text(MyApp.title),
centerTitle: true,
),
body: Column(
children: <Widget>[
buildSearch(),
Expanded(
child: ListView.builder(
itemCount: books.length,
itemBuilder: (context, index) {
final book = books[index];
return buildBook(book);
},
),
),
],
),
);
Widget buildSearch() => SearchWidget(
text: query,
hintText: 'Title or Author Name',
onChanged: searchBook,
);
Future searchBook(String query) async => debounce(() async {
final books = await BooksApi.getBooks(query);
if (!mounted) return;
setState(() {
this.query = query;
this.books = books;
});
});
Widget buildBook(Book book) => ListTile(
leading: Image.network(
book.urlImage,
fit: BoxFit.cover,
width: 50,
height: 50,
),
title: Text(book.title),
subtitle: Text(book.author),
);
}
| 0 |
mirrored_repositories/filter_listview_example/lib | mirrored_repositories/filter_listview_example/lib/data/book_data.dart | import 'package:filter_listview_example/model/book.dart';
final allBooks = <Book>[
Book(
id: 1,
author: 'Ardi Evans',
title: 'Modern Buildings',
urlImage:
'https://images.unsplash.com/photo-1615347497551-277d6616b959?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=692&q=80',
),
Book(
id: 2,
author: 'Lerone Pieters',
title: 'Busy City Life',
urlImage:
'https://images.unsplash.com/photo-1615346340977-cf7f5a8f3059?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80',
),
Book(
id: 3,
author: 'Uliana Kopanytsia',
title: 'Sweets and Cakes',
urlImage:
'https://images.unsplash.com/photo-1615351897596-d3a9fffb5797?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=665&q=80',
),
Book(
id: 4,
author: 'Riccardo Andolfo',
title: 'Vast Deserts',
urlImage:
'https://images.unsplash.com/photo-1615333619365-a44d7e655661?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&auto=format&fit=crop&w=1050&q=80',
),
Book(
id: 5,
author: 'Miguel Arguibide',
title: 'Parkour',
urlImage:
'https://images.unsplash.com/photo-1615286505008-cbca9896192f?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&auto=format&fit=crop&w=962&q=80',
),
Book(
id: 6,
author: 'Tran Mau Tri Tam',
title: 'Cute Kitties',
urlImage:
'https://images.unsplash.com/photo-1615369794017-f65e6f0c0393?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=634&q=80',
),
Book(
id: 7,
author: 'Josh Hemsley',
title: 'Beahces',
urlImage:
'https://images.unsplash.com/photo-1615357633073-a7b67638dedb?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=564&q=80',
),
Book(
id: 8,
author: 'Carlos Mesa',
title: 'Tides',
urlImage:
'https://images.unsplash.com/photo-1615185054269-363482a365ad?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=809&q=80',
),
Book(
id: 9,
author: 'Kellen Riggin',
title: 'Magnificent Forests',
urlImage:
'https://images.unsplash.com/photo-1615331224984-281512856592?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=634&q=80',
),
Book(
id: 10,
author: 'Navi Photography',
title: 'Butterflies',
urlImage:
'https://images.unsplash.com/photo-1615300236079-4bdb43bd9a9a?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=700&q=80'),
];
| 0 |
mirrored_repositories/filter_listview_example/lib | mirrored_repositories/filter_listview_example/lib/model/book.dart | class Book {
final int id;
final String title;
final String author;
final String urlImage;
const Book({
required this.id,
required this.author,
required this.title,
required this.urlImage,
});
factory Book.fromJson(Map<String, dynamic> json) => Book(
id: json['id'],
author: json['author'],
title: json['title'],
urlImage: json['urlImage'],
);
Map<String, dynamic> toJson() => {
'id': id,
'title': title,
'author': author,
'urlImage': urlImage,
};
}
| 0 |
mirrored_repositories/filter_listview_example/lib | mirrored_repositories/filter_listview_example/lib/widget/search_widget.dart | import 'package:flutter/material.dart';
class SearchWidget extends StatefulWidget {
final String text;
final ValueChanged<String> onChanged;
final String hintText;
const SearchWidget({
Key? key,
required this.text,
required this.onChanged,
required this.hintText,
}) : super(key: key);
@override
_SearchWidgetState createState() => _SearchWidgetState();
}
class _SearchWidgetState extends State<SearchWidget> {
final controller = TextEditingController();
@override
Widget build(BuildContext context) {
final styleActive = TextStyle(color: Colors.black);
final styleHint = TextStyle(color: Colors.black54);
final style = widget.text.isEmpty ? styleHint : styleActive;
return Container(
height: 42,
margin: const EdgeInsets.fromLTRB(16, 16, 16, 16),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white,
border: Border.all(color: Colors.black26),
),
padding: const EdgeInsets.symmetric(horizontal: 8),
child: TextField(
controller: controller,
decoration: InputDecoration(
icon: Icon(Icons.search, color: style.color),
suffixIcon: widget.text.isNotEmpty
? GestureDetector(
child: Icon(Icons.close, color: style.color),
onTap: () {
controller.clear();
widget.onChanged('');
FocusScope.of(context).requestFocus(FocusNode());
},
)
: null,
hintText: widget.hintText,
hintStyle: style,
border: InputBorder.none,
),
style: style,
onChanged: widget.onChanged,
),
);
}
}
| 0 |
mirrored_repositories/filter_listview_example/lib | mirrored_repositories/filter_listview_example/lib/api/books_api.dart | import 'dart:convert';
import 'package:filter_listview_example/model/book.dart';
import 'package:http/http.dart' as http;
class BooksApi {
static Future<List<Book>> getBooks(String query) async {
final url = Uri.parse(
'https://gist.githubusercontent.com/JohannesMilke/d53fbbe9a1b7e7ca2645db13b995dc6f/raw/eace0e20f86cdde3352b2d92f699b6e9dedd8c70/books.json');
final response = await http.get(url);
if (response.statusCode == 200) {
final List books = json.decode(response.body);
return books.map((json) => Book.fromJson(json)).where((book) {
final titleLower = book.title.toLowerCase();
final authorLower = book.author.toLowerCase();
final searchLower = query.toLowerCase();
return titleLower.contains(searchLower) ||
authorLower.contains(searchLower);
}).toList();
} else {
throw Exception();
}
}
}
| 0 |
mirrored_repositories/10DaysOfFlutter | mirrored_repositories/10DaysOfFlutter/lib/main.dart | import 'package:flutter/material.dart';
import 'package:practiceproject/Day12/On_Borad.dart';
void main() {
runApp(
MyApp(),
);
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: NewOnBoard(),
debugShowCheckedModeBanner: false,
);
}
}
| 0 |
mirrored_repositories/10DaysOfFlutter/lib | mirrored_repositories/10DaysOfFlutter/lib/day10/Confetti_screen.dart | // Day 10 Confetti celebration
import 'package:flutter/material.dart';
import 'package:confetti/confetti.dart';
class NewConfetti extends StatefulWidget {
@override
_NewConfettiState createState() => _NewConfettiState();
}
class _NewConfettiState extends State<NewConfetti> {
// define confettie controller
ConfettiController control;
@override
// define initState
void initState() {
super.initState();
control = ConfettiController(
duration: Duration(seconds: 10),
); // set time of confettie
}
// define dispose to clear momory after another event
@override
void dispose() {
super.dispose();
control.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Day 10 Confetti "),
centerTitle: true,
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Align(
alignment: Alignment.center,
child: ConfettiWidget(
// confetti widget mainly needs a confetticontroller
// here we are providing a variable to controll confetti
// variable must be as confettiecontroller type
confettiController: control,
// direction is in left you can change
shouldLoop: true,
blastDirectionality: BlastDirectionality.explosive,
),
),
// create a button for celebration
FlatButton(
onPressed: () {
control.play();
},
child: Text("Click To Celebrate "),
),
],
),
);
}
}
// Thats it for today
// Subscribe
// like
// share
// comments
// #CodeWithNix
// 100Daysofcode
// 100Daysofflutter
// ThankYou | 0 |
mirrored_repositories/10DaysOfFlutter/lib | mirrored_repositories/10DaysOfFlutter/lib/Day6/NewCurved.dart | // Day 6 Curved NavigationBar
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'package:flutter/material.dart';
class CurvedNavigation extends StatefulWidget {
@override
_CurvedNavigationState createState() => _CurvedNavigationState();
}
class _CurvedNavigationState extends State<CurvedNavigation> {
int onClick = 0;
// now to navigate you need to create a list and list always be final type
final List pageToNavigate = [
Container(color: Colors.red),
Container(color: Colors.pink),
Container(color: Colors.yellow),
Container(color: Colors.black),
];
// list is array type
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Day 6 Curved Navigation"),
),
// body to show the changes
body: pageToNavigate[onClick],
bottomNavigationBar: CurvedNavigationBar(
// there is more properties in curved NavigationBar Widget as
backgroundColor: Colors.pink[700],
color: Colors.white, // by default color is white you can leave it as
animationDuration: Duration(milliseconds: 400),
// adding duration time yiu can as you want
// you can add navigation also by using onTap property
// index is a value that store clicking index means which icon did you clicked
onTap: (index) {
// change navigation you need to add setState or setState is a
// Stateful widget property so you need to use a stateless
// widget
setState(() {
// need a counter variable
// assign counter variable with index
onClick = index;
// you can see the result by clicking on and print index
// by using print statement
print(onClick);
});
},
items: [
Icon(
Icons.arrow_forward,
size: 30,
),
Icon(
Icons.compare_arrows,
size: 30,
),
Icon(Icons.person, size: 30),
Icon(Icons.search, size: 30),
],
),
);
}
}
// that's it for today
// Like
// Share
// subscribe
// get all latest updates
//100daysOfflutter
//100DaysOfCode
// Jai Hind
| 0 |
mirrored_repositories/10DaysOfFlutter/lib | mirrored_repositories/10DaysOfFlutter/lib/Day9/image_show.dart | import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.dart';
class ImageShow extends StatefulWidget {
@override
_ImageShowState createState() => _ImageShowState();
}
class _ImageShowState extends State<ImageShow> {
int imageIndex = 0;
List imageList = [
Image.network(
'https://d1csarkz8obe9u.cloudfront.net/posterpreviews/nature-welcome-church-poster-template-4462aba18bb8695eaa7cd2ecded68fc6_screen.jpg?ts=1561468002'),
Image.network('https://wallpaperaccess.com/full/25636.jpg'),
Image.network(
'https://images.wallpaperscraft.com/image/mountain_river_trees_160481_3840x2160.jpg'),
Image.network(
'https://c4.wallpaperflare.com/wallpaper/376/331/823/3-316-16-9-aspect-ratio-s-sfw-wallpaper-preview.jpg'),
Image.network(
'https://i.pinimg.com/originals/b8/94/01/b89401be81d329ecb27280e34ef49627.jpg'),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Image Show"),
brightness: Brightness.dark,
centerTitle: true,
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CarouselSlider(
options: CarouselOptions(
autoPlay: true,
autoPlayAnimationDuration: Duration(milliseconds: 3000),
scrollDirection: Axis.horizontal,
// by default scroll direction is vertical
disableCenter: true,
autoPlayCurve: Curves.bounceIn,
initialPage: 0,
aspectRatio: 16 / 9,
),
items: imageList.map(
(imageIndex) {
return Builder(builder: (BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 14),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(20),
),
),
child: imageIndex,
);
});
},
).toList(),
),
],
),
);
}
}
// thats is for today
// subscribe to Code With Nix for daily update
// like
// share
// subscribe
// 100daysofflutter
// 100daysofcode
// #CodeWithNix
/// thank you all
| 0 |
mirrored_repositories/10DaysOfFlutter/lib | mirrored_repositories/10DaysOfFlutter/lib/Day11/NewContainer.dart | import 'dart:math';
// Day 11 Animated Container
import 'package:flutter/material.dart';
class AnimatedCotainerApp extends StatefulWidget {
@override
_AnimatedCotainerAppState createState() =>
_AnimatedCotainerAppState();
}
class _AnimatedCotainerAppState extends State<AnimatedCotainerApp> {
Color myColor =
Colors.green; // custome variable for color to animate color
// create height and width variable using double type
double myHeight = 100; // initail height
double myWidth = 140; // initaial witdh
//if you want to add rounded boundery
BorderRadiusGeometry myRadius = BorderRadius.circular(10);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("day 11 Animated Container "),
centerTitle: true,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AnimatedContainer(
duration: Duration(seconds: 1),
height: myHeight,
width: myWidth,
// use decoration property to apply circular radius
decoration: BoxDecoration(
color: myColor,
borderRadius: myRadius,
),
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
final random = Random();
myColor = Color.fromRGBO(
random.nextInt(255), // red
random.nextInt(255), //green
random.nextInt(255), // blue
1, // opacity
);
myHeight = random.nextInt(300).toDouble();
myWidth = random.nextInt(300).toDouble();
});
},
child: Icon(Icons.add),
),
);
}
}
// Thats it for today basics of animated container
//thank you
// Code With Nix
// 100DaysofFlutter
// 100DaysofCode
// #CodeWithNix
// like
// share
//comment
//Jai hind ///////// | 0 |
mirrored_repositories/10DaysOfFlutter/lib | mirrored_repositories/10DaysOfFlutter/lib/Day11/VideoPlayer.dart | import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
class CustomVideoPlayer extends StatefulWidget {
@override
_CustomVideoPlayerState createState() =>
_CustomVideoPlayerState();
}
class _CustomVideoPlayerState extends State<CustomVideoPlayer> {
VideoPlayerController controll;
@override
void initState() {
super.initState();
controll = VideoPlayerController.asset('assets\fast_furious_9.mp4')
..initialize().then((_) => setState(() {}));
controll.setLooping(true);
}
@override
void dispose() {
super.dispose();
controll.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Day 11 Video Player"),
centerTitle: true,
),
body: Stack(
children: [
controll.value.initialized
? AspectRatio(
aspectRatio: controll.value.aspectRatio,
child: VideoPlayer(controll),
)
: Container(),
Positioned(
left: 200,
top: 100,
child: IconButton(
icon: Icon(
controll.value.isPlaying
? Icons.pause
: Icons.play_arrow,
size: 40,
),
onPressed: () {
controll.value.isPlaying
? controll.pause()
: controll.play();
}),
),
],
),
);
}
}
| 0 |
mirrored_repositories/10DaysOfFlutter/lib | mirrored_repositories/10DaysOfFlutter/lib/Day8/ImageSlider.dart | import 'package:flutter/material.dart';
// day 8 Image slider using buttons
// create stateful widget
class ImageSlider extends StatefulWidget {
@override
_ImageSliderState createState() => _ImageSliderState();
}
class _ImageSliderState extends State<ImageSlider> {
// create variables for togle
int onClick = 0;
int onButtonClick = 0;
// create image list
final List imageList = [
Image.asset('assets/n1.png'),
Image.asset('assets/n2.png'),
Image.asset('assets/n3.png'),
Image.asset('assets/n4.jpg'),
Image.asset('assets/n5.jpg'),
Image.asset('assets/n6.png'),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Day 8 Image Slider"),
),
body: Column(
children: [
Container(
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: Icon(Icons.arrow_back_ios),
onPressed: () {
setState(() {
if (onClick == 0) {
onClick = imageList.length - 1;
} else {
onClick--;
}
});
},
),
Container(
height: 200,
width: 200,
child: imageList[onClick],
),
IconButton(
icon: Icon(Icons.arrow_forward_ios),
onPressed: () {
setState(() {
if (onClick == imageList.length - 1) {
onClick = 0;
} else {
onClick++;
}
});
})
],
),
),
SizedBox(height: 40),
Container(
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
FlatButton(
onPressed: () {
setState(() {
if (onButtonClick == 0) {
onButtonClick = imageList.length - 1;
} else {
onButtonClick--;
}
});
},
child: Row(
children: [
Icon(Icons.arrow_back),
Text("Prev"),
],
)),
Container(
height: 200,
width: 200,
child: imageList[onButtonClick],
),
FlatButton(
onPressed: () {
setState(() {
if (onButtonClick == imageList.length - 1) {
onButtonClick = 0;
} else {}
onButtonClick++;
});
},
child: Row(
children: [
Text("Next"),
Icon(Icons.arrow_forward),
],
)),
],
),
),
],
),
);
}
}
// That's it for today
// subscribe
//Like
// Share
// Comment
// 100DaysofFlutter
// CodeWithNix
// 100DaysofCode
| 0 |
mirrored_repositories/10DaysOfFlutter/lib | mirrored_repositories/10DaysOfFlutter/lib/Day2/NewListView.dart | // Day 2 Scrolling Option
import 'package:flutter/material.dart';
class NewListView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text(" Day 2"),
),
// there is one more way to do a scroll view design by using ListView Widget
// first you need to remove SingleChildScrollView
// change Column widget with ListView
body: ListView(
children: [
Container(
height: 200,
color: Colors.blue,
),
Container(
height: 300,
color: Colors.red,
),
Container(
height: 400,
color: Colors.green,
),
Container(
color: Colors.pink,
height: 200,
),
],
),
),
);
}
}
// Thats is for today see you all in next video
// show your support to us
// subscribe Code With Nix to Youtube all update from basic to advance Flutter Design
// 100daysOfFlutter
// Thank you all
| 0 |
mirrored_repositories/10DaysOfFlutter/lib | mirrored_repositories/10DaysOfFlutter/lib/Day7/Alert_Box.dart | // day 7 Alert Message
import 'package:flutter/material.dart';
class NewAlert extends StatefulWidget {
@override
_NewAlertState createState() => _NewAlertState();
}
class _NewAlertState extends State<NewAlert> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Day 7 Alert "),
centerTitle: true,
),
body: Column(
children: [
RaisedButton(
child: Text("Show Alert"),
onPressed: () {
setState(() {
showDialog(
context: context,
builder: (context) {
return AlertMessage();
},
);
});
}),
],
),
);
}
}
class AlertMessage extends StatelessWidget {
const AlertMessage({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return AlertDialog(
// define Alert what ever you want
// Text Message
// Images
// Action Buttons etc
title: Text("its me Alert"),
content: Image.asset('assets/alert-2.gif'),
actions: [
FlatButton(
onPressed: () {
print("Yes is Tapped");
},
child: Text("Yes")),
FlatButton(
onPressed: () {
print("No Is Tapped ");
},
child: Text("No")),
// if you wanna check that your action button is working or not
// add print statement to show
],
);
}
}
// Thats it for today
// see you all in next video
// Subscribe
// Like
// Share
// 100DaysofFlutter
// 100daysofcode
| 0 |
mirrored_repositories/10DaysOfFlutter/lib | mirrored_repositories/10DaysOfFlutter/lib/Day4/NewNavigation.dart | import 'package:flutter/material.dart';
class NewNavigation extends StatefulWidget {
@override
_NewNavigationState createState() => _NewNavigationState();
}
class _NewNavigationState extends State<NewNavigation> {
int clicked = 0;
final List pages = [
Container(color: Colors.red),
Container(color: Colors.green),
Container(color: Colors.pink),
Container(color: Colors.blueGrey),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Day 4 Navigation Bar"),
centerTitle: true,
),
body: pages[clicked],
bottomNavigationBar: BottomNavigationBar(
currentIndex: clicked,
type: BottomNavigationBarType.shifting,
// type: BottomNavigationBarType.fixed,
// backgroundColor: Colors.greenAccent,
onTap: (index) {
setState(() {
clicked = index;
});
},
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text("Home"),
backgroundColor: Colors.deepOrange,
),
BottomNavigationBarItem(
icon: Icon(Icons.widgets),
title: Text("Explore"),
backgroundColor: Colors.deepOrange,
),
BottomNavigationBarItem(
icon: Icon(Icons.search),
title: Text("Search"),
backgroundColor: Colors.deepOrange,
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
title: Text("Profile"),
backgroundColor: Colors.deepOrange,
),
],
),
);
}
}
| 0 |
mirrored_repositories/10DaysOfFlutter/lib | mirrored_repositories/10DaysOfFlutter/lib/Day1/NewContainer.dart | // Day 1 Flutter Basic to Advance Design Only For You Enjoy..
// work start in flutter by importing material package
import 'package:flutter/material.dart';
// like all programming language dart's Flutter also run by using main method
// create a Stateless Widgit
//give name of widget that you previously taken
class NewContainer extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
// return a Material App flutter page always load with the help materialApp widget
home: Scaffold(
appBar: AppBar(
title: Text("Day 1 Design"),
),
// then create body
// For Body we need a body property
body: Container(
// you can take any thing else as i'll take Container we would learn more about that latter
// pre ( Ctrl + Space ) to see the all properties of any widget
child: Column(
// to make all container in center we will use
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
// its upto you to apply mainAxis or CrossAxis Alignment property
// we are using Expanded Widget thats why the result are same if yo delete them.
children: [
Expanded(
child: Container(
height: 100,
width: 300,
color: Colors.red,
),
),
Expanded(
child: Container(
height: 100,
width: 250,
color: Colors.black,
),
),
Expanded(
child: Container(
height: 100,
width: 200,
color: Colors.amber,
),
),
Expanded(
child: Container(
height: 100,
width: 150,
color: Colors.blue,
),
),
Expanded(
child: Container(
height: 100,
width: 100,
color: Colors.brown,
),
),
Expanded(
child: Container(
height: 100,
width: 50,
color: Colors.greenAccent,
),
),
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/10DaysOfFlutter/lib | mirrored_repositories/10DaysOfFlutter/lib/Day5/NewDrawer.dart | import 'package:flutter/material.dart';
class NewDrawer extends StatefulWidget {
@override
_NewDrawerState createState() => _NewDrawerState();
}
class _NewDrawerState extends State<NewDrawer> {
int onClick = 0;
final List pages = [
Container(color: Colors.red),
Container(color: Colors.green),
Container(color: Colors.orange),
Container(color: Colors.brown),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Day 5 Drawer"),
centerTitle: true,
),
body: pages[onClick],
drawer: Drawer(
child: ListView(
children: [
ListTile(
title: Text("Red"),
onTap: () {
setState(() {
onClick = 0;
Navigator.pop(context);
});
},
),
ListTile(
title: Text("Green"),
onTap: () {
setState(() {
onClick = 1;
Navigator.pop(context);
});
},
),
ListTile(
title: Text("Orange"),
onTap: () {
setState(() {
onClick = 2;
Navigator.pop(context);
});
},
),
ListTile(
title: Text("Brown"),
onTap: () {
setState(() {
onClick = 3;
Navigator.pop(context);
});
},
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/10DaysOfFlutter/lib | mirrored_repositories/10DaysOfFlutter/lib/Day12/On_Borad.dart | import 'package:flutter_onboard/flutter_onboard.dart';
import 'package:provider/provider.dart';
import 'package:flutter/material.dart';
class NewOnBoard extends StatelessWidget {
final PageController _pageController = PageController();
@override
Widget build(BuildContext context) {
return Provider<OnBoardState>(
create: (_) => OnBoardState(),
child: Scaffold(
body: OnBoard(
onSkip: () {
print('Skipped');
},
onDone: () {
print('Done Tapped');
},
pageController: _pageController,
onBoardData: onBoardData,
titleStyles: TextStyle(
color: Colors.deepPurple,
fontSize: 18,
fontWeight: FontWeight.w900,
letterSpacing: 0.15,
),
descriptionStyles: TextStyle(
fontSize: 16,
color: Colors.blue.shade300,
),
pageIndicatorStyle: PageIndicatorStyle(
width: 100,
inactiveColor: Colors.deepPurple,
activeColor: Colors.purple,
inactiveSize: Size(8, 8),
activeSize: Size(12, 12),
),
skipButton: FlatButton(
onPressed: () {
print('skipped button tapped');
},
child: Text(
'Skip',
style: TextStyle(color: Colors.deepPurple),
),
),
nextButton: Consumer<OnBoardState>(
builder: (BuildContext context, OnBoardState state,
Widget child) {
return InkWell(
onTap: () => _onNextTap(state),
child: Container(
width: 230,
height: 50,
alignment: Alignment.center,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.blue,
Colors.deepPurple,
],
),
),
child: Text(
state.isLastPage ? "Done" : "Next",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
);
},
),
),
),
);
}
void _onNextTap(OnBoardState onBoardState) {
if (!onBoardState.isLastPage) {
_pageController.animateToPage(
onBoardState.page + 1,
duration: Duration(milliseconds: 250),
curve: Curves.easeInOutSine,
);
} else {
print("done");
}
}
final List<OnBoardModel> onBoardData = [
OnBoardModel(
title: "Set your own goals and get better",
description:
"Goal support your motivation and inspire you to work harder",
imgUrl: "assets\n3.png",
),
OnBoardModel(
title: "Track your progress with statistics",
description:
"Analyse personal result with detailed chart and numerical values",
imgUrl: 'assets\n2.png',
),
OnBoardModel(
title: "Create photo comparisons and share your results",
description:
"Take before and after photos to visualize progress and get the shape that you dream about",
imgUrl: 'assets\n1.png',
),
];
}
| 0 |
mirrored_repositories/10DaysOfFlutter/lib | mirrored_repositories/10DaysOfFlutter/lib/Day3/NewSliverAppBar.dart | import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class NewSliverAppBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: [
SliverAppBar(
centerTitle: true,
title: Text(
"Day 3 Sliver App Bar",
style: GoogleFonts.gelasio(
fontSize: 40,
color: Colors.yellow,
backgroundColor: Colors.black),
),
backgroundColor: Colors.greenAccent,
expandedHeight: 200,
flexibleSpace: FlexibleSpaceBar(
background: Image.network(
'https://www.thespruce.com/thmb/jsaa79w1VWVUR1u3nQM9ZNsNmiA=/216'
'7x1384/filters:fill(auto,1)/palm-tree-on-beach-big-579f66d35f9'
'b589aa979d113.jpg',
fit: BoxFit.fill,
),
),
),
SliverFixedExtentList(
itemExtent: 200,
delegate: SliverChildListDelegate(
[
Container(color: Colors.green[800]),
Container(color: Colors.green[600]),
Container(color: Colors.green[400]),
Container(color: Colors.green[200]),
Container(color: Colors.green[100]),
Container(color: Colors.green[50]),
],
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/10DaysOfFlutter | mirrored_repositories/10DaysOfFlutter/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:practiceproject/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/flutter-firebase-realtime-database | mirrored_repositories/flutter-firebase-realtime-database/lib/realtime_db.dart | import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.dart';
class realtime_db extends StatefulWidget {
@override
_realtime_dbState createState() => _realtime_dbState();
}
class _realtime_dbState extends State<realtime_db> {
late DatabaseReference _dbref;
String databasejson = "";
int countvalue =0;
@override
void initState() {
// TODO: implement initState
super.initState();
_dbref = FirebaseDatabase.instance.reference();
_dbref.child("myCountKey").child("key_counter").onValue.listen((event) {
print("counter update "+ event.snapshot.value.toString());
setState(() {
countvalue = event.snapshot.value;
});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: SingleChildScrollView(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text( countvalue.toString()+ " database - " + databasejson),
),
TextButton(
onPressed: () {
_createDB();
},
child: Text(" create DB")),
TextButton(onPressed: () {
_realdb_once();
}, child: Text(" read value")),
TextButton(onPressed: () {
_readdb_onechild();
}, child: Text(" read once child")),
TextButton(onPressed: () {
_updatevalue();
}, child: Text(" update value")),
TextButton(onPressed: () {
_updatevalue_count();
}, child: Text(" update counter value by 1")),
// _updatevalue_count()
TextButton(onPressed: () {
_delete();
}, child: Text(" delete value")),
],
),
),
),
);
}
_createDB() {
_dbref.child("profile").set(" kamal profile");
_dbref.child("jobprofile").set({'website': "www.blueappsoftware.com", "website2": "www.dripcoding.com"});
}
_realdb_once() {
_dbref.once().then((DataSnapshot dataSnapshot){
print(" read once - "+ dataSnapshot.value.toString() );
setState(() {
databasejson = dataSnapshot.value.toString();
});
});
}
_readdb_onechild(){
_dbref.child("jobprofile").child("website2").once().then((DataSnapshot dataSnapshot){
print(" read once - "+ dataSnapshot.value.toString() );
setState(() {
databasejson = dataSnapshot.value.toString();
});
});
}
_updatevalue(){
_dbref.child("jobprofile").update( { "website2": "www.dripcoding.com2"});
}
_updatevalue_count(){
_dbref.child("myCountKey").update({ "key_counter" : countvalue +1});
}
_delete(){
_dbref.child("profile").remove();
}
}
| 0 |
mirrored_repositories/flutter-firebase-realtime-database | mirrored_repositories/flutter-firebase-realtime-database/lib/main.dart | import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter_app_firebase_noti/realtime_db.dart';
Future<void> main() async{
WidgetsFlutterBinding.ensureInitialized();
FirebaseApp firebaseApp = await Firebase.initializeApp();
runApp(MaterialApp(
home: realtime_db(),
) );
}
| 0 |
mirrored_repositories/flutter-firebase-realtime-database | mirrored_repositories/flutter-firebase-realtime-database/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_app_firebase_noti/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/App-Expenses | mirrored_repositories/App-Expenses/lib/main.dart | import 'dart:math';
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'components/transaction_form.dart';
import 'components/transaction_list.dart';
import '../models/transactions.dart';
import 'components/chart.dart';
main() => runApp(ExpensesApp());
class ExpensesApp extends StatelessWidget {
ExpensesApp({Key? key}) : super(key: key);
final ThemeData tema = ThemeData();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
theme: tema.copyWith(
colorScheme: tema.colorScheme.copyWith(
primary: Color.fromARGB(255, 240, 184, 221),
secondary: Color.fromARGB(255, 158, 131, 230),
tertiary: Color.fromARGB(255, 197, 238, 186),
),
textTheme: tema.textTheme.copyWith(
headline6: const TextStyle(
fontFamily: 'OpenSans',
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.black,
),
button: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
appBarTheme: const AppBarTheme(
titleTextStyle: TextStyle(
fontFamily: 'OpenSans',
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final List<Transaction> _transactions = [];
bool _showChart = false;
List<Transaction> get _recentTransaction {
return _transactions.where((tr) {
return tr.date.isAfter(DateTime.now().subtract(
const Duration(days: 7),
));
}).toList();
}
_addTransaction(String title, double value, DateTime date) {
final newTransaction = Transaction(
id: Random().nextDouble().toString(),
title: title,
value: value,
date: date,
);
setState(() {
_transactions.add(newTransaction);
});
Navigator.of(context).pop();
}
_removeTransaction(String id) {
setState(() {
_transactions.removeWhere((tr) => tr.id == id);
});
}
_opentransactionFormModal(BuildContext context) {
showModalBottomSheet(
context: context,
builder: (_) {
return TransactionForm(_addTransaction);
},
);
}
Widget _getIconButton(IconData icon, Function() fn) {
return Platform.isIOS
? GestureDetector(onTap: fn, child: Icon(icon))
: IconButton(icon: Icon(icon), onPressed: fn);
}
@override
Widget build(BuildContext context) {
final mediaQuery = MediaQuery.of(context);
bool isLandscape = mediaQuery.orientation == Orientation.landscape;
final iconList = Platform.isIOS
? CupertinoIcons.list_bullet
: Icons.format_list_bulleted_rounded;
final iconChart = Platform.isIOS
? CupertinoIcons.chart_bar_alt_fill
: Icons.equalizer_rounded;
final actions = [
if (isLandscape)
_getIconButton(
_showChart ? iconList : iconChart,
() {
setState(() {
_showChart = !_showChart;
});
},
),
_getIconButton(
Platform.isIOS ? CupertinoIcons.add : Icons.add_rounded,
() => _opentransactionFormModal(context),
),
];
final PreferredSizeWidget appBar = AppBar(
title: const Text('Despesas Pessoais'),
actions: actions,
);
final availableHeight = mediaQuery.size.height -
appBar.preferredSize.height -
mediaQuery.padding.top;
final bodyPage = SafeArea(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
// if (isLandscape)
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Text('Exibir Gráfico'),
// Switch.adaptive(
// value: _showChart,
// onChanged: (value) {
// setState(() {
// _showChart = value;
// });
// },
// activeColor: Color.fromARGB(244, 244, 185, 136),
// inactiveTrackColor: Theme.of(context).colorScheme.tertiary,
// ),x
// ],
// ),
if (_showChart || !isLandscape)
Container(
height: availableHeight * (isLandscape ? 0.75 : 0.3),
child: Chart(_recentTransaction),
),
if (!_showChart || !isLandscape)
Container(
height: availableHeight * (isLandscape ? 1 : 0.7),
child: TransactionList(_transactions, _removeTransaction),
),
],
),
),
);
return Platform.isIOS
? CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text('Despesas Pessoais'),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: actions,
),
),
child: bodyPage,
)
: Scaffold(
appBar: appBar,
body: bodyPage,
floatingActionButton: Platform.isIOS
? Container()
: FloatingActionButton(
child: Icon(Icons.add_rounded),
onPressed: () => _opentransactionFormModal(context),
backgroundColor: Color.fromARGB(244, 244, 185, 136),
),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerFloat,
);
}
}
| 0 |
mirrored_repositories/App-Expenses/lib | mirrored_repositories/App-Expenses/lib/components/adaptative_button.dart | import 'package:flutter/cupertino.dart';
import 'dart:io';
import 'package:flutter/material.dart';
class AdaptativeButton extends StatelessWidget {
final String label;
final Function() onPressed;
const AdaptativeButton(
this.label,
this.onPressed, {
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Platform.isIOS
? CupertinoButton(
child: Text(label),
onPressed: onPressed,
color: Theme.of(context).colorScheme.tertiary,
padding: const EdgeInsets.symmetric(
horizontal: 20,
),
)
: ElevatedButton(
child: Text(
label,
style: TextStyle(
color: Theme.of(context).colorScheme.tertiary,
),
),
onPressed: onPressed,
style: ElevatedButton.styleFrom(
backgroundColor: Color.fromARGB(244, 244, 185, 136),
),
);
}
}
| 0 |
mirrored_repositories/App-Expenses/lib | mirrored_repositories/App-Expenses/lib/components/transaction_item.dart | import 'package:flutter/material.dart';
import '../models/transactions.dart';
import 'package:intl/intl.dart';
import 'dart:math';
class TransactionItem extends StatefulWidget {
const TransactionItem({
Key? key,
required this.tr,
required this.onRemove,
}) : super(key: key);
final Transaction tr;
final void Function(String p1) onRemove;
@override
State<TransactionItem> createState() => _TransactionItemState();
}
class _TransactionItemState extends State<TransactionItem> {
static const colors = [
Color.fromARGB(244, 238, 245, 140),
Color.fromARGB(255, 234, 182, 241),
Color.fromARGB(255, 156, 206, 247),
Color.fromARGB(255, 197, 238, 186)
];
Color? _backgroundColor;
@override
void initState() {
super.initState();
int i = Random().nextInt(4);
_backgroundColor = colors[i];
}
@override
Widget build(BuildContext context) {
return Card(
elevation: 5,
margin: const EdgeInsets.symmetric(
vertical: 8,
horizontal: 5,
),
child: ListTile(
leading: CircleAvatar(
foregroundColor: Theme.of(context).colorScheme.secondary,
backgroundColor: _backgroundColor,
radius: 30,
child: Padding(
padding: const EdgeInsets.all(6.0),
child: FittedBox(
child: Text('R\$${widget.tr.value}'),
),
),
),
title: Text(
widget.tr.title,
style: Theme.of(context).textTheme.headline6,
),
subtitle: Text(
DateFormat('d MMM y').format(widget.tr.date),
),
trailing: MediaQuery.of(context).size.width > 380
? TextButton.icon(
onPressed: (() => widget.onRemove(widget.tr.id)),
icon: const Icon(Icons.delete),
label: Text('Excluir'),
style: TextButton.styleFrom(
foregroundColor: const Color.fromARGB(244, 244, 185, 136),
),
)
: IconButton(
icon: const Icon(Icons.delete),
color: const Color.fromARGB(244, 244, 185, 136),
onPressed: (() => widget.onRemove(widget.tr.id)),
),
),
);
}
}
| 0 |
mirrored_repositories/App-Expenses/lib | mirrored_repositories/App-Expenses/lib/components/adaptative_text_field.dart | import 'package:flutter/cupertino.dart';
import 'dart:io';
import 'package:flutter/material.dart';
class AdaptativeTextField extends StatelessWidget {
final String? label;
final TextEditingController? controller;
final TextInputType keyboardType;
final Function(String)? onSubmitted;
const AdaptativeTextField({
this.label,
this.controller,
this.keyboardType = TextInputType.text,
this.onSubmitted,
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Platform.isIOS
? Padding(
padding: const EdgeInsets.only(
bottom: 10,
),
child: CupertinoTextField(
controller: controller,
keyboardType: keyboardType,
onSubmitted: onSubmitted,
placeholder: label,
padding: const EdgeInsets.symmetric(
horizontal: 6,
vertical: 12,
),
),
)
: TextField(
controller: controller,
keyboardType: keyboardType,
onSubmitted: onSubmitted,
decoration: InputDecoration(
labelText: label,
),
);
}
}
| 0 |
mirrored_repositories/App-Expenses/lib | mirrored_repositories/App-Expenses/lib/components/transaction_list.dart | import 'package:expenses/models/transactions.dart';
import 'package:flutter/material.dart';
import './transaction_item.dart';
class TransactionList extends StatelessWidget {
final List<Transaction> transactions;
final void Function(String) onRemove;
const TransactionList(this.transactions, this.onRemove, {Key? key})
: super(key: key);
@override
Widget build(BuildContext context) {
return transactions.isEmpty
? LayoutBuilder(
builder: (ctx, constraints) {
return Column(
children: <Widget>[
const SizedBox(height: 20),
Text(
'Nenhuma Transação Cadastrada!',
style: Theme.of(context).textTheme.headline6,
),
const SizedBox(height: 20),
SizedBox(
height: constraints.maxHeight * 0.60,
child: Image.asset(
'assets/images/waiting.png',
fit: BoxFit.cover,
),
),
],
);
},
)
: ListView.builder(
itemCount: transactions.length,
itemBuilder: (ctx, index) {
final tr = transactions[index];
return TransactionItem(
key: GlobalObjectKey(tr.id),
tr: tr,
onRemove: onRemove,
);
},
);
// ListView.builder(
// itemCount: transactions.length,
// itemBuilder: (ctx, index) {
// final tr = transactions[index];
// return TransactionItem(
// tr: tr,
// onRemove: onRemove,
// );
// },
// );
// }
}
}
| 0 |
mirrored_repositories/App-Expenses/lib | mirrored_repositories/App-Expenses/lib/components/chart.dart | import 'package:expenses/components/chart_bar.dart';
import 'package:expenses/models/transactions.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/container.dart';
import 'package:intl/intl.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'chart_bar.dart';
class Chart extends StatelessWidget {
final List<Transaction> recentTransaction;
Chart(this.recentTransaction);
List<Map<String, Object>> get groupedTransactions {
return List.generate(7, (index) {
final weekDay = DateTime.now().subtract(
Duration(days: index),
);
double totalSum = 0.0;
for (var i = 0; i < recentTransaction.length; i++) {
bool sameDay = recentTransaction[i].date.day == weekDay.day;
bool sameMonth = recentTransaction[i].date.month == weekDay.month;
bool sameYear = recentTransaction[i].date.year == weekDay.year;
if (sameDay && sameMonth && sameYear) {
totalSum += recentTransaction[i].value;
}
}
return {
'day': DateFormat.E().format(weekDay)[0],
'value': totalSum,
};
}).reversed.toList();
}
double get _weekTotalValue {
return groupedTransactions.fold(0.0, (sum, tr) {
return sum + (tr['value'] as double);
});
}
@override
Widget build(BuildContext context) {
return Card(
elevation: 6,
margin: const EdgeInsets.all(20),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: groupedTransactions.map((tr) {
return Flexible(
fit: FlexFit.tight,
child: ChartBar(
label: tr['day'] as String,
value: tr['value'] as double,
percentage: _weekTotalValue == 0
? 0
: (tr['value'] as double) / _weekTotalValue,
),
);
}).toList(),
),
),
);
}
}
| 0 |
mirrored_repositories/App-Expenses/lib | mirrored_repositories/App-Expenses/lib/components/chart_bar.dart | import 'package:flutter/cupertino.dart';
import 'package:flutter/src/widgets/container.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/material.dart';
class ChartBar extends StatelessWidget {
final String? label;
final double? value;
final double? percentage;
ChartBar({
this.label,
this.value,
this.percentage,
});
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (ctx, constraints) {
return Column(
children: [
SizedBox(
height: constraints.maxHeight * 0.15,
child: FittedBox(
child: Text('${value!.toStringAsFixed(2)}'),
),
),
SizedBox(height: constraints.maxHeight * 0.05),
SizedBox(
height: constraints.maxHeight * 0.6,
width: 10,
child: Stack(
alignment: Alignment.bottomCenter,
children: [
Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey,
width: 1.0,
),
color: const Color.fromRGBO(220, 220, 200, 1),
borderRadius: BorderRadius.circular(5),
),
),
FractionallySizedBox(
heightFactor: percentage,
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.secondary,
borderRadius: BorderRadius.circular(5),
),
),
),
],
),
),
SizedBox(height: constraints.maxHeight * 0.05),
Container(
height: constraints.maxHeight * 0.15,
child: FittedBox(child: Text(label!)),
),
],
);
},
);
}
}
| 0 |
mirrored_repositories/App-Expenses/lib | mirrored_repositories/App-Expenses/lib/components/adaptative_date_picker.dart | import 'package:flutter/cupertino.dart';
import 'package:intl/intl.dart';
import 'dart:io';
import 'package:flutter/material.dart';
class AdaptativeDatePicker extends StatelessWidget {
final DateTime? selectedDate;
final Function(DateTime)? onDateChanged;
const AdaptativeDatePicker({
this.selectedDate,
this.onDateChanged,
Key? key,
}) : super(key: key);
_showDatePicker(BuildContext context) {
showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2021),
lastDate: DateTime.now(),
).then((pickedDate) {
if (pickedDate == null) {
return;
}
onDateChanged!(pickedDate);
});
}
@override
Widget build(BuildContext context) {
return Platform.isIOS
? SizedBox(
height: 180,
child: CupertinoDatePicker(
mode: CupertinoDatePickerMode.date,
initialDateTime: DateTime.now(),
minimumDate: DateTime(2021),
maximumDate: DateTime.now(),
onDateTimeChanged: onDateChanged!,
),
)
: SizedBox(
height: 70,
child: Row(
children: [
Expanded(
child: Text(
selectedDate == null
? 'Nenhuma data selecionada!'
: 'Data Selecionada: ${DateFormat('dd/MM/y').format(selectedDate!)}',
),
),
TextButton(
onPressed: () => _showDatePicker(context),
child: const Text(
'Selecionar Data',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/App-Expenses/lib | mirrored_repositories/App-Expenses/lib/components/transaction_form.dart | import 'package:expenses/components/adaptative_button.dart';
import 'package:flutter/material.dart';
import 'adaptative_date_picker.dart';
import 'adaptative_text_field.dart';
class TransactionForm extends StatefulWidget {
final void Function(String, double, DateTime)? onSubmit;
const TransactionForm(this.onSubmit, {Key? key}) : super(key: key);
@override
State<TransactionForm> createState() => _TransactionFormState();
}
class _TransactionFormState extends State<TransactionForm> {
final _titleController = TextEditingController();
final _valueController = TextEditingController();
DateTime _selectedDate = DateTime.now();
_submitForm() {
final title = _titleController.text;
final value = double.tryParse(_valueController.text) ?? 0;
if (title.isEmpty || value <= 0 || _selectedDate == null) {
return;
}
widget.onSubmit!(title, value, _selectedDate);
}
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Card(
elevation: 5,
child: Padding(
padding: EdgeInsets.only(
top: 10,
left: 10,
right: 10,
bottom: 10 + MediaQuery.of(context).viewInsets.bottom,
),
child: Column(
children: [
AdaptativeTextField(
label: 'Título',
controller: _titleController,
onSubmitted: (_) => _submitForm,
),
AdaptativeTextField(
label: 'Valor (R\$)',
controller: _valueController,
keyboardType:
const TextInputType.numberWithOptions(decimal: true),
onSubmitted: (_) => _submitForm,
),
AdaptativeDatePicker(
selectedDate: _selectedDate,
onDateChanged: (newDate) {
setState(() {
_selectedDate = newDate;
});
},
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
AdaptativeButton(
'Nova Transação',
_submitForm,
),
],
)
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/App-Expenses/lib | mirrored_repositories/App-Expenses/lib/models/transactions.dart | class Transaction {
final String id;
final String title;
final double value;
final DateTime date;
Transaction({
required this.id,
required this.title,
required this.value,
required this.date,
});
}
| 0 |
mirrored_repositories/ssp_ce_ltrs | mirrored_repositories/ssp_ce_ltrs/lib/home_page.dart | import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:ssp_ce_ltrs/component_wrapper.dart';
import 'package:ssp_ce_ltrs/constants.dart';
import 'package:ssp_ce_ltrs/model/card1_model.dart';
import 'package:ssp_ce_ltrs/speech_home_page.dart';
import 'package:ssp_ce_ltrs/widget_mod.dart';
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<HomePage> {
_MyAppState() {
ComponentWrapper.instance; //init singleton to wrap components
}
@override
Widget build(BuildContext buildContext) {
SystemChrome.setEnabledSystemUIMode(
SystemUiMode.immersiveSticky); //Fullscreen display
// ComponentWrapper.instance.mainSongAudioCache
// .play("childrens-theme-madness-paranoia-kevin-macLeod.mp3");
double screenWidth = MediaQuery.of(buildContext).size.width;
double screenHeight = MediaQuery.of(buildContext).size.height;
Orientation orientation = MediaQuery.of(buildContext).orientation;
double bigButtonHeight = 0;
double bigButtonWidth = 0;
double separatorSize = 0;
double titleSize = 0;
double topPaddingCardImage = 0;
if (orientation == Orientation.portrait) {
bigButtonHeight = screenHeight * 0.85;
bigButtonWidth = screenWidth * 0.85;
separatorSize = screenHeight * 0.02;
titleSize = screenHeight * 0.07;
} else {
bigButtonHeight = screenHeight * 0.75;
bigButtonWidth = screenWidth * 0.80;
separatorSize = screenHeight * 0.05;
titleSize = screenHeight * 0.08;
}
return MaterialApp(
home: Scaffold(
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/bg-farm.jpg"),
fit: BoxFit.cover,
),
),
child: Column(
children: [
Container(
height: titleSize,
margin: EdgeInsets.only(
left: separatorSize,
top: separatorSize,
right: separatorSize),
child: Row(
children: [
Icon(
Icons.account_circle_rounded,
size: titleSize,
),
Text(
"Hello",
style: TextStyle(
fontFamily: "ChocolateBar",
fontSize: titleSize * 0.8),
)
],
),
),
SizedBox(
height: separatorSize,
),
Container(
height: bigButtonHeight,
child: ListView.builder(
scrollDirection: Axis.horizontal,
padding: EdgeInsets.only(left: separatorSize, right: 6),
itemCount: cards1.length,
itemBuilder: (context, index) {
return Material(
color: Colors.transparent,
child: Row(
children: [
Ink(
height: bigButtonHeight,
width: bigButtonWidth,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(28),
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(cards1[index].cardBackground)
.withOpacity(CARD_OPACITY),
Colors.greenAccent
.withOpacity(CARD_OPACITY)
])),
child: InkWell(
enableFeedback: false,
onTap: () {
ComponentWrapper.instance.audioCache2
.play("button-tap.wav");
Navigator.pushNamed(
buildContext, cards1[index].cardPage);
},
child: Stack(
children: [
Positioned.fill(
child: Align(
alignment: Alignment.topCenter,
child: Padding(
padding: EdgeInsets.only(
top: topPaddingCardImage),
child: Container(
child: Image.asset(
'assets/images/' +
cards1[index].cardImage,
fit: BoxFit.cover,
),
),
),
)),
Positioned.fill(
child: Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding:
const EdgeInsets.only(bottom: 50),
child: Text(
cards1[index].cardTitle,
style: TextStyle(
fontFamily: "ChocolateBar",
fontSize: 30,
color: Colors.white,
shadows: BORDERED_TEXT_SHADOW),
),
),
))
],
),
),
),
SizedBox(
width: separatorSize,
)
],
),
);
}),
)
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/ssp_ce_ltrs | mirrored_repositories/ssp_ce_ltrs/lib/sound.dart | import 'package:flutter/material.dart';
class Sound {
late String id;
late String soundCategory;
late String soundName;
late String soundPath;
late String imagePath;
late Color bgColor;
late Color displayColor;
late String displayType;
Sound.imageDisplay(String id, String soundCategory, String soundName,
String soundPath, String imagePath, Color bgColor) {
this.id = id;
this.soundCategory = soundCategory;
this.soundName = soundName;
this.soundPath = soundPath;
this.imagePath = imagePath;
this.bgColor = bgColor;
this.displayColor = Colors.transparent;
this.displayType = "image";
}
Sound.svgDisplay(String id, String soundCategory, String soundName,
String soundPath, String imagePath, Color bgColor, Color displayColor) {
this.id = id;
this.soundCategory = soundCategory;
this.soundName = soundName;
this.soundPath = soundPath;
this.imagePath = imagePath;
this.bgColor = bgColor;
this.displayColor = displayColor;
this.displayType = "svg";
}
Sound.textDisplay(String id, String soundCategory, String soundName,
String soundPath, Color bgColor, Color displayColor) {
this.id = id;
this.soundCategory = soundCategory;
this.soundName = soundName;
this.soundPath = soundPath;
this.imagePath = "";
this.bgColor = bgColor;
this.displayColor = displayColor;
this.displayType = "text";
}
}
| 0 |
mirrored_repositories/ssp_ce_ltrs | mirrored_repositories/ssp_ce_ltrs/lib/nav_bar.dart | import 'package:flutter/material.dart';
class NavBarWidgets {
int _selectedIndex = 0;
static const TextStyle optionStyle =
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
getNavBar() {
return BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.business),
label: 'Business',
),
BottomNavigationBarItem(
icon: Icon(Icons.school),
label: 'School',
),
],
currentIndex: _selectedIndex,
selectedItemColor: Colors.amber[800],
onTap: null,
);
}
}
| 0 |
mirrored_repositories/ssp_ce_ltrs | mirrored_repositories/ssp_ce_ltrs/lib/widget_mod.dart | import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
var BORDERED_TEXT_SHADOW = [
Shadow(
// bottomLeft
offset: Offset(-1.5, -1.5),
color: Colors.black),
Shadow(
// bottomRight
offset: Offset(1.5, -1.5),
color: Colors.black),
Shadow(
// topRight
offset: Offset(1.5, 1.5),
color: Colors.black),
Shadow(
// topLeft
offset: Offset(-1.5, 1.5),
color: Colors.black),
];
| 0 |
mirrored_repositories/ssp_ce_ltrs | mirrored_repositories/ssp_ce_ltrs/lib/component_wrapper.dart | import 'package:audioplayers/audioplayers.dart';
import 'package:ssp_ce_ltrs/sound_populator.dart';
class ComponentWrapper {
static ComponentWrapper? _instance;
late AudioPlayer audioPlayer;
late AudioPlayer mainSongAudioPlayer;
late AudioCache audioCache;
late AudioCache audioCache2;
late AudioCache mainSongAudioCache;
late SoundPopulator soundPopulator;
late bool mainSongAudioPlayState;
ComponentWrapper._() {
audioPlayer = AudioPlayer();
audioPlayer.setReleaseMode(ReleaseMode.STOP);
mainSongAudioPlayer = AudioPlayer();
mainSongAudioPlayer.setReleaseMode(ReleaseMode.STOP);
audioCache =
AudioCache(prefix: 'assets/sounds/speech/', fixedPlayer: audioPlayer);
audioCache2 =
AudioCache(prefix: 'assets/sounds/', fixedPlayer: audioPlayer);
mainSongAudioCache =
AudioCache(prefix: 'assets/sounds/', fixedPlayer: mainSongAudioPlayer);
soundPopulator = SoundPopulator();
}
static ComponentWrapper get instance => _instance ??= ComponentWrapper._();
}
| 0 |
mirrored_repositories/ssp_ce_ltrs | mirrored_repositories/ssp_ce_ltrs/lib/constants.dart | import 'package:ssp_ce_ltrs/speech_home_page.dart';
final double CARD_OPACITY = 0.98;
| 0 |
mirrored_repositories/ssp_ce_ltrs | mirrored_repositories/ssp_ce_ltrs/lib/speech_home_page.dart | import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:ssp_ce_ltrs/component_wrapper.dart';
import 'package:ssp_ce_ltrs/constants.dart';
import 'package:ssp_ce_ltrs/learn_speech/animal_speech_page.dart';
import 'package:ssp_ce_ltrs/model/card1_model.dart';
import 'package:ssp_ce_ltrs/model/card_speech_model.dart';
import 'package:ssp_ce_ltrs/widget_mod.dart';
class SpeechHomePage extends StatefulWidget {
const SpeechHomePage({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<SpeechHomePage> {
_MyAppState() {
ComponentWrapper.instance; //init singleton to wrap components
}
@override
Widget build(BuildContext buildContext) {
double screenWidth = MediaQuery.of(buildContext).size.width;
double screenHeight = MediaQuery.of(buildContext).size.height;
Orientation orientation = MediaQuery.of(buildContext).orientation;
double bigButtonHeight = 0;
double bigButtonWidth = 0;
double separatorSize = 0;
double titleSize = 0;
double topPaddingCardImage = 0;
if (orientation == Orientation.portrait) {
bigButtonHeight = screenHeight * 0.85;
bigButtonWidth = screenWidth * 0.85;
separatorSize = screenHeight * 0.02;
titleSize = screenHeight * 0.07;
topPaddingCardImage = 100;
} else {
bigButtonHeight = screenHeight * 0.75;
bigButtonWidth = screenWidth * 0.80;
separatorSize = screenHeight * 0.05;
titleSize = screenHeight * 0.08;
topPaddingCardImage = 10;
}
return MaterialApp(
home: Scaffold(
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/bg-farm.jpg"),
fit: BoxFit.cover,
),
),
child: Column(
children: [
Container(
height: titleSize,
margin: EdgeInsets.only(
left: separatorSize,
top: separatorSize,
right: separatorSize),
child: Row(
children: [
InkWell(
child: Icon(
Icons.chevron_left_rounded,
size: titleSize,
),
onTap: () {
ComponentWrapper.instance.audioCache2
.play("button-tap.wav");
Navigator.pop(buildContext);
},
enableFeedback: false,
)
],
),
),
SizedBox(
height: separatorSize,
),
Container(
height: bigButtonHeight,
child: ListView.builder(
scrollDirection: Axis.horizontal,
padding: EdgeInsets.only(left: separatorSize, right: 6),
itemCount: cardsSpeech.length,
itemBuilder: (context, index) {
return Material(
color: Colors.transparent,
child: Row(
children: [
Ink(
height: bigButtonHeight,
width: bigButtonWidth,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(28),
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(cardsSpeech[index].cardBackground)
.withOpacity(CARD_OPACITY),
Colors.blue.withOpacity(CARD_OPACITY)
])),
child: InkWell(
enableFeedback: false,
onTap: () async {
ComponentWrapper.instance.audioCache2
.play("button-tap.wav");
// ComponentWrapper.instance.mainSongAudioPlayer
// .stop();
await Navigator.pushNamed(buildContext,
cardsSpeech[index].cardPage);
// ComponentWrapper.instance.mainSongAudioCache.play(
// "childrens-theme-madness-paranoia-kevin-macLeod.mp3");
},
child: Stack(
children: [
Positioned.fill(
child: Align(
alignment: Alignment.topCenter,
child: Padding(
padding: EdgeInsets.only(
top: topPaddingCardImage),
child: Container(
child: Image.asset(
'assets/images/' +
cardsSpeech[index].cardImage,
fit: BoxFit.cover,
),
),
),
)),
Positioned.fill(
child: Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding:
const EdgeInsets.only(bottom: 50),
child: Text(
cardsSpeech[index].category,
style: TextStyle(
fontFamily: "ChocolateBar",
fontSize: 40,
color: Colors.white,
shadows: BORDERED_TEXT_SHADOW),
),
),
))
],
),
),
),
SizedBox(
width: separatorSize,
)
],
),
);
}),
)
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/ssp_ce_ltrs | mirrored_repositories/ssp_ce_ltrs/lib/sound_populator.dart | import 'package:flutter/material.dart';
import 'package:ssp_ce_ltrs/component_wrapper.dart';
import 'package:ssp_ce_ltrs/sound.dart';
import 'package:audioplayers/audioplayers.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:ssp_ce_ltrs/widget_mod.dart';
class SoundPopulator {
final int DEF_NUM_BUTTON_PER_ROW_PORTRAIT = 2;
final int DEF_NUM_BUTTON_PER_ROW_LANDSCAPE = 5;
List<Flexible> populateData(List<Sound> soundsData, Orientation orientation,
[int? numButtonPerRowPortrait, int? numButtonPerRowLandscape]) {
//AudioPlayer audioPlayer = ComponentWrapper.instance.audioPlayer;
AudioCache audioCache = ComponentWrapper.instance.audioCache;
List<Flexible> allDataGroupedEachRow = [];
List<Flexible> data = [];
int? numButtonEachRow = orientation == Orientation.portrait
? (numButtonPerRowPortrait == null
? DEF_NUM_BUTTON_PER_ROW_PORTRAIT
: numButtonPerRowPortrait)
: (numButtonPerRowLandscape == null
? DEF_NUM_BUTTON_PER_ROW_LANDSCAPE
: numButtonPerRowLandscape);
int counter = 0;
for (Sound sound in soundsData) {
Widget displayImageOrText;
if (sound.displayType == "text") {
// display text
print("display text: " + sound.soundName);
displayImageOrText = Container(
child: SizedBox.expand(
child: Text(
sound.soundName.toUpperCase(),
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: "ChocolateBar",
fontSize: 30,
shadows: BORDERED_TEXT_SHADOW),
)),
);
} else if (sound.displayType == "image") {
//displat image
print("display image: " + sound.imagePath);
displayImageOrText = Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/" + sound.imagePath),
fit: BoxFit.contain),
),
);
} else {
//displat svg
print("display svg: " + sound.imagePath);
displayImageOrText = Container(
child: SizedBox.expand(
child: SvgPicture.asset("assets/images/" + sound.imagePath)),
//color: Colors.black,
);
}
data.add(Flexible(
flex: 1,
child: Container(
margin: EdgeInsets.only(left: 15, right: 15, bottom: 15),
child: SizedBox.expand(
child: MaterialButton(
padding: EdgeInsets.all(8.0),
textColor: Colors.white,
color: sound.bgColor,
splashColor: Colors.greenAccent,
elevation: 8.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(
color: Colors.black12,
width: 1,
style: BorderStyle.solid)),
child: GestureDetector(
onTapDown: (_) {
print('Tapped onTapDown');
audioCache.play(sound.soundPath);
},
onTapCancel: () {
print('Tapped onTapCancel');
audioCache.play(sound.soundPath);
},
child: displayImageOrText,
),
// ),
onPressed: () {/* use onTapDown from GestureDetector */},
),
),
/*child: SizedBox.expand(
child: IconButton(
icon: Image.asset('images/cat.png'),
iconSize: 1,
color: sound.color,
onPressed: () {},
)*/
/* child: ElevatedButton(
child: Text("Button " + sound.soundName),
style: ElevatedButton.styleFrom(primary: sound.color),
onPressed: () {},
),*/
),
));
counter++;
if (counter == numButtonEachRow) {
print('dataPerRow.add');
allDataGroupedEachRow.add(Flexible(
flex: 1,
child: Row(
children: data,
)));
data = [];
counter = 0;
}
}
//add empty flex to show remain button
while (data.isNotEmpty && counter != numButtonEachRow) {
data.add(Flexible(flex: 1, child: Container()));
counter++;
}
if (data.isNotEmpty) {
allDataGroupedEachRow.add(Flexible(
flex: 1,
child: Row(
children: data,
)));
}
return allDataGroupedEachRow;
}
Widget populateData2(BuildContext buildContext, List<Sound> soundsData,
Orientation orientation,
[int? numButtonPerRowPortrait, int? numButtonPerRowLandscape]) {
AudioCache audioCache = ComponentWrapper.instance.audioCache;
var size = MediaQuery.of(buildContext).size;
var orientation = MediaQuery.of(buildContext).orientation;
int? numButtonEachRow = orientation == Orientation.portrait
? (numButtonPerRowPortrait == null
? DEF_NUM_BUTTON_PER_ROW_PORTRAIT
: numButtonPerRowPortrait)
: (numButtonPerRowLandscape == null
? DEF_NUM_BUTTON_PER_ROW_LANDSCAPE
: numButtonPerRowLandscape);
/*24 is for notification bar on Android*/
final double screenHeight = size.height;
final double screenWidth = size.width;
double titleSize = 0, buttonAreaHeight = 0, separatorSize = 0;
if (orientation == Orientation.portrait) {
titleSize = screenHeight * 0.07;
separatorSize = screenHeight * 0.02;
buttonAreaHeight = 1.2 * (screenHeight) / screenWidth;
} else {
titleSize = screenHeight * 0.08;
separatorSize = screenHeight * 0.05;
buttonAreaHeight = screenWidth / (screenHeight) / 1.4;
}
return GridView.count(
crossAxisCount: numButtonEachRow,
childAspectRatio: buttonAreaHeight,
children: List.generate(
soundsData.length,
(index) {
Widget displayImageOrText;
if (soundsData[index].displayType == "text") {
// display text
print(
"display text: " + soundsData[index].soundName.toUpperCase());
displayImageOrText = Container(
child: SizedBox.expand(
child: Text(
soundsData[index].soundName.toUpperCase(),
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: "ChocolateBar",
fontSize: 30,
shadows: BORDERED_TEXT_SHADOW),
)),
);
} else if (soundsData[index].displayType == "image") {
//displat image
print("display image: " + soundsData[index].imagePath);
displayImageOrText = Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
"assets/images/" + soundsData[index].imagePath),
fit: BoxFit.contain),
),
);
} else {
//displat svg
print("display svg: " + soundsData[index].imagePath);
displayImageOrText = Container(
child: SvgPicture.asset(
"assets/images/" + soundsData[index].imagePath),
color: Colors.black,
);
}
return MaterialButton(
padding: EdgeInsets.all(8.0),
textColor: Colors.white,
color: soundsData[index].bgColor,
splashColor: Colors.greenAccent,
elevation: 8.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(
color: Colors.black12,
width: 1,
style: BorderStyle.solid)),
child: GestureDetector(
onTapDown: (_) {
print('Tapped onTapDown');
audioCache.play(soundsData[index].soundPath);
},
onTapCancel: () {
print('Tapped onTapCancel');
audioCache.play(soundsData[index].soundPath);
},
child: displayImageOrText,
),
// ),
onPressed: () {/* use onTapDown from GestureDetector */},
);
},
));
}
}
| 0 |
mirrored_repositories/ssp_ce_ltrs | mirrored_repositories/ssp_ce_ltrs/lib/main.dart | import 'package:flutter/material.dart';
import 'package:ssp_ce_ltrs/home_page.dart';
import 'package:ssp_ce_ltrs/learn_speech/animal_speech_page.dart';
import 'package:ssp_ce_ltrs/learn_speech/color_speech_page.dart';
import 'package:ssp_ce_ltrs/learn_speech/household_speech_page.dart';
import 'package:ssp_ce_ltrs/learn_speech/letter_speech_page.dart';
import 'package:ssp_ce_ltrs/learn_speech/number_speech_page.dart';
import 'package:ssp_ce_ltrs/learn_speech/shape2d_speech_page.dart';
import 'package:ssp_ce_ltrs/learn_speech/shape3d_speech_page.dart';
import 'package:ssp_ce_ltrs/learn_speech/vehicle_speech_page.dart';
import 'package:ssp_ce_ltrs/speech_home_page.dart';
void main() {
runApp(MaterialApp(
title: 'Belajar',
initialRoute: 'homePage',
onGenerateRoute: (settings) {
Widget page = HomePage();
switch (settings.name) {
case '/speechHomePage':
page = SpeechHomePage();
break;
case '/animalSpeechPage':
page = AnimalSpeechPage();
break;
case '/vehicleSpeechPage':
page = VehicleSpeechPage();
break;
case '/householdSpeechPage':
page = HouseholdSpeechPage();
break;
case '/colorSpeechPage':
page = ColorSpeechPage();
break;
case '/shape2DSpeechPage':
page = Shape2DSpeechPage();
break;
case '/shape3DSpeechPage':
page = Shape3DSpeechPage();
break;
case '/letterSpeechPage':
page = LetterSpeechPage();
break;
case '/numberSpeechPage':
page = NumberSpeechPage();
break;
}
return PageRouteBuilder(pageBuilder: (_, __, ___) => page);
},
routes: {
'homePage': (context) => HomePage(),
'speechHomePage': (context) => SpeechHomePage(),
'animalSpeechPage': (context) => AnimalSpeechPage(),
},
));
}
| 0 |