repo_id
stringlengths 21
168
| file_path
stringlengths 36
210
| content
stringlengths 1
9.98M
| __index_level_0__
int64 0
0
|
---|---|---|---|
mirrored_repositories/Flutterdev-static-web/lib | mirrored_repositories/Flutterdev-static-web/lib/const/const_colors.dart | import 'package:flutter/material.dart';
class ConstColor{
static Color kbgColor = Color(0xffFAF5FF);
static Color kcolorBlue = Color(0xff2C5282);
} | 0 |
mirrored_repositories/Flutterdev-static-web/lib/ui | mirrored_repositories/Flutterdev-static-web/lib/ui/component/section2.dart | import 'package:flutter/material.dart';
import 'package:responsive_framework/responsive_framework.dart';
import 'package:velocity_x/velocity_x.dart';
class Section2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
decoration: BoxDecoration(
color: Vx.white,
boxShadow: [
BoxShadow(color: Colors.grey, offset: Offset(3, 3), blurRadius: 30)
]),
alignment: Alignment.center,
margin: EdgeInsets.symmetric(horizontal: 40),
child: VStack([
ResponsiveRowColumn(
rowColumn: !ResponsiveWrapper.of(context).isSmallerThan(DESKTOP),
rowCrossAxisAlignment: CrossAxisAlignment.start,
columnCrossAxisAlignment: CrossAxisAlignment.center,
columnMainAxisSize: MainAxisSize.min,
rowPadding: EdgeInsets.symmetric(horizontal: 80, vertical: 80),
columnPadding: EdgeInsets.symmetric(horizontal: 25, vertical: 50),
columnSpacing: 50,
rowSpacing: 50,
children: [
ResponsiveRowColumnItem(
rowFlex: 1,
rowFit: FlexFit.tight,
child: subWidget(
Icons.landscape, "Got a dog", "We'll bring a dog car seat"),
),
ResponsiveRowColumnItem(
rowFlex: 1,
rowFit: FlexFit.tight,
child: subWidget(
Icons.landscape, "Got a dog", "We'll bring a dog car seat"),
),
ResponsiveRowColumnItem(
rowFlex: 1,
rowFit: FlexFit.tight,
child: subWidget(
Icons.landscape, "Got a dog", "We'll bring a dog car seat"),
),
],
)
]),
);
}
}
Widget subWidget(IconData icon, String title, String text) => Container(
child: Row(
children: [
sub1Icon(
IconButton(
icon: Icon(icon),
onPressed: () {},
),
Vx.white,
),
Column(
children: [
Container(
alignment: Alignment.topLeft,
child: title.text.blue900.extraBold.size(15).make())
.pOnly(top: 20, bottom: 20),
Container(
alignment: Alignment.topLeft,
child: text.text.gray900.thin.light.center.heightRelaxed
.letterSpacing(1)
.make()),
],
)
],
));
Widget sub1Icon(Widget icon, Color color) => Container(
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
boxShadow: [
BoxShadow(color: Colors.grey, offset: Offset(2, 3), blurRadius: 30)
]),
child: CircleAvatar(
maxRadius: 25,
backgroundColor: color,
child: icon,
),
);
| 0 |
mirrored_repositories/Flutterdev-static-web/lib/ui | mirrored_repositories/Flutterdev-static-web/lib/ui/component/section4.dart | import 'package:flutter/material.dart';
import 'package:responsive_framework/responsive_framework.dart';
import 'package:velocity_x/velocity_x.dart';
class Section4 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Vx.indigo100,
),
child: VStack([
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 3.0, vertical: 20),
child: Container(
height: 3.0,
width: 50,
color: Colors.green,
),
),
Container(
alignment: Alignment.center,
child: "Monthly plans for less than a parking space"
.text
.blue900
.center
.extraBold
.size(25)
.make()),
Container(
alignment: Alignment.center,
width: 550,
child:
"All-inclusive, usage-based car subscriptions. Monthly plans based on how much you drive that includes parking,insurance,maintenance, and more."
.text
.gray900
.thin
.light
.justify
.heightRelaxed
.letterSpacing(1)
.make())
.p20(),
],
),
ResponsiveRowColumn(
rowColumn: !ResponsiveWrapper.of(context).isSmallerThan(DESKTOP),
rowCrossAxisAlignment: CrossAxisAlignment.start,
columnCrossAxisAlignment: CrossAxisAlignment.center,
columnMainAxisSize: MainAxisSize.min,
rowPadding: EdgeInsets.symmetric(horizontal: 80, vertical: 80),
columnPadding: EdgeInsets.symmetric(horizontal: 25, vertical: 50),
columnSpacing: 50,
rowSpacing: 50,
children: [
ResponsiveRowColumnItem(
rowFlex: 1,
rowFit: FlexFit.tight,
child: subWidget(
context,
"it's yours for a hours or a few days",
"educationists all over the world agree that if you educate a man",
Icons.local_parking,
"Freedom")
.card
.roundedNone
.make().whThreeForth(context)),
ResponsiveRowColumnItem(
rowFlex: 1,
rowFit: FlexFit.tight,
child: subWidget(
context,
"it's yours for a hours or a few days",
"educationists all over the world agree that if you educate a man",
Icons.local_parking,
"Gateway")
.card
.roundedNone
.elevation(70)
.make()
.whThreeForth(context)),
ResponsiveRowColumnItem(
rowFlex: 1,
rowFit: FlexFit.tight,
child: subWidget(
context,
"it's yours for a hours or a few days",
"educationists all over the world agree that if you educate a man",
Icons.local_parking,
"FlexPass")
.card
.roundedNone
.make().whThreeForth(context)),
],
)
]));
}
}
Column subWidget(BuildContext context, String text, String text2, IconData icon,
String title) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
alignment: Alignment.center,
child: title.text.blue900.extraBold.size(25).make())
.pOnly(bottom: 20),
Container(
alignment: Alignment.center,
child: text.text.gray900.thin.light.center.heightRelaxed
.letterSpacing(1)
.make()),
Container(
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(r"$150").text.bold.size(30).blue500.make().pOnly(top: 20),
Text("/month")
.text
.gray900
.thin
.light
.heightRelaxed
.letterSpacing(1)
.make().pOnly(top:30)
],
)),
Padding(
padding: EdgeInsets.symmetric(horizontal: 3.0, vertical: 10.0),
child: Container(
height: 1.0,
width: 300.0,
color: Vx.gray500,
),
),
Container(
alignment: Alignment.center,
child: text2.text.gray900.thin.light.center.heightRelaxed
.letterSpacing(1)
.make()
.pOnly(left: 10.0, right: 10.0))
.pOnly(top: 30, bottom: 30),
Container(
alignment: Alignment.center,
width: 150,
height: 50,
decoration: BoxDecoration(
color: Vx.green400, borderRadius: BorderRadius.circular(50)),
child: "Start with Flex".text.white.make(),
).pOnly(top: 20),
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
"View Plan details".text.blue500.make(),
Icon(
Icons.arrow_forward,
color: Vx.blue400,
)
],
)).pOnly(top: 20)
// .pOnly(left: 50),
],
);
}
| 0 |
mirrored_repositories/Flutterdev-static-web/lib/ui | mirrored_repositories/Flutterdev-static-web/lib/ui/component/section3.dart | import 'package:flutter/material.dart';
import 'package:responsive_framework/responsive_framework.dart';
import 'package:velocity_x/velocity_x.dart';
class Section3 extends StatefulWidget {
@override
_Section3State createState() => _Section3State();
}
class _Section3State extends State<Section3> {
@override
Widget build(BuildContext context) {
return Container(
// height: 700,
width: double.infinity,
decoration: BoxDecoration(
color: Vx.blue900,
image: DecorationImage(
colorFilter: ColorFilter.mode(Vx.blue900, BlendMode.color),
image: AssetImage("asset/images/2.png"),
fit: BoxFit.cover)),
child: VStack([
ResponsiveRowColumn(
rowColumn: !ResponsiveWrapper.of(context).isSmallerThan(DESKTOP),
rowCrossAxisAlignment: CrossAxisAlignment.start,
columnCrossAxisAlignment: CrossAxisAlignment.center,
columnMainAxisSize: MainAxisSize.min,
rowPadding: EdgeInsets.symmetric(horizontal: 80, vertical: 80),
columnPadding: EdgeInsets.symmetric(horizontal: 25, vertical: 50),
columnSpacing: 50,
rowSpacing: 50,
children: [
ResponsiveRowColumnItem(
rowFlex: 1,
rowFit: FlexFit.tight,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.symmetric(vertical: 20),
child: Container(
alignment: Alignment.topLeft,
height: 3.0,
width: 50,
color: Colors.green,
),
),
Container(
width: 300,
alignment: Alignment.topLeft,
child: "Always Drive On Identical Prius"
.text
.white
.extraBold
.size(25)
.make()),
Container(
alignment: Alignment.topLeft,
width: 350,
margin: EdgeInsets.only(left: 40),
child:
"The is the urgent need to educate the female child because educationists all over the world agree that if you educate a man, you educate an individual whereas if you educate a woman, you educate a whole nation. The woman is the mother of the society. To grow, a man has sit at the fit of a woman to be nurtured and to be taught the mysteries of life. We should educate the girl child to acquire more scientific ways of teaching the man"
.text
.green100
.thin
.light
.justify
.heightRelaxed
.letterSpacing(1)
.make())
.pOnly(top: 10),
Padding(
padding:
EdgeInsets.symmetric(horizontal: 3.0, vertical: 30.0),
child: Container(
height: 1.0,
width: 300.0,
color: Vx.gray500,
)),
Container(
alignment: Alignment.topLeft,
width: 350,
margin: EdgeInsets.only(left: 40),
child:
"educationists all over the world agree that if you educate a man, you educate an individual whereas if you educate a woman, you educate a whole nation. The woman is the mother of the society. To grow, a man has sit at the fit of a woman to be nurtured and to be taught the mysteries of life."
.text
.green100
.thin
.light
.justify
.heightRelaxed
.letterSpacing(1)
.make()),
],
),
),
ResponsiveRowColumnItem(
rowFlex: 1,
rowFit: FlexFit.tight,
child: Column(
children: [
Container(
child: Image(
image:AssetImage("asset/images/car.png") ,)
),
Container(
child: Image(
image:AssetImage("asset/images/carcar.png") ,)
).pOnly(top:60)
// Padding(
// padding:
// EdgeInsets.symmetric(horizontal: 3.0, vertical: 20),
// child: Container(
// height: 3.0,
// width: 50,
// color: Colors.green,
// ),
// ),
// Container(
// alignment: Alignment.center,
// child: "Simple and handy process"
// .text
// .white
// .extraBold
// .size(25)
// .make()),
// Container(
// alignment: Alignment.center,
// width: 550,
// child:
// "All-inclusive, usage-based car subscriptions. Monthly plans based on how much you drive that includes parking,insurance,maintenance, and more."
// .text
// .white
// .thin
// .light
// .justify
// .heightRelaxed
// .letterSpacing(1)
// .make())
// .p20(),
],
),
)
],
)
]),
).pOnly(top: 5);
}
}
| 0 |
mirrored_repositories/Flutterdev-static-web/lib/ui | mirrored_repositories/Flutterdev-static-web/lib/ui/component/block.dart | import 'package:flutter/material.dart';
import 'package:responsive_framework/responsive_framework.dart';
const List<Condition> blockWidthConstraints = [
Condition.equals(name: MOBILE, value: BoxConstraints(maxWidth: 600)),
Condition.equals(name: TABLET, value: BoxConstraints(maxWidth: 700)),
Condition.equals(name: MOBILE, value: BoxConstraints(maxWidth: 1280)),
];
EdgeInsets blockPadding(BuildContext context) => ResponsiveValue(context,
defaultValue: EdgeInsets.symmetric(horizontal: 55, vertical: 80),
valueWhen: [
Condition.smallerThan(
name: TABLET,
value: EdgeInsets.symmetric(horizontal: 15, vertical: 45))
]).value;
| 0 |
mirrored_repositories/Flutterdev-static-web/lib/ui | mirrored_repositories/Flutterdev-static-web/lib/ui/component/navbar.dart | import 'package:flutter/material.dart';
import 'package:port/const/const_colors.dart';
import 'package:responsive_framework/responsive_framework.dart';
import 'package:velocity_x/velocity_x.dart';
class NavBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: ConstColor.kbgColor,
appBar: VxAppBar(
backgroundColor: ConstColor.kbgColor,
elevation: 0,
leading: ResponsiveVisibility(
visible: false,
visibleWhen: [Condition.smallerThan(name: DESKTOP)],
child: Icon(
Icons.menu,
color: Vx.blue800,
),
),
title: ResponsiveVisibility(
replacement: navContent(),
visible: false,
visibleWhen: [Condition.equals(name: MOBILE)],
child: navContentMobile()),
actions: [
navBtn(),
],
),
);
}
Widget navBtn() {
return Row(
children: [
"Login".text.blue800.semiBold.make(),
SizedBox(
width: 10,
),
btnDesign(
text: "Sign Up".text.white.semiBold.make(),
elevation: 15,
color: Vx.blue800),
SizedBox(
width: 8.0,
),
],
);
}
Widget navBtnMobile() {
return Row(
children: [
btnDesign(
text: "Sign Up".text.white.semiBold.make(),
elevation: 15,
color: Vx.blue800),
],
);
}
Row navContent() {
return Row(
children: [
"FlutterDeveloper".text.size(20).blue800.tight.bold.italic.make(),
SizedBox(
width: 250,
),
ResponsiveVisibility(
visible: false,
visibleWhen: [Condition.equals(name: DESKTOP)],
child: Row(
children: [
"Home".text.semiBold.blue800.size(15).make(),
SizedBox(
width: 40,
),
"Pricing".text.semiBold.blue800.size(15).make(),
SizedBox(
width: 40,
),
"Product".text.semiBold.blue800.size(15).make(),
SizedBox(
width: 40,
),
"Contact us".text.semiBold.blue800.size(15).make(),
],
),
),
],
);
}
}
Row navContentMobile() {
return Row(
children: [
"FlutterDeveloper".text.size(20).blue800.tight.bold.italic.make(),
],
);
}
Widget btnDesign({Widget text, Color color, double elevation}) => RaisedButton(
onPressed: () {},
color: color,
child: text,
elevation: elevation,
);
| 0 |
mirrored_repositories/Flutterdev-static-web/lib/ui | mirrored_repositories/Flutterdev-static-web/lib/ui/component/section5.dart | import 'package:flutter/material.dart';
import 'package:velocity_x/velocity_x.dart';
class Footer extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
// margin: EdgeInsets.fromLTRB(0, 30.0, 0, 0),
height: 50,
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
"Made with".text.blue900.size(20).italic.make(),
" Love ".text.red500.size(20).italic.make(),
"by flutter developers".text.blue900.italic.size(20).make()
],
),
);
}
}
| 0 |
mirrored_repositories/Flutterdev-static-web/lib/ui | mirrored_repositories/Flutterdev-static-web/lib/ui/component/section1.dart | import 'package:flutter/material.dart';
import 'package:responsive_framework/responsive_framework.dart';
import 'package:velocity_x/velocity_x.dart';
import 'section2.dart';
class Section1 extends StatelessWidget {
const Section1({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
decoration: BoxDecoration(
color: Vx.indigo100,
),
child: Stack(
// alignment: Alignment.bottomCenter,
fit: StackFit.loose,
children: [
VStack([
Column(
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 3.0, vertical: 20),
child: Container(
height: 3.0,
width: 50,
color: Colors.green,
),
),
Container(
alignment: Alignment.center,
child: "Simple and handy process"
.text
.blue900
.extraBold
.size(25)
.make()),
Container(
alignment: Alignment.center,
width: 550,
child:
"All-inclusive, usage-based car subscriptions. Monthly plans based on how much you drive that includes parking,insurance,maintenance, and more."
.text
.gray900
.thin
.light
.justify
.heightRelaxed
.letterSpacing(1)
.make())
.p20(),
],
),
SizedBox(
height: 25,
),
ResponsiveRowColumn(
rowColumn:
!ResponsiveWrapper.of(context).isSmallerThan(DESKTOP),
rowCrossAxisAlignment: CrossAxisAlignment.start,
columnCrossAxisAlignment: CrossAxisAlignment.center,
columnMainAxisSize: MainAxisSize.min,
rowPadding: EdgeInsets.symmetric(horizontal: 80, vertical: 80),
columnPadding:
EdgeInsets.symmetric(horizontal: 25, vertical: 50),
columnSpacing: 50,
rowSpacing: 50,
children: [
ResponsiveRowColumnItem(
rowFlex: 1,
rowFit: FlexFit.tight,
child: subWidget(
context,
"Text when you want your car no app needed just an online account. Real human operators",
Icons.phone_iphone,
"Text us")),
ResponsiveRowColumnItem(
rowFlex: 1,
rowFit: FlexFit.tight,
child: subWidget(
context,
"Your car will arrive at your door - clean and fully fueled",
Icons.local_airport,
"We deliver")
.pOnly(top: 80)),
ResponsiveRowColumnItem(
rowFlex: 1,
rowFit: FlexFit.tight,
child: subWidget(
context,
"Hop in and go with you full insurance, FastTrak, Phone acessories and unlimited mileage",
Icons.landscape,
"You drive")),
ResponsiveRowColumnItem(
rowFlex: 1,
rowFit: FlexFit.tight,
child: subWidget(
context,
"it's yours for a hours or a few days.Return on your own time,anywhere.We'll gas and clean it",
Icons.local_parking,
"We pick it up")
.pOnly(top: 80)),
])
]),
ResponsiveVisibility(
visible: false,
visibleWhen: [Condition.equals(name: DESKTOP)],
child: Section2().pOnly(top: 600))
],
),
);
}
Column subWidget(
BuildContext context, String text, IconData icon, String title) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
iconDesign(
IconButton(
icon: Icon(icon),
onPressed: () {},
),
Vx.white,
context),
Container(
alignment: Alignment.center,
child: title.text.blue900.extraBold.size(15).make())
.pOnly(top: 20, bottom: 20),
Container(
alignment: Alignment.center,
child: text.text.gray900.thin.light.center.heightRelaxed
.letterSpacing(1)
.make()),
Padding(
padding: EdgeInsets.symmetric(horizontal: 3.0, vertical: 10.0),
child: Container(
height: 1.0,
width: 100.0,
color: Vx.gray500,
),
),
// .pOnly(left: 50),
],
);
}
}
Widget iconDesign(Widget icon, Color color, context) => Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
boxShadow: [
BoxShadow(color: Colors.grey, offset: Offset(2, 3), blurRadius: 30)
]),
child: CircleAvatar(
maxRadius: 35,
backgroundColor: color,
child: icon,
),
);
| 0 |
mirrored_repositories/Flutterdev-static-web/lib/ui | mirrored_repositories/Flutterdev-static-web/lib/ui/component/header.dart | import 'package:flare_flutter/flare_actor.dart';
import 'package:flutter/material.dart';
import 'package:port/const/const_colors.dart';
import 'package:velocity_x/velocity_x.dart';
class Header extends StatefulWidget {
@override
_HeaderState createState() => _HeaderState();
}
class _HeaderState extends State<Header> {
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: ConstColor.kbgColor,
image: DecorationImage(
colorFilter:
ColorFilter.mode(ConstColor.kbgColor, BlendMode.color),
image: AssetImage("asset/images/5.png"),
fit: BoxFit.cover)),
alignment: Alignment.topLeft,
padding: EdgeInsets.symmetric(horizontal: 50, vertical: 90),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children:<Widget>[
hLeftSide().pOnly(top:80),
Container(
height:500,
width:500,
child:FlareActor("asset/nima/Filip.flr", alignment:Alignment.center, fit:BoxFit.contain, animation:"idle")).pOnly(bottom:20)
]
),
);
}
Column hLeftSide() {
return Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
alignment: Alignment.topLeft,
child: "You drive.".text.blue900.extraBold.size(40).make()),
Container(
alignment: Alignment.topLeft,
child: "We'll handle the rest"
.text
.blue900
.extraBold
.size(40)
.make()).pOnly(bottom:40),
Container(
alignment: Alignment.topLeft,
child: "All-inclusive, usage-based car subscriptions."
.text
.gray900
.thin
.semiBold
.heightRelaxed
.make())
.pOnly(top: 30, bottom: 25),
Container(
alignment: Alignment.topLeft,
child: Row(
children: [
Container(
width: 250,
height: 45,
child: TextField(
decoration: InputDecoration(
hintText: "@ Enter your email...",
contentPadding: EdgeInsets.only(left: 10, right: 10),
border: OutlineInputBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(0)))),
),
),
btnTextField(text: "Subcribe")
],
),
),
Container(
alignment: Alignment.topLeft,
child: Row(
children: [
"Want to talk to our customer care?."
.text
.gray900
.thin
.semiBold
.heightRelaxed
.make(),
InkWell(
onHover: (_) {},
child: " Request a chat".text.black.bold.underline.make())
],
)).pOnly(top: 20),
],
);
}
}
Widget btnTextField({String text}) => Container(
height: 45,
width: 80,
alignment: Alignment.center,
child: Text(text).text.white.semiBold.make(),
decoration: BoxDecoration(
color: Vx.blue900,
borderRadius: BorderRadius.only(
topRight: Radius.circular(5), bottomRight: Radius.circular(5))),
);
| 0 |
mirrored_repositories/Flutterdev-static-web | mirrored_repositories/Flutterdev-static-web/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:port/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(HomePageDesign());
// 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/Mausam-Weather-App | mirrored_repositories/Mausam-Weather-App/lib/main.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:weather_app/res/app_color.dart';
import 'package:weather_app/view/home/home_screen.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return GetMaterialApp(
debugShowCheckedModeBanner: false,
title: 'Mausam',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: AppColor.defaultAppColor,
brightness: Brightness.dark
),
useMaterial3: true,
fontFamily: 'Lato',
),
home: const HomeScreen(),
);
}
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib/view | mirrored_repositories/Mausam-Weather-App/lib/view/home/home_screen.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:weather_app/utils/utils.dart';
import 'package:weather_app/view/home/widgets/appbar_widget.dart';
import 'package:weather_app/view/home/widgets/current_temp_widget.dart';
import 'package:weather_app/view/home/widgets/footer_widget.dart';
import 'package:weather_app/view/home/widgets/info_widget.dart';
import 'package:weather_app/view_model/controller/global_controller.dart';
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
final GlobalController globalController = Get.put(GlobalController());
Future<void> _refreshData() async {
await globalController.getLocationAndFetchWeather();
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: RefreshIndicator.adaptive(
onRefresh: _refreshData,
child: Obx(
() => globalController.checkLoading().isTrue
? const Center(
child: CircularProgressIndicator(),
)
: Container(
decoration: BoxDecoration(
gradient:
Utils.getBackgroundGradient(globalController.weatherMain),
),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: ListView(
children: const [
AppbarWidget(),
CurrentTempWidget(),
InfoWidget(),
FooterWidget(),
],
),
),
),
),
),
);
}
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib/view/home | mirrored_repositories/Mausam-Weather-App/lib/view/home/widgets/info_widget.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:weather_app/res/images/image_assets.dart';
import 'package:weather_app/view/home/widgets/components/frosted_container.dart';
import 'package:weather_app/view/home/widgets/components/horizontal_container.dart';
import 'package:weather_app/view/home/widgets/components/info_row.dart';
import 'package:weather_app/view/home/widgets/components/vertical_container.dart';
import 'package:weather_app/view_model/controller/global_controller.dart';
class InfoWidget extends StatelessWidget {
const InfoWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final GlobalController globalController = Get.put(GlobalController());
return Obx(
() => Row(
children: [
Expanded(
child: Column(
children: [
Row(
children: [
Expanded(
child: VerticalContainer(
label: 'Sunrise',
value: globalController.sunriseTime(),
imagePath: ImageAssets.sunrise,
),
),
Expanded(
child: VerticalContainer(
label: 'Sunset',
value: globalController.sunsetTime(),
imagePath: ImageAssets.sunset,
),
),
],
),
HorizontalContainer(
label: globalController.windDirection(),
value: globalController.windSpeed(),
imagePath: ImageAssets.wind,
),
],
),
),
Expanded(
child: FrostedContainer(
height: 170,
child: Padding(
padding: const EdgeInsets.all(15),
child: Column(
children: [
InfoRow(
label: 'Real Feel',
value: '${globalController.feelsLike()} °C',
),
InfoRow(
label: 'Pressure',
value: globalController.pressure(),
),
InfoRow(
label: 'Humidity',
value: globalController.humidity(),
),
InfoRow(
label: 'Visibility',
value: globalController.visibility(),
),
],
),
),
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib/view/home | mirrored_repositories/Mausam-Weather-App/lib/view/home/widgets/footer_widget.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:weather_app/utils/constants.dart';
import 'package:weather_app/view_model/controller/global_controller.dart';
class FooterWidget extends StatelessWidget {
const FooterWidget({super.key});
@override
Widget build(BuildContext context) {
final GlobalController globalController = Get.put(GlobalController());
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'OpenWeather',
style: lightBodyTextStyle,
),
Text(
'Last updated ${globalController.dtValue()}',
style: lightBodyTextStyle,
),
],
),
);
}
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib/view/home | mirrored_repositories/Mausam-Weather-App/lib/view/home/widgets/appbar_widget.dart | import 'package:flutter/material.dart';
import 'package:geocoding/geocoding.dart';
import 'package:get/get.dart';
import 'package:weather_app/utils/constants.dart';
import 'package:weather_app/utils/utils.dart';
import 'package:weather_app/view_model/controller/global_controller.dart';
class AppbarWidget extends StatefulWidget {
const AppbarWidget({super.key});
@override
State<AppbarWidget> createState() => _AppbarWidgetState();
}
class _AppbarWidgetState extends State<AppbarWidget> {
String city = '';
final GlobalController globalController =
Get.put(GlobalController(), permanent: true);
@override
void initState() {
getAddress(globalController.getLatitude().value,
globalController.getLongitude().value);
super.initState();
}
getAddress(lat, lon) async {
List<Placemark> placemark = await placemarkFromCoordinates(lat, lon);
Placemark place = placemark[0];
setState(() {
city = place.locality!;
});
}
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(city, style: mediumTextStyle),
Text(
Utils.date,
style: lightTitleTextStyle,
),
],
),
);
}
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib/view/home | mirrored_repositories/Mausam-Weather-App/lib/view/home/widgets/current_temp_widget.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:weather_app/utils/constants.dart';
import 'package:weather_app/view_model/controller/global_controller.dart';
class CurrentTempWidget extends StatelessWidget {
const CurrentTempWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final GlobalController globalController = Get.put(GlobalController());
return SizedBox(
height: MediaQuery.sizeOf(context).height * .6,
child: Obx(
() => Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
'assets/weather/${globalController.weatherIconCode()}.png',
),
const SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
globalController.currentTemperature(),
style: largeTextStyle,
),
Text(
'°C',
style: Theme.of(context).textTheme.headlineLarge,
),
],
),
Text(
globalController.weatherDescription(),
style: titleTextStyle,
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib/view/home/widgets | mirrored_repositories/Mausam-Weather-App/lib/view/home/widgets/components/horizontal_container.dart | import 'package:flutter/material.dart';
import 'package:weather_app/utils/constants.dart';
import 'package:weather_app/view/home/widgets/components/frosted_container.dart';
class HorizontalContainer extends StatelessWidget {
final String label, value;
final String imagePath;
const HorizontalContainer(
{super.key,
required this.label,
required this.value,
required this.imagePath});
@override
Widget build(BuildContext context) {
return FrostedContainer(
height: 65,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Image.asset(
imagePath,
width: 40,
height: 40,
),
Column(
children: [
Text(
label,
style: lightTitleTextStyle,
),
Text(
value,
style: titleTextStyle,
),
],
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib/view/home/widgets | mirrored_repositories/Mausam-Weather-App/lib/view/home/widgets/components/info_row.dart | import 'package:flutter/material.dart';
import 'package:weather_app/utils/constants.dart';
class InfoRow extends StatelessWidget {
final String label, value;
const InfoRow({super.key, required this.label, required this.value});
@override
Widget build(BuildContext context) {
return Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
label,
style: lightTitleTextStyle,
),
Text(
value,
style: titleTextStyle,
),
],
),
const Padding(
padding: EdgeInsets.only(bottom: 5),
child: Divider(
height: 10,
color: Colors.white70,
),
),
],
);
}
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib/view/home/widgets | mirrored_repositories/Mausam-Weather-App/lib/view/home/widgets/components/vertical_container.dart | import 'package:flutter/material.dart';
import 'package:weather_app/utils/constants.dart';
import 'package:weather_app/view/home/widgets/components/frosted_container.dart';
class VerticalContainer extends StatelessWidget {
final String label, value;
final String imagePath;
const VerticalContainer(
{super.key,
required this.label,
required this.value,
required this.imagePath});
@override
Widget build(BuildContext context) {
return FrostedContainer(
height: 100,
child: Padding(
padding: const EdgeInsets.all(10),
child: Column(
children: [
Image.asset(
imagePath,
width: 40,
height: 40,
),
Text(
label,
style: lightTitleTextStyle,
),
Text(
value,
style: titleTextStyle,
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib/view/home/widgets | mirrored_repositories/Mausam-Weather-App/lib/view/home/widgets/components/frosted_container.dart | import 'dart:ui';
import 'package:flutter/material.dart';
class FrostedContainer extends StatelessWidget {
final Widget child;
final double height;
const FrostedContainer({super.key, required this.child, required this.height});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(3.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(15),
child: Container(
height: height,
color: Colors.transparent,
child: Stack(
children: [
BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 4.0,
sigmaY: 4.0,
),
child: Container(),
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
border: Border.all(
color: Colors.white.withOpacity(0.07),
),
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Colors.white.withOpacity(0.15),
Colors.white.withOpacity(0.05),
]),
),
),
Center(
child: child,
),
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib | mirrored_repositories/Mausam-Weather-App/lib/res/app_color.dart | import 'package:flutter/material.dart';
class AppColor {
static const defaultAppColor = Colors.blue;
static const lightTextColor = Colors.white70;
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib/res | mirrored_repositories/Mausam-Weather-App/lib/res/app_url/app_url.dart | import 'package:weather_app/res/app_url/api_key.dart';
String weatherAppUrl(var lat, var lon) {
String url;
url =
'https://api.openweathermap.org/data/2.5/weather?lat=$lat&lon=$lon&appid=$apiKey&units=metric';
return url;
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib/res | mirrored_repositories/Mausam-Weather-App/lib/res/app_url/api_key.dart | const apiKey = '018271c2c88cef88401a229867e0b3a9';
| 0 |
mirrored_repositories/Mausam-Weather-App/lib/res | mirrored_repositories/Mausam-Weather-App/lib/res/images/image_assets.dart | class ImageAssets {
static const sunrise = 'assets/icons/sunrise.png';
static const sunset = 'assets/icons/sunset.png';
static const wind = 'assets/icons/wind.png';
static const feelsLike = 'assets/icons/feelslike.png';
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib | mirrored_repositories/Mausam-Weather-App/lib/data/app_exceptions.dart | class AppExceptions implements Exception {
final String? _prefix;
final String? _message;
AppExceptions([this._prefix, this._message]);
}
class InternetException extends AppExceptions {
InternetException([message]) : super('');
}
class RequestTimeOut extends AppExceptions {
RequestTimeOut([message]) : super('');
}
class ServerError extends AppExceptions {
ServerError([message]) : super('');
}
class InvalidUrlException extends AppExceptions {
InvalidUrlException([message]) : super('');
}
class FetchDataException extends AppExceptions {
FetchDataException([message]) : super('');
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib/data | mirrored_repositories/Mausam-Weather-App/lib/data/network/base_api_services.dart | abstract class BaseApiServices {
Future<dynamic> getWeatherApi(var lan, var lon);
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib/data | mirrored_repositories/Mausam-Weather-App/lib/data/network/api_services.dart | import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:weather_app/data/app_exceptions.dart';
import 'package:weather_app/data/network/base_api_services.dart';
import 'package:weather_app/res/app_url/app_url.dart';
class ApiServices extends BaseApiServices {
@override
Future getWeatherApi(lan, lon) async {
var jsonData;
try {
var response = await http
.get(Uri.parse(weatherAppUrl(lan, lon)))
.timeout(const Duration(seconds: 20));
jsonData = jsonResponse(response);
} on SocketException {
throw InternetException(
'No Internet',
);
} on RequestTimeOut {
throw RequestTimeOut(
'Request Timeout',
);
}
return jsonData;
}
dynamic jsonResponse(http.Response response) {
switch (response.statusCode) {
case 200:
var jsonResponse = jsonDecode(response.body);
return jsonResponse;
case 400:
var jsonResponse = jsonDecode(response.body);
return jsonResponse;
default:
throw FetchDataException(
'Error while Communication ${response.statusCode}',
);
}
}
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib | mirrored_repositories/Mausam-Weather-App/lib/model/weather_model.dart | class WeatherModel {
Coord? coord;
List<Weather>? weather;
String? base;
Main? main;
int? visibility;
Wind? wind;
Clouds? clouds;
int? dt;
Sys? sys;
int? timezone;
int? id;
String? name;
int? cod;
WeatherModel(
{this.coord,
this.weather,
this.base,
this.main,
this.visibility,
this.wind,
this.clouds,
this.dt,
this.sys,
this.timezone,
this.id,
this.name,
this.cod});
WeatherModel.fromJson(Map<String, dynamic> json) {
coord = json['coord'] != null ? Coord.fromJson(json['coord']) : null;
if (json['weather'] != null) {
weather = <Weather>[];
json['weather'].forEach((v) {
weather!.add(Weather.fromJson(v));
});
}
base = json['base'];
main = json['main'] != null ? Main.fromJson(json['main']) : null;
visibility = json['visibility'];
wind = json['wind'] != null ? Wind.fromJson(json['wind']) : null;
clouds = json['clouds'] != null ? Clouds.fromJson(json['clouds']) : null;
dt = json['dt'];
sys = json['sys'] != null ? Sys.fromJson(json['sys']) : null;
timezone = json['timezone'];
id = json['id'];
name = json['name'];
cod = json['cod'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
if (coord != null) {
data['coord'] = coord!.toJson();
}
if (weather != null) {
data['weather'] = weather!.map((v) => v.toJson()).toList();
}
data['base'] = base;
if (main != null) {
data['main'] = main!.toJson();
}
data['visibility'] = visibility;
if (wind != null) {
data['wind'] = wind!.toJson();
}
if (clouds != null) {
data['clouds'] = clouds!.toJson();
}
data['dt'] = dt;
if (sys != null) {
data['sys'] = sys!.toJson();
}
data['timezone'] = timezone;
data['id'] = id;
data['name'] = name;
data['cod'] = cod;
return data;
}
}
class Coord {
double? lon;
double? lat;
Coord({this.lon, this.lat});
Coord.fromJson(Map<String, dynamic> json) {
lon = json['lon'];
lat = json['lat'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['lon'] = lon;
data['lat'] = lat;
return data;
}
}
class Weather {
int? id;
String? main;
String? description;
String? icon;
Weather({this.id, this.main, this.description, this.icon});
Weather.fromJson(Map<String, dynamic> json) {
id = json['id'];
main = json['main'];
description = json['description'];
icon = json['icon'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['main'] = main;
data['description'] = description;
data['icon'] = icon;
return data;
}
}
class Main {
double? temp;
double? feelsLike;
double? tempMin;
double? tempMax;
int? pressure;
int? humidity;
int? seaLevel;
int? grndLevel;
Main(
{this.temp,
this.feelsLike,
this.tempMin,
this.tempMax,
this.pressure,
this.humidity,
this.seaLevel,
this.grndLevel});
Main.fromJson(Map<String, dynamic> json) {
temp = json['temp'];
feelsLike = json['feels_like'];
tempMin = json['temp_min'];
tempMax = json['temp_max'];
pressure = json['pressure'];
humidity = json['humidity'];
seaLevel = json['sea_level'];
grndLevel = json['grnd_level'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['temp'] = temp;
data['feels_like'] = feelsLike;
data['temp_min'] = tempMin;
data['temp_max'] = tempMax;
data['pressure'] = pressure;
data['humidity'] = humidity;
data['sea_level'] = seaLevel;
data['grnd_level'] = grndLevel;
return data;
}
}
class Wind {
double? speed;
int? deg;
double? gust;
Wind({this.speed, this.deg, this.gust});
Wind.fromJson(Map<String, dynamic> json) {
speed = json['speed'];
deg = json['deg'];
gust = json['gust'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['speed'] = speed;
data['deg'] = deg;
data['gust'] = gust;
return data;
}
}
class Clouds {
int? all;
Clouds({this.all});
Clouds.fromJson(Map<String, dynamic> json) {
all = json['all'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['all'] = all;
return data;
}
}
class Sys {
int? type;
int? id;
String? country;
int? sunrise;
int? sunset;
Sys({this.type, this.id, this.country, this.sunrise, this.sunset});
Sys.fromJson(Map<String, dynamic> json) {
type = json['type'];
id = json['id'];
country = json['country'];
sunrise = json['sunrise'];
sunset = json['sunset'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['type'] = type;
data['id'] = id;
data['country'] = country;
data['sunrise'] = sunrise;
data['sunset'] = sunset;
return data;
}
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib/view_model | mirrored_repositories/Mausam-Weather-App/lib/view_model/controller/global_controller.dart | import 'package:get/get.dart';
import 'package:geolocator/geolocator.dart';
import 'package:weather_app/data/network/api_services.dart';
import 'package:weather_app/model/weather_model.dart';
import 'package:weather_app/utils/utils.dart';
class GlobalController extends GetxController {
final RxBool _isLoading = true.obs;
final RxDouble latitude = 0.0.obs;
final RxDouble longitude = 0.0.obs;
final Rx<WeatherModel?> _weatherData = Rx<WeatherModel?>(null);
final RxString _weatherMain = ''.obs;
RxBool checkLoading() => _isLoading;
RxDouble getLatitude() => latitude;
RxDouble getLongitude() => longitude;
Rx<WeatherModel?> getWeatherModel() => _weatherData;
WeatherModel? weatherDataValue() => _weatherData.value;
String get weatherMain => _weatherMain.value;
void setWeatherMain(String value) {
_weatherMain.value = value;
}
String weatherDescription() =>
weatherDataValue()!.weather![0].description!.toUpperCase().toString();
String weatherIconCode() => weatherDataValue()!.weather![0].icon.toString();
String currentTemperature() =>
weatherDataValue()!.main!.temp!.round().toString();
String minTemperature() =>
weatherDataValue()!.main!.tempMin!.round().toString();
String maxTemperature() =>
weatherDataValue()!.main!.tempMax!.round().toString();
String pressure() => '${weatherDataValue()!.main!.pressure.toString()} hPa';
String humidity() => '${weatherDataValue()!.main!.humidity.toString()} %';
String visibility() =>
Utils.convertVisibility(weatherDataValue()!.visibility.toString());
String sunriseTime() =>
Utils.convertTimestampToTime(weatherDataValue()!.sys!.sunrise.toString());
String sunsetTime() =>
Utils.convertTimestampToTime(weatherDataValue()!.sys!.sunset.toString());
String windSpeed() =>
Utils.convertSpeed(weatherDataValue()!.wind!.speed.toString());
String windDirection() =>
Utils.getWindDirection(weatherDataValue()!.wind!.deg.toString());
String feelsLike() => weatherDataValue()!.main!.feelsLike!.round().toString();
String dtValue() => Utils.convertDtToTime(weatherDataValue()!.dt.toString());
@override
void onInit() {
super.onInit();
if (_isLoading.isTrue) {
getLocationAndFetchWeather();
}
}
Future<void> getLocationAndFetchWeather() async {
try {
await getLocation();
await getWeather();
} catch (e) {
print('Error: $e');
} finally {
_isLoading.value = false;
}
}
Future<void> getLocation() async {
try {
bool serviceEnabled;
LocationPermission permission;
serviceEnabled = await Geolocator.isLocationServiceEnabled();
permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.denied) {
Get.snackbar(
'Location',
'Location permissions are denied',
snackPosition: SnackPosition.BOTTOM,
);
return Future.error('Location permissions are denied');
}
}
if (permission == LocationPermission.deniedForever) {
return Future.error(
'Location permissions are permanently denied, we cannot request permissions.');
}
final position = await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.best,
);
latitude.value = position.latitude;
longitude.value = position.longitude;
} catch (e) {
print('Error getting location: $e');
}
}
Future<void> getWeather() async {
try {
final weatherData = await ApiServices().getWeatherApi(
latitude.value,
longitude.value,
);
final weatherModel = WeatherModel.fromJson(weatherData);
setWeatherMain(weatherModel.weather![0].main!.toString());
_weatherData.value = weatherModel;
} catch (e) {
print('Error fetching weather data: $e');
}
}
}
| 0 |
mirrored_repositories/Mausam-Weather-App/lib | mirrored_repositories/Mausam-Weather-App/lib/utils/constants.dart | import 'package:flutter/material.dart';
import 'package:weather_app/res/app_color.dart';
//text styles
const largeTextStyle = TextStyle(
fontSize: 60,
);
const mediumTextStyle = TextStyle(
fontSize: 36,
);
const headingTextStyle = TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
);
const titleTextStyle = TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
);
const lightTitleTextStyle = TextStyle(
fontSize: 14,
color: AppColor.lightTextColor,
);
const bodyTextStyle = TextStyle(
fontSize: 12,
);
const lightBodyTextStyle = TextStyle(
fontSize: 12,
color: AppColor.lightTextColor,
);
| 0 |
mirrored_repositories/Mausam-Weather-App/lib | mirrored_repositories/Mausam-Weather-App/lib/utils/utils.dart | import 'package:intl/intl.dart';
import 'package:flutter/material.dart';
class Utils {
static String date = DateFormat('yMMMMd').format(DateTime.now());
static String convertVisibility(String visibilityMeters) {
double visibilityKm = double.parse(visibilityMeters) / 1000.0;
return '${visibilityKm.toStringAsFixed(0)} Km';
}
static String convertSpeed(String speedMetersPerSecond) {
double speedKilometersPerHour = double.parse(speedMetersPerSecond) * 3.6;
return '${speedKilometersPerHour.toStringAsFixed(0)} km/h';
}
static String getWindDirection(String degrees) {
int degreesInt = int.tryParse(degrees) ?? 0;
if (degreesInt >= 338 || degreesInt < 23) {
return 'North';
} else if (degreesInt >= 23 && degreesInt < 68) {
return 'Northeast';
} else if (degreesInt >= 68 && degreesInt < 113) {
return 'East';
} else if (degreesInt >= 113 && degreesInt < 158) {
return 'Southeast';
} else if (degreesInt >= 158 && degreesInt < 203) {
return 'South';
} else if (degreesInt >= 203 && degreesInt < 248) {
return 'Southwest';
} else if (degreesInt >= 248 && degreesInt < 293) {
return 'West';
} else {
return 'Northwest';
}
}
static String convertTimestampToTime(String timestamp) {
int timestampInt = int.tryParse(timestamp) ?? 0;
final DateTime dateTime =
DateTime.fromMillisecondsSinceEpoch(timestampInt * 1000);
final String formattedTime = DateFormat('h:mm a').format(dateTime);
return formattedTime;
}
static String convertDtToTime(String dt) {
int dtInt = int.tryParse(dt) ?? 0;
final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(dtInt * 1000);
final String formattedTime = DateFormat('h:mm a').format(dateTime);
return formattedTime;
}
static LinearGradient getBackgroundGradient(String weatherMain) {
LinearGradient linearGradient;
switch (weatherMain.toLowerCase()) {
case 'clear':
case 'snow':
linearGradient = const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.lightBlue,
Colors.indigoAccent,
],
);
break;
case 'smoke':
case 'haze':
case 'squall':
case 'tornado':
linearGradient = const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.lightBlue,
Colors.blueGrey,
],
);
break;
case 'dust':
case 'sand':
linearGradient = const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.grey,
Colors.brown,
],
);
break;
case 'fog':
case 'mist':
case 'ash':
linearGradient = const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.lightBlue,
Colors.white70
],
);
break;
case 'clouds':
case 'thunderstorm':
linearGradient = const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.grey,
Colors.blueGrey,
],
);
break;
case 'rain':
case 'drizzle':
linearGradient = const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.blue,
Colors.indigo,
],
);
break;
default:
linearGradient = const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.grey,
Colors.white70
],
);
}
return linearGradient;
}
}
| 0 |
mirrored_repositories/Mausam-Weather-App | mirrored_repositories/Mausam-Weather-App/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 in the flutter_test package. 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:weather_app/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const 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/Response/ResponseApp | mirrored_repositories/Response/ResponseApp/lib/main.dart | import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'views/DetailedNewsPage.dart';
import 'views/HomePage.dart';
import 'views/MapsBody.dart';
import 'views/NewsBody.dart';
import 'views/OnboardingScreen.dart';
import 'views/SOS.dart';
import 'views/SOSselect.dart';
import 'views/WhatToDoBody.dart';
import 'package:response/views/Flood.dart';
void main() {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
statusBarColor: Colors.black,
systemNavigationBarColor: Platform.isAndroid ? Colors.black : null,
systemNavigationBarDividerColor: Colors.black,
),
);
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
runApp(ResponseApp());
}
class ResponseApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
initialRoute: HomePage.id,
routes: {
OnboardingScreen.id: (context) => OnboardingScreen(),
//Home Screens
HomePage.id: (context) => HomePage(),
WhatToDoBody.id: (context) => WhatToDoBody(),
NewsBody.id: (context) => NewsBody(),
MapsBody.id: (context) => MapsBody(),
Flood.id: (context) => Flood(),
//SOS page
SOS.id: (context) => SOS(),
SOSselect.id: (context) => SOSselect(),
//Detailed Screens
DetailedNewsPage.id: (context) => DetailedNewsPage(),
},
);
}
}
| 0 |
mirrored_repositories/Response/ResponseApp | mirrored_repositories/Response/ResponseApp/lib/test.dart | import 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:response/utilities/LocationService.dart';
class HomePage1 extends StatefulWidget {
@override
HomePageState createState() => HomePageState();
}
class HomePageState extends State<HomePage1> {
Completer<GoogleMapController> _controller = Completer();
LocationService locationService = LocationService();
double _latitude = 19.095212;
double _longitude = 72.863363;
void getLocationData() async {
_latitude = await locationService.getLat();
_longitude = await locationService.getLong();
}
@override
void initState() {
getLocationData();
super.initState();
}
double zoomVal = 5.0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {
//
}),
title: Text("New York"),
actions: <Widget>[
IconButton(
icon: Icon(Icons.arrow_forward),
onPressed: () {
//
}),
],
),
body: Stack(
children: <Widget>[
_buildGoogleMap(context),
_zoomminusfunction(),
_zoomplusfunction(),
_buildContainer(),
],
),
);
}
Widget _zoomminusfunction() {
return Align(
alignment: Alignment.topLeft,
child: IconButton(
icon: Icon(Icons.zoom_out, color: Color(0xff6200ee)),
onPressed: () {
zoomVal--;
_minus(zoomVal);
}),
);
}
Widget _zoomplusfunction() {
return Align(
alignment: Alignment.topRight,
child: IconButton(
icon: Icon(Icons.zoom_in, color: Color(0xff6200ee)),
onPressed: () {
zoomVal++;
_plus(zoomVal);
}),
);
}
Future<void> _minus(double zoomVal) async {
final GoogleMapController controller = await _controller.future;
controller.animateCamera(CameraUpdate.newCameraPosition(
CameraPosition(target: LatLng(40.712776, -74.005974), zoom: zoomVal)));
}
Future<void> _plus(double zoomVal) async {
final GoogleMapController controller = await _controller.future;
controller.animateCamera(CameraUpdate.newCameraPosition(
CameraPosition(target: LatLng(40.712776, -74.005974), zoom: zoomVal)));
}
Widget _buildContainer() {
return Align(
alignment: Alignment.bottomLeft,
child: Container(
margin: EdgeInsets.symmetric(vertical: 20.0),
height: 150.0,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
SizedBox(width: 10.0),
Padding(
padding: const EdgeInsets.all(8.0),
child: _boxes(
"https://lh5.googleusercontent.com/p/AF1QipO3VPL9m-b355xWeg4MXmOQTauFAEkavSluTtJU=w225-h160-k-no",
40.738380,
-73.988426,
"Gramercy Tavern"),
),
SizedBox(width: 10.0),
Padding(
padding: const EdgeInsets.all(8.0),
child: _boxes(
"https://lh5.googleusercontent.com/p/AF1QipMKRN-1zTYMUVPrH-CcKzfTo6Nai7wdL7D8PMkt=w340-h160-k-no",
40.761421,
-73.981667,
"Le Bernardin"),
),
SizedBox(width: 10.0),
Padding(
padding: const EdgeInsets.all(8.0),
child: _boxes(
"https://images.unsplash.com/photo-1504940892017-d23b9053d5d4?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60",
40.732128,
-73.999619,
"Blue Hill"),
),
],
),
),
);
}
Widget _boxes(String _image, double, double long, String restaurantName) {
return GestureDetector(
onTap: () {
_gotoLocation(_latitude, _longitude);
},
child: Container(
child: new FittedBox(
child: Material(
color: Colors.white,
elevation: 14.0,
borderRadius: BorderRadius.circular(24.0),
shadowColor: Color(0x802196F3),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
width: 180,
height: 200,
child: ClipRRect(
borderRadius: new BorderRadius.circular(24.0),
child: Image(
fit: BoxFit.fill,
image: NetworkImage(_image),
),
),
),
Container(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: myDetailsContainer1(restaurantName),
),
),
],
)),
),
),
);
}
Widget myDetailsContainer1(String restaurantName) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Container(
child: Text(
restaurantName,
style: TextStyle(
color: Color(0xff6200ee),
fontSize: 24.0,
fontWeight: FontWeight.bold),
)),
),
SizedBox(height: 5.0),
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Container(
child: Text(
"4.1",
style: TextStyle(
color: Colors.black54,
fontSize: 18.0,
),
)),
Container(
child: Icon(
Icons.star_border,
color: Colors.amber,
size: 15.0,
),
),
Container(
child: Icon(
Icons.star,
color: Colors.amber,
size: 15.0,
),
),
Container(
child: Icon(
Icons.star_border,
color: Colors.amber,
size: 15.0,
),
),
Container(
child: Icon(
Icons.star,
color: Colors.amber,
size: 15.0,
),
),
Container(
child: Icon(
Icons.star_half,
color: Colors.amber,
size: 15.0,
),
),
Container(
child: Text(
"(946)",
style: TextStyle(
color: Colors.black54,
fontSize: 18.0,
),
)),
],
)),
SizedBox(height: 5.0),
Container(
child: Text(
"American \u00B7 \u0024\u0024 \u00B7 1.6 mi",
style: TextStyle(
color: Colors.black54,
fontSize: 18.0,
),
)),
SizedBox(height: 5.0),
Container(
child: Text(
"Closed \u00B7 Opens 17:00 Thu",
style: TextStyle(
color: Colors.black54,
fontSize: 18.0,
fontWeight: FontWeight.bold),
)),
],
);
}
Widget _buildGoogleMap(BuildContext context) {
return Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: GoogleMap(
mapType: MapType.normal,
initialCameraPosition:
CameraPosition(target: LatLng(40.712776, -74.005974), zoom: 12),
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
markers: {
newyork1Marker,
newyork2Marker,
newyork3Marker,
gramercyMarker,
bernardinMarker,
blueMarker
},
),
);
}
Future<void> _gotoLocation(double lat, double long) async {
final GoogleMapController controller = await _controller.future;
controller.animateCamera(CameraUpdate.newCameraPosition(CameraPosition(
target: LatLng(lat, long),
zoom: 15,
tilt: 50.0,
bearing: 45.0,
)));
}
}
Marker gramercyMarker = Marker(
markerId: MarkerId('gramercy'),
position: LatLng(40.738380, -73.988426),
infoWindow: InfoWindow(title: 'Gramercy Tavern'),
icon: BitmapDescriptor.defaultMarkerWithHue(
BitmapDescriptor.hueViolet,
),
);
Marker bernardinMarker = Marker(
markerId: MarkerId('bernardin'),
position: LatLng(40.761421, -73.981667),
infoWindow: InfoWindow(title: 'Le Bernardin'),
icon: BitmapDescriptor.defaultMarkerWithHue(
BitmapDescriptor.hueViolet,
),
);
Marker blueMarker = Marker(
markerId: MarkerId('bluehill'),
position: LatLng(40.732128, -73.999619),
infoWindow: InfoWindow(title: 'Blue Hill'),
icon: BitmapDescriptor.defaultMarkerWithHue(
BitmapDescriptor.hueViolet,
),
);
//New York Marker
Marker newyork1Marker = Marker(
markerId: MarkerId('newyork1'),
position: LatLng(40.742451, -74.005959),
infoWindow: InfoWindow(title: 'Los Tacos'),
icon: BitmapDescriptor.defaultMarkerWithHue(
BitmapDescriptor.hueViolet,
),
);
Marker newyork2Marker = Marker(
markerId: MarkerId('newyork2'),
position: LatLng(40.729640, -73.983510),
infoWindow: InfoWindow(title: 'Tree Bistro'),
icon: BitmapDescriptor.defaultMarkerWithHue(
BitmapDescriptor.hueViolet,
),
);
Marker newyork3Marker = Marker(
markerId: MarkerId('newyork3'),
position: LatLng(40.719109, -74.000183),
infoWindow: InfoWindow(title: 'Le Coucou'),
icon: BitmapDescriptor.defaultMarkerWithHue(
BitmapDescriptor.hueViolet,
),
);
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/views/HomePageDialogflow.dart | import 'package:flutter/material.dart';
import 'package:flutter_dialogflow/dialogflow_v2.dart';
import 'package:response/widgets/CustomAppBar.dart';
class HomePageDialogflow extends StatefulWidget {
HomePageDialogflow({Key key, this.title}) : super(key: key);
final String title;
@override
_HomePageDialogflow createState() => new _HomePageDialogflow();
}
class _HomePageDialogflow extends State<HomePageDialogflow> {
final List<ChatMessage> _messages = <ChatMessage>[];
final TextEditingController _textController = new TextEditingController();
Widget _buildTextComposer() {
return new IconTheme(
data: new IconThemeData(color: Theme.of(context).accentColor),
child: SafeArea(
bottom: true,
top: false,
left: false,
right: false,
child: new Container(
margin: const EdgeInsets.symmetric(horizontal: 8.0),
child: new Row(
children: <Widget>[
new Flexible(
child: new TextField(
controller: _textController,
onSubmitted: _handleSubmitted,
decoration:
new InputDecoration.collapsed(hintText: "Send a message"),
),
),
new Container(
margin: new EdgeInsets.symmetric(horizontal: 4.0),
child: new IconButton(
icon: new Icon(Icons.send),
onPressed: () => _handleSubmitted(_textController.text)),
),
],
),
),
),
);
}
void response(query) async {
_textController.clear();
AuthGoogle authGoogle =
await AuthGoogle(fileJson: "assets/json/credentials.json").build();
Dialogflow dialogflow =
Dialogflow(authGoogle: authGoogle, language: Language.english);
AIResponse response = await dialogflow.detectIntent(query);
ChatMessage message = new ChatMessage(
text: response.getMessage() ??
new CardDialogflow(response.getListMessage()[0]).title,
name: "Bot",
type: false,
);
setState(() {
_messages.insert(0, message);
});
}
void _handleSubmitted(String text) {
_textController.clear();
ChatMessage message = new ChatMessage(
text: text,
name: "Response Bot",
type: true,
);
setState(() {
_messages.insert(0, message);
});
response(text);
}
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Column(children: <Widget>[
CustomAppBar(),
new Flexible(
child: new ListView.builder(
padding: new EdgeInsets.all(8.0),
reverse: true,
itemBuilder: (_, int index) => _messages[index],
itemCount: _messages.length,
)),
new Divider(height: 1.0),
new Container(
decoration: new BoxDecoration(color: Theme.of(context).cardColor),
child: _buildTextComposer(),
),
]),
);
}
}
class ChatMessage extends StatelessWidget {
ChatMessage({this.text, this.name, this.type});
final String text;
final String name;
final bool type;
List<Widget> otherMessage(context) {
return <Widget>[
new Container(
margin: const EdgeInsets.only(right: 16.0),
child: new CircleAvatar(child: new Text('B')),
),
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(this.name,
style: new TextStyle(fontWeight: FontWeight.bold)),
new Container(
margin: const EdgeInsets.only(top: 5.0),
child: new Text(text),
),
],
),
),
];
}
List<Widget> myMessage(context) {
return <Widget>[
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
new Text(this.name, style: Theme.of(context).textTheme.subtitle1),
new Container(
margin: const EdgeInsets.only(top: 5.0),
child: new Text(text),
),
],
),
),
new Container(
margin: const EdgeInsets.only(left: 16.0),
child: new CircleAvatar(
child: new Text(
this.name[0],
style: new TextStyle(fontWeight: FontWeight.bold),
)),
),
];
}
@override
Widget build(BuildContext context) {
return new Container(
margin: const EdgeInsets.symmetric(vertical: 10.0),
child: new Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: this.type ? myMessage(context) : otherMessage(context),
),
);
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/views/NewsBody.dart | import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:response/utilities/LocationService.dart';
import 'package:response/utilities/constants.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:intl/intl.dart';
import 'package:response/widgets/CustomAppBar.dart';
import 'package:response/widgets/CustomNewsTile.dart';
class NewsBody extends StatefulWidget {
static const String id = '/NewsBody';
//static string disasterType = 'Disaster';
@override
_NewsBodyState createState() => _NewsBodyState();
}
class _NewsBodyState extends State<NewsBody> {
String _isClicked = 'national';
LocationService locationService = LocationService();
var userLocation = "MUMBAI";
//New firestore instance
final _firestore = Firestore.instance;
List<CustomNewsTile> nationalNewsWidgets = [];
List<CustomNewsTile> localNewsWidgets = [];
@override
void initState() {
getLocationData();
super.initState();
}
//Needs to be future!
Future getLocationData() async {
// Fetching _userLocation
userLocation = await locationService.getLocation();
setState(() {});
}
@override
Widget build(BuildContext context) {
ScreenUtil.init(
context,
width: 375.0,
height: 667.0,
allowFontScaling: true,
);
return Column(
children: [
CustomAppBar(),
Padding(
padding: EdgeInsets.only(left: 20.0.w, top: 10.0.h, bottom: 10.0.h),
child: Row(
children: [
GestureDetector(
onTap: () {
setState(() {
_isClicked = 'national';
});
},
child: Text('National News',
style: _isClicked == 'national'
? kActiveTitleNewsPageTextStyle
: kInactiveTitleNewsPageTextStyle),
),
SizedBox(width: 20.0.w),
GestureDetector(
onTap: () {
setState(() {
_isClicked = 'local';
});
},
child: Text('Local News',
style: _isClicked == 'local'
? kActiveTitleNewsPageTextStyle
: kInactiveTitleNewsPageTextStyle),
),
],
),
),
_isClicked == 'national'
? StreamBuilder<QuerySnapshot>(
stream: _firestore.collection('RealNews').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Center(
child: CircularProgressIndicator(
backgroundColor: Colors.blueAccent),
);
}
final realNews = snapshot.data.documents;
for (var news in realNews) {
final String location = (news.data['location'] == null
? 'India'
: news.data['location']);
//date conversion
DateTime myDateTime =
DateTime.parse(news.data['date'].toDate().toString());
final String date =
DateFormat('d LLLL, y').format(myDateTime);
final String description = news.data['description'];
final String distype = news.data['distype'];
//widget.disasterType = distype;
final String headline = news.data['headline'];
final String imageurl = news.data['imageurl'];
final String url = news.data['url'];
nationalNewsWidgets.add(CustomNewsTile(
date: date == null ? '' : date,
description: description.isEmpty
? 'Take action if you know an earthquake is going to hit before strikes. Secure items that might fall and cause injuries (e.g, bookshelves, mirrors, light fixtures). Practice how to Drop, Cover, and Hold On. Store critical supplies and documents. Plan how you will communicate with family members. Refer to the news link below to find out more. Be healthy, be safe!'
: description,
distype: distype == null
? 'Disaster'
: distype[0].toUpperCase() +
distype.substring(1).toLowerCase(),
headline: headline.isEmpty
? 'Disaster occurred : Refer news for further details.'
: headline,
imageurl: imageurl == null
? 'https://images.pexels.com/photos/70573/fireman-firefighter-rubble-9-11-70573.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940'
: imageurl,
location: location == null ? 'India' : location,
url: url == null
? 'https://immohann.github.io/Crisis-Management/index.html'
: url,
));
}
return Expanded(
child: ListView.builder(
padding: EdgeInsets.only(
bottom: 70.0.w, top: 0.0, right: 0.0, left: 0.0),
shrinkWrap: true,
scrollDirection: Axis.vertical,
physics: AlwaysScrollableScrollPhysics(),
itemCount: nationalNewsWidgets.length,
itemBuilder: (context, i) {
return nationalNewsWidgets[i];
}),
);
},
)
: StreamBuilder<QuerySnapshot>(
stream: _firestore.collection('RealNews').snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Center(
child: CircularProgressIndicator(
backgroundColor: Colors.blueAccent),
);
}
final realNews = snapshot.data.documents;
for (var news in realNews) {
final String location = (news.data['location'] == null
? 'India'
: news.data['location']);
String newsLocation = location.toUpperCase();
if (!userLocation.contains(newsLocation)) {
//date conversion
DateTime myDateTime =
DateTime.parse(news.data['date'].toDate().toString());
final String date =
DateFormat('d LLLL, y').format(myDateTime);
final String description = news.data['description'];
final String distype = news.data['distype'];
final String headline = news.data['headline'];
final String imageurl = news.data['imageurl'];
final String url = news.data['url'];
localNewsWidgets.add(CustomNewsTile(
date: date == null ? '' : date,
description: description.isEmpty
? 'Take action if you know an earthquake is going to hit before strikes. Secure items that might fall and cause injuries (e.g, bookshelves, mirrors, light fixtures). Practice how to Drop, Cover, and Hold On. Store critical supplies and documents. Plan how you will communicate with family members. Refer to the news link below to find out more. Be healthy, be safe!'
: description,
distype: distype == null
? 'Disaster'
: distype[0].toUpperCase() +
distype.substring(1).toLowerCase(),
headline: headline.isEmpty
? 'Disaster occurred : Refer news for further details.'
: headline,
imageurl: imageurl == null
? 'https://images.pexels.com/photos/70573/fireman-firefighter-rubble-9-11-70573.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940'
: imageurl,
location: location == null ? 'India' : location,
url: url == null
? 'https://immohann.github.io/Crisis-Management/index.html'
: url,
));
}
}
return Expanded(
child: ListView.builder(
padding: EdgeInsets.only(
bottom: 70.0.w, top: 0.0, right: 0.0, left: 0.0),
shrinkWrap: true,
scrollDirection: Axis.vertical,
physics: AlwaysScrollableScrollPhysics(),
itemCount: localNewsWidgets.length,
itemBuilder: (context, i) {
return localNewsWidgets[i];
}),
);
},
),
],
);
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/views/WhatToDoBody.dart | import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:response/utilities/constants.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:response/widgets/CustomAppBar.dart';
import 'package:response/widgets/CustomPrecautionListTile.dart';
class WhatToDoBody extends StatefulWidget {
static const String id = '/WhatToDoBody';
@override
_WhatToDoBodyState createState() => _WhatToDoBodyState();
}
class _WhatToDoBodyState extends State<WhatToDoBody>
with SingleTickerProviderStateMixin {
AnimationController _animationController;
void initState() {
super.initState();
_animationController =
AnimationController(vsync: this, duration: Duration(seconds: 1));
_animationController.repeat(reverse: true);
}
@override
void dispose() {
_animationController.dispose();
super.dispose();
}
List<CustomPrecautionListTile> _buildList() {
List<CustomPrecautionListTile> _list = [];
List<String> disasters = [
'Earthquake',
'Flood',
'Storm',
'Pandemic',
'Wildfire',
'Violence'
];
for (int index = 0; index < disasters.length; index++) {
var item = CustomPrecautionListTile(
disaster: disasters[index],
);
_list.add(item);
}
return _list;
}
@override
Widget build(BuildContext context) {
var _width = MediaQuery.of(context).size.width;
ScreenUtil.init(
context,
width: 375.0,
height: 667.0,
allowFontScaling: true,
);
return Column(
children: [
CustomAppBar(),
Container(
width: _width - 40.0.w,
height: 180.0.h,
child: Stack(
children: [
Align(
alignment: Alignment.bottomCenter,
child: Container(
width: _width - 40.0.w,
height: 125.0.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0.w),
border: Border.all(
color: kPrimaryRed,
),
),
),
),
Align(
alignment: Alignment.topCenter,
child: Column(
children: [
Image.asset(
'assets/images/doctorTeam.png',
width: 200.0.w,
height: 130.0.h,
),
Padding(
padding: EdgeInsets.only(
top: 8.0.h, bottom: 5.0.h, left: 8.0.w, right: 8.0.w),
child: Text('Tips & Precautions from top doctors!',
textAlign: TextAlign.center,
style: kWhatToDoPageTextStyle),
),
],
),
),
],
),
),
FadeTransition(
opacity:
_animationController.drive(CurveTween(curve: Curves.easeOut)),
child: Container(
margin: EdgeInsets.only(top: 10.0.h, bottom: 10.0.h),
padding: EdgeInsets.symmetric(vertical: 5.0.h, horizontal: 40.0.w),
decoration: BoxDecoration(
color: Color(0xffe8f4fa),
borderRadius: BorderRadius.all(Radius.circular(15.0.w)),
),
child: Text(
'Emergency Drill',
style: TextStyle(
fontSize: ScreenUtil().setSp(17.5),
fontFamily: 'WorkSans',
color: Colors.black,
),
),
),
),
Expanded(
child: ListView(
padding: EdgeInsets.only(
bottom: 70.0.w, top: 0.0, right: 0.0, left: 0.0),
scrollDirection: Axis.vertical,
physics: AlwaysScrollableScrollPhysics(),
children: _buildList(),
),
),
],
);
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/views/Flood.dart | import 'package:flutter/material.dart';
class Flood extends StatelessWidget {
static const String id = '/Flood';
@override
Widget build(BuildContext context) {
return Scaffold();
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/views/SOS.dart | import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:response/utilities/constants.dart';
import 'SOSselect.dart';
class SOS extends StatefulWidget {
static const String id = '/SOS';
@override
_SOSState createState() => _SOSState();
}
class _SOSState extends State<SOS> with SingleTickerProviderStateMixin {
AnimationController _animationController;
Animation _animation;
void initState() {
super.initState();
_animationController =
AnimationController(vsync: this, duration: Duration(seconds: 1));
_animationController.repeat(reverse: true);
_animation = Tween(begin: 2.0, end: 15.0).animate(_animationController)
..addListener(() {
setState(() {});
});
}
@override
void dispose() {
_animationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
var _width = MediaQuery.of(context).size.width;
ScreenUtil.init(
context,
width: 375.0,
height: 667.0,
allowFontScaling: true,
);
// ScreenUtil().setWidth()
// ScreenUtil().setHeight()
return Scaffold(
body: Column(
children: [
SafeArea(
top: true,
bottom: false,
left: false,
right: false,
child: Padding(
padding: EdgeInsets.only(
top: ScreenUtil().setHeight(10),
left: ScreenUtil().setWidth(10),
right: ScreenUtil().setWidth(10),
bottom: ScreenUtil().setHeight(5)),
child: Row(
children: [
IconButton(
icon: Icon(Icons.arrow_back_ios,
size: ScreenUtil().setWidth(20.0), color: Colors.black),
onPressed: () {
Navigator.pop(context);
},
),
Container(
margin: EdgeInsets.only(
left: ScreenUtil().setWidth(52),
bottom: ScreenUtil().setHeight(10.0)),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(20),
vertical: ScreenUtil().setHeight(10)),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(20)),
border: Border.all(
color: Colors.black12,
),
),
child: Text(
'Safety Services',
style: TextStyle(
fontSize: ScreenUtil().setSp(20.0),
color: Colors.black,
fontWeight: FontWeight.w300,
fontFamily: 'Anton-Regular',
),
),
),
],
),
),
),
Material(
elevation: 5.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(20))),
child: Container(
width: _width - ScreenUtil().setWidth(40),
height: ScreenUtil().setHeight(215),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(20)),
border: Border.all(
color: Colors.black12,
),
),
child: Column(
children: [
GestureDetector(
onTap: () {
Navigator.pushNamed(context, SOSselect.id);
},
child: Container(
width: ScreenUtil().setWidth(200),
height: ScreenUtil().setHeight(130),
margin: EdgeInsets.only(top: 20.0, bottom: 15.0),
child: Image.asset('assets/images/alert_icon.png'),
decoration: BoxDecoration(
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Color(0xffFCEDEE),
blurRadius: _animation.value * 4.5,
spreadRadius: _animation.value * 1.5,
)
],
),
),
),
Padding(
padding: EdgeInsets.only(
top: ScreenUtil().setHeight(8),
bottom: ScreenUtil().setHeight(5),
left: ScreenUtil().setWidth(8.0),
right: ScreenUtil().setWidth(8.0)),
child: Text('Tap in case of an emergency',
textAlign: TextAlign.center,
style: kWhatToDoPageTextStyle.copyWith(
color: Colors.black38)),
),
],
),
),
),
SizedBox(height: ScreenUtil().setHeight(25.0)),
Expanded(
child: Container(
margin: EdgeInsets.all(ScreenUtil().setWidth(20)),
width: _width - ScreenUtil().setWidth(40),
height: ScreenUtil().setHeight(230),
padding: EdgeInsets.all(ScreenUtil().setWidth(20)),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(20)),
border: Border.all(
color: Colors.black12,
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Choose 5 Emergency Contacts',
style: TextStyle(
fontSize: ScreenUtil().setSp(19.0),
fontFamily: 'WorkSans',
fontWeight: FontWeight.bold,
color: Colors.black,
)),
GestureDetector(
onTap: () {
// getContacts();
},
child: Align(
alignment: Alignment.topCenter,
child: Container(
margin: EdgeInsets.symmetric(
vertical: ScreenUtil().setHeight(10.0)),
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(30),
vertical: ScreenUtil().setHeight(10)),
decoration: BoxDecoration(
color: Colors.blue.withOpacity(0.08),
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(20)),
border: Border.all(
color: Colors.blue,
),
),
child: Text(
'Choose Contacts',
style: kCustomNewsTileDisasterTextStyle.copyWith(
fontSize: ScreenUtil().setSp(15.0),
color: Colors.blue),
),
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
'0',
style: TextStyle(
fontSize: ScreenUtil().setSp(50),
color: Colors.black38,
fontFamily: 'WorkSans',
),
),
SizedBox(width: ScreenUtil().setWidth(15.0)),
Image.asset('assets/images/phone2.png',
width: ScreenUtil().setWidth(35.0),
height: ScreenUtil().setHeight(35.0))
],
),
Text('Contacts Added',
style: TextStyle(
fontSize: ScreenUtil().setSp(13.5),
color: Colors.black38,
fontFamily: 'WorkSans',
)),
],
),
],
),
),
),
],
),
);
}
// Iterable<Contact> _contacts;
//
// getContacts() async {
// PermissionStatus permissionStatus = await _getPermission();
// PermissionStatus permissionStatus = PermissionStatus.granted;
//
// if (permissionStatus == PermissionStatus.granted) {
// var contacts = await ContactsService.getContacts();
// setState(() {
// _contacts = contacts;
// });
// } else {
// throw PlatformException(
// code: 'PERMISSION_DENIED',
// message: 'Access to location data denied',
// details: null,
// );
// }
// }
//
// Future<PermissionStatus> _getPermission() async {
// PermissionStatus permission = await PermissionHandler()
// .checkPermissionStatus(PermissionGroup.contacts);
// if (permission != PermissionStatus.granted &&
// permission != PermissionStatus.disabled) {
// Map<PermissionGroup, PermissionStatus> permisionStatus =
// await PermissionHandler()
// .requestPermissions([PermissionGroup.contacts]);
// return permisionStatus[PermissionGroup.contacts] ??
// PermissionStatus.unknown;
// } else {
// return permission;
// }
//}
//_contacts != null
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/views/HomePage.dart | import 'package:flutter/material.dart';
import 'package:response/custom_icons/drawer_icon_icons.dart';
import 'package:response/custom_icons/idea_icons.dart';
import 'package:response/custom_icons/maps_icons.dart';
import 'package:response/custom_icons/news_icons.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:response/custom_icons/share_icons.dart';
import 'package:response/models/MenuItem.dart';
import 'package:response/utilities/constants.dart';
import 'package:response/widgets/SubscriptionBottomModalSheet.dart';
import 'package:share/share.dart' as ShareFunction;
import 'package:url_launcher/url_launcher.dart';
import 'HomePageDialogflow.dart';
import 'MapsBody.dart';
import 'NewsBody.dart';
import 'WhatToDoBody.dart';
class HomePage extends StatefulWidget {
static const String id = '/HomePage';
@override
State<StatefulWidget> createState() {
return _HomePageState();
}
}
final snackBar = SnackBar(
content: Text(
'Unable to access link, check your network connection.',
style: TextStyle(fontFamily: 'WorkSans'),
),
action: SnackBarAction(
label: 'RETRY',
textColor: Color(0xff9B72CD),
onPressed: () {},
),
);
class _HomePageState extends State<HomePage> {
List<Widget> _widgetList = [
WhatToDoBody(),
NewsBody(),
MapsBody(),
HomePageDialogflow(),
];
int _index = 1;
@override
Widget build(BuildContext context) {
ScreenUtil.init(
context,
width: 375.0,
height: 667.0,
allowFontScaling: true,
);
final List<MenuItem> options1 = [
MenuItem(DrawerIcon.home_run, 'Home', () => Navigator.pop(context)),
MenuItem(
Icons.notifications_active,
'Subscribe for Alerts',
() {
Navigator.pop(context);
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) {
return Wrap(
children: [
SubscriptionBottomModalSheet(),
],
);
});
},
),
];
final List<MenuItem> options2 = [
MenuItem(DrawerIcon.question_mark, 'How to use?', () {
//TODO: Bug here
// Navigator.pushNamed(context, OnboardingScreen.id);
}),
MenuItem(
Share.icons8_share,
'Tell a friend',
() => ShareFunction.Share.share(
"Response is a A Cross Platform Mobile Application for disaster management. Be safe, be alert and always be ready with Response!",
subject: 'Download Response App')),
MenuItem(DrawerIcon.speak, 'Feedback', () async {
String url = 'https://forms.gle/KbumM4K9bx8a3FT29';
try {
await launch(url);
print('y');
} catch (e) {
print('n');
print('$e : Could not launch $url on Homepage');
Scaffold.of(context).showSnackBar(snackBar); //check
}
}),
MenuItem(Icons.phone, 'Contact Us', () async {
String url = 'https://immohann.github.io/Crisis-Management/';
try {
await launch(url);
print('y');
} catch (e) {
print('n');
print('$e : Could not launch $url on Homepage');
Scaffold.of(context).showSnackBar(snackBar); //check
}
}),
MenuItem(DrawerIcon.terms_and_conditions, 'Terms & Conditions', () {}),
];
return Scaffold(
extendBody: true,
resizeToAvoidBottomPadding: false,
backgroundColor: Colors.white,
drawer: Drawer(
child: Stack(
children: [
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/drawer.jpg'),
fit: BoxFit.cover,
),
),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomRight,
stops: [0.5, 1],
colors: [
Colors.black.withOpacity(.9),
Colors.black.withOpacity(.2)
],
),
),
),
),
Container(
padding: EdgeInsets.only(
top: 50.h, bottom: 50.h, left: 20.w, right: 20.0.w),
// color: Color(0xff061254),
// color: Color(0xff3691CD), too blue
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Image.asset('assets/images/logo.png',
width: 150.0.w, height: 100.0.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
children: options1.map((item) {
return GestureDetector(
onTap: item.onPressed,
child: ListTile(
leading: Icon(
item.icon,
color: Colors.white,
size: 30.w,
),
title:
Text(item.title, style: kDrawerItemTextStyle),
),
);
}).toList(),
),
SizedBox(height: 10.h),
Divider(color: Colors.white54),
Text(
'About',
style: TextStyle(
fontSize: ScreenUtil().setSp(12.0),
fontWeight: FontWeight.bold,
color: Colors.white70),
),
Column(
children: options2.map((item) {
return GestureDetector(
onTap: item.onPressed,
child: ListTile(
leading: Icon(
item.icon,
color: Colors.white,
size: 25.w,
),
title: Text(
item.title,
style: kDrawerItemTextStyle,
),
),
);
}).toList(),
),
SizedBox(height: 20.h),
Center(
child: Text(
'Version 1.0.0',
style: TextStyle(
fontSize: ScreenUtil().setSp(12.0),
color: Colors.white54),
),
),
],
),
],
),
),
],
),
),
body: _widgetList[_index],
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: _index,
backgroundColor: Colors.black87,
selectedItemColor: Colors.white,
unselectedItemColor: Colors.white54,
iconSize: 20.0.w,
onTap: (int index) {
setState(() {
_index = index;
});
},
items: [
BottomNavigationBarItem(
icon: Icon(Idea.icons8_idea),
label: 'What to do?',
),
BottomNavigationBarItem(icon: Icon(News.icons8_news), label: 'News'),
BottomNavigationBarItem(icon: Icon(Maps.location), label: 'Map'),
BottomNavigationBarItem(
icon: Icon(DrawerIcon.speak), label: 'ChatBot'),
],
),
);
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/views/MapsBody.dart | import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:flutter/widgets.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:response/custom_icons/emergency_icons.dart';
import 'package:response/utilities/LocationService.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:response/utilities/constants.dart';
import 'SOS.dart';
class MapsBody extends StatefulWidget {
static const String id = '/MapsBody';
@override
_MapsBodyState createState() => _MapsBodyState();
}
class _MapsBodyState extends State<MapsBody> {
LocationService locationService = LocationService();
double _latitude = 19.095212;
double _longitude = 72.863363;
void getLocationData() async {
_latitude = await locationService.getLat();
_longitude = await locationService.getLong();
}
//map code:
Completer<GoogleMapController> _controller = Completer();
static const LatLng _center = const LatLng(45.521563, -122.677433);
final Set<Marker> _markers = {};
LatLng _lastMapPosition = _center;
MapType _currentMapType = MapType.normal;
void _onMapTypeButtonPressed() {
setState(() {
_currentMapType = _currentMapType == MapType.normal
? MapType.satellite
: MapType.normal;
});
}
void _onAddMarkerButtonPressed() {
setState(() {
_markers.add(Marker(
// This marker id can be anything that uniquely identifies each marker.
markerId: MarkerId(_lastMapPosition.toString()),
position: _lastMapPosition,
infoWindow: InfoWindow(
title: 'Your Current Location',
snippet: "Mumbai",
),
icon: BitmapDescriptor.defaultMarker,
));
});
}
void _onCameraMove(CameraPosition position) {
_lastMapPosition = position.target;
}
void _onMapCreated(GoogleMapController controller) {
_controller.complete(controller);
}
@override
void initState() {
getLocationData();
super.initState();
}
@override
Widget build(BuildContext context) {
ScreenUtil.init(
context,
width: 375.0,
height: 667.0,
allowFontScaling: true,
);
return Scaffold(
body: Stack(
children: [
SafeArea(
top: false,
bottom: true,
left: false,
right: false,
child: GoogleMap(
onMapCreated: _onMapCreated,
initialCameraPosition: CameraPosition(
target: LatLng(_latitude, _longitude), //_center
zoom: 12.0,
),
mapType: _currentMapType,
markers: _markers,
onCameraMove: _onCameraMove,
),
),
SafeArea(
top: true,
bottom: false,
left: false,
right: false,
child: Column(
children: [
Padding(
padding: EdgeInsets.symmetric(
horizontal: 10.0.w, vertical: 10.0.h),
child: Material(
elevation: 5.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0.w)),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20.0.w),
border: Border.all(
color: Colors.white,
),
),
padding: EdgeInsets.symmetric(horizontal: 20.0.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: Icon(Icons.menu,
size: 20.0.w, color: Colors.black),
onPressed: () {
Scaffold.of(context).openDrawer();
}),
Text(
'RESPONSE ',
style: kCustomAppBarResponseLogoTextStyle,
),
IconButton(
icon: Icon(Emergency.warning,
size: 20.0.w, color: Colors.black),
onPressed: () {
Navigator.pushNamed(context, SOS.id);
}),
],
)),
),
),
Padding(
padding: const EdgeInsets.all(16.0),
child: Align(
alignment: Alignment.topRight,
child: Column(
children: <Widget>[
FloatingActionButton(
backgroundColor: Colors.white,
splashColor: Colors.blue,
elevation: 5.0,
tooltip: 'Increment',
child:
Icon(Icons.map, color: Colors.black, size: 36.0),
onPressed: _onMapTypeButtonPressed,
),
SizedBox(height: 16.0),
FloatingActionButton(
onPressed: _onAddMarkerButtonPressed,
materialTapTargetSize: MaterialTapTargetSize.padded,
backgroundColor: Colors.lightGreen,
child: const Icon(Icons.add_location, size: 36.0),
),
],
),
),
),
],
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/views/DetailedNewsPage.dart | import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:response/custom_icons/arrow_front_icons.dart';
import 'package:response/custom_icons/heart_icon_icons.dart';
import 'package:response/custom_icons/share_icons.dart';
import 'package:response/utilities/constants.dart';
import 'package:drop_cap_text/drop_cap_text.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:share/share.dart' as ShareFunction;
import 'package:flutter_screenutil/flutter_screenutil.dart';
class DetailedNewsPage extends StatefulWidget {
static const String id = '/DetailedNewsPage';
final String date;
final String description;
final String distype;
final String headline;
final String imageurl;
final String location;
final String url;
DetailedNewsPage(
{this.distype,
this.imageurl,
this.headline,
this.date,
this.location,
this.description,
this.url});
@override
_DetailedNewsPageState createState() => _DetailedNewsPageState();
}
final snackBar = SnackBar(
content: Text(
'Unable to access link, check your network connection.',
style: TextStyle(fontFamily: 'WorkSans'),
),
action: SnackBarAction(
label: 'RETRY',
textColor: Color(0xff9B72CD),
onPressed: () {},
),
);
class _DetailedNewsPageState extends State<DetailedNewsPage>
with SingleTickerProviderStateMixin {
AnimationController _animationController;
NetworkImage _buildImage() {
try {
return NetworkImage(widget.imageurl);
} catch (e) {
return NetworkImage(
'https://images.pexels.com/photos/70573/fireman-firefighter-rubble-9-11-70573.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940');
}
}
void initState() {
super.initState();
_animationController =
AnimationController(vsync: this, duration: Duration(seconds: 1));
_animationController.repeat(reverse: true);
}
@override
void dispose() {
_animationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
ScreenUtil.init(
context,
width: 375.0,
height: 667.0,
allowFontScaling: true,
);
var _width = MediaQuery.of(context).size.width;
return Scaffold(
body: Builder(builder: (BuildContext context) {
return SafeArea(
top: true,
bottom: false,
left: false,
right: false,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Padding(
padding: EdgeInsets.only(
top: 10.0.h, left: 10.0.w, right: 10.0.w, bottom: 5.0.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
FloatingActionButton(
heroTag: null,
onPressed: () {
Navigator.pop(context);
},
child: Icon(Icons.arrow_back_ios_outlined,
color: Colors.black, size: 15.0.w),
backgroundColor: Colors.white,
elevation: 5.0,
mini: true,
),
Container(
padding: EdgeInsets.symmetric(
horizontal: 20.0.w, vertical: 10.0.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0.w),
border: Border.all(
color: Colors.black12,
),
),
child: Text(
widget.distype,
style: kCustomNewsTileDisasterTextStyle.copyWith(
fontSize: ScreenUtil().setSp(15.0)),
),
),
FloatingActionButton(
heroTag: null,
onPressed: () {
ShareFunction.Share.share(
"${widget.distype} Alert⚠️️ ${widget.headline}❗Visit the news link: ${widget.url} Do a good thing today😇 Donate to ${widget.distype} Relief funds: https://pmnrf.gov.in/en/online-donation", //TODO: Put link
subject: 'News shared from Response App');
},
child: Icon(Share.icons8_share,
color: Colors.black, size: 15.0.w),
backgroundColor: Colors.white,
elevation: 5.0,
mini: true,
),
],
),
),
Expanded(
child: ListView(
padding: EdgeInsets.all(0.0),
scrollDirection: Axis.vertical,
physics: AlwaysScrollableScrollPhysics(),
children: [
Padding(
padding: EdgeInsets.symmetric(
vertical: 10.0.h, horizontal: 25.0.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
widget.headline,
style: TextStyle(
fontSize: ScreenUtil().setSp(22.0),
color: Colors.black,
fontFamily: 'PlayfairDisplay-Bold',
),
),
Padding(
padding: EdgeInsets.symmetric(vertical: 15.0.h),
child: Material(
elevation: 5.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0.w)),
child: Container(
height: 200.0.h,
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(20.0.w)),
image: DecorationImage(
fit: BoxFit.cover, image: _buildImage()),
),
child: Container(
padding: EdgeInsets.only(
left: 10.0.w, bottom: 10.0.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(20.0.w)),
gradient: LinearGradient(
begin: Alignment.bottomRight,
stops: [0.1, 0.9],
colors: [
Colors.black.withOpacity(.8),
Colors.black.withOpacity(.1)
],
),
),
alignment: Alignment.bottomLeft,
child: Visibility(
visible:
true, //TODO: Visible if the news is live
child: FadeTransition(
opacity: _animationController.drive(
CurveTween(curve: Curves.easeOut)),
child: Container(
padding: EdgeInsets.symmetric(
vertical: 2.0.h,
horizontal: 10.0.w),
decoration: BoxDecoration(
color: Color(0xff92F0AD),
borderRadius: BorderRadius.all(
Radius.circular(10.0.w)),
),
child: Text(
'LIVE',
style: TextStyle(
fontSize: ScreenUtil().setSp(12.0),
fontFamily: 'FredokaOne',
fontWeight: FontWeight.w500,
color: Color(0xff132418),
),
),
),
),
),
),
),
),
),
Text(
' Yesterday, 9:24 PM • ${widget.location}', //todo date
style: kCustomNewsTileDateTimeTextStyle,
),
],
),
),
Padding(
padding: EdgeInsets.only(
top: 18.0.h, left: 25.0.w, bottom: 40.0.h),
child: Material(
elevation: 3.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(5.0.w),
bottomLeft: Radius.circular(5.0.w),
),
),
child: GestureDetector(
onTap: () async {
try {
await launch(
'https://immohann.github.io/Crisis-Management/${widget.distype}.html');
} catch (e) {
print(
'$e : Could not launch ${widget.url} on DetailedNewsPage');
Scaffold.of(context).showSnackBar(snackBar);
}
},
child: Container(
height: 30.0.h,
width: _width,
padding: EdgeInsets.only(
left: 20.0.w, top: 5.0.h, bottom: 5.0.h),
decoration: BoxDecoration(
color: Color(0xffF3963E),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(5.0.w),
bottomLeft: Radius.circular(5.0.w),
),
),
child: Row(
children: [
Text(
'Refer ${widget.distype} Precautions ',
style: TextStyle(
fontSize: ScreenUtil().setSp(15.0),
color: Colors.white54,
fontFamily: 'Merriweather',
),
),
Icon(ArrowFront.right_outline,
color: Colors.white54, size: 13.0.w),
],
),
),
),
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 25.0.w),
child: Column(
children: [
DropCapText(
widget.description,
mode: DropCapMode.inside,
dropCapPadding: EdgeInsets.only(right: 5.0.w),
dropCapStyle: kCustomNewsTileDropCapTextStyle,
style: kCustomNewsTileDropCapBodyTextStyle,
),
SizedBox(height: 30.0.h),
Text(
'Do a good thing today!',
textAlign: TextAlign.center,
style: kCustomNewsTileDisasterTextStyle.copyWith(
fontSize: ScreenUtil().setSp(15.0)),
),
Text(
'Donate to ${widget.distype} Relief Funds',
textAlign: TextAlign.center,
style: kCustomNewsTileDisasterTextStyle.copyWith(
fontSize: ScreenUtil().setSp(15.0)),
),
GestureDetector(
onTap: () async {
String donationLink =
'https://pmnrf.gov.in/en/online-donation';
try {
await launch(donationLink);
} catch (e) {
print(
'$e : Could not launch $donationLink on DetailedNewsPage');
Scaffold.of(context).showSnackBar(snackBar);
}
},
child: Container(
margin: EdgeInsets.only(top: 20.0.w),
padding: EdgeInsets.symmetric(
horizontal: 20.0.w, vertical: 10.0.h),
decoration: BoxDecoration(
color: Colors.pinkAccent.withOpacity(0.08),
borderRadius: BorderRadius.circular(20.0.w),
border: Border.all(
color: Colors.pinkAccent,
),
),
child: Wrap(
spacing: 15.0.w,
alignment: WrapAlignment.center,
children: [
Icon(HeartIcon.heart,
color: Colors.pinkAccent, size: 20.0.w),
Text(
'Donate',
style: kCustomNewsTileDisasterTextStyle
.copyWith(
fontSize: ScreenUtil().setSp(15.0),
color: Colors.pinkAccent),
),
],
),
),
),
GestureDetector(
onTap: () async {
try {
await launch(widget.url);
} catch (e) {
print(
'$e : Could not launch ${widget.url} on DetailedNewsPage');
Scaffold.of(context).showSnackBar(snackBar);
}
},
child: Container(
margin: EdgeInsets.symmetric(vertical: 30.0.h),
padding: EdgeInsets.symmetric(
horizontal: 20.0.w, vertical: 10.0.h),
decoration: BoxDecoration(
color: Colors.blue.withOpacity(0.08),
borderRadius: BorderRadius.circular(20.0.w),
border: Border.all(
color: Colors.blue,
),
),
child: Text(
'Click here to visit the news link',
style:
kCustomNewsTileDisasterTextStyle.copyWith(
fontSize: ScreenUtil().setSp(15.0),
color: Colors.blue),
),
),
),
],
),
),
],
),
),
],
),
);
}),
);
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/views/SOSselect.dart | import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:response/widgets/CustomSOSTile.dart';
class SOSselect extends StatelessWidget {
static const String id = '/SOSselect';
List<CustomSOSTile> _buildList() {
List<CustomSOSTile> _list = [];
List<String> disasters = [
'Earthquake',
'Flood',
'Storm',
'Pandemic',
'Wildfire',
'Violence'
];
for (int index = 0; index < disasters.length; index++) {
var item = CustomSOSTile(
disaster: disasters[index],
);
_list.add(item);
}
return _list;
}
@override
Widget build(BuildContext context) {
ScreenUtil.init(
context,
width: 375.0,
height: 667.0,
allowFontScaling: true,
);
return Scaffold(
body: Padding(
padding: EdgeInsets.symmetric(
vertical: ScreenUtil().setWidth(20.0),
horizontal: ScreenUtil().setHeight(20.0)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Padding(
padding: EdgeInsets.only(bottom: ScreenUtil().setHeight(5)),
child: IconButton(
icon: Icon(Icons.arrow_back_ios,
size: ScreenUtil().setWidth(20.0), color: Colors.black),
onPressed: () {
Navigator.pop(context);
},
),
),
Text(
'Choose Disaster',
style: TextStyle(
fontSize: ScreenUtil().setSp(20.0),
color: Colors.black,
fontWeight: FontWeight.bold,
fontFamily: 'WorkSans',
),
),
],
),
SizedBox(height: ScreenUtil().setHeight(15.0)),
Expanded(
child: ListView(
padding: EdgeInsets.only(
bottom: ScreenUtil().setWidth(70.0),
top: 0.0,
right: 0.0,
left: 0.0),
scrollDirection: Axis.vertical,
physics: AlwaysScrollableScrollPhysics(),
children: _buildList(),
),
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/views/OnboardingScreen.dart | import 'package:flutter/material.dart';
import 'package:introduction_screen/introduction_screen.dart';
import 'package:response/models/OnboardingModel.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class OnboardingScreen extends StatefulWidget {
static String id = '/Onboarding2';
@override
_OnboardingScreenState createState() => _OnboardingScreenState();
}
class _OnboardingScreenState extends State<OnboardingScreen> {
final introKey = GlobalKey<IntroductionScreenState>();
final OnboardingPage onboard = OnboardingPage();
List<PageViewModel> pagesList() {
List<PageViewModel> list = [];
for (int i = 0; i < OnboardingPage.getNumOfPages(); i++) {
list.add(PageViewModel(
title: onboard.getTitle(i),
body: onboard.getInfo(i),
));
}
return list;
}
@override
Widget build(BuildContext context) {
ScreenUtil.init(
context,
width: 375.0,
height: 667.0,
allowFontScaling: true,
);
return Scaffold(
body: Stack(
children: [
IntroductionScreen(
globalBackgroundColor: Colors.transparent,
key: introKey,
pages: pagesList(),
onDone: () => Navigator.pop(context),
showSkipButton: true,
skipFlex: 0,
nextFlex: 0,
skip: Text(
'Skip',
style: TextStyle(
fontFamily: 'Merriweather',
color: Colors.white,
),
),
next: Icon(Icons.arrow_forward, color: Colors.white),
done: Text(
'Done',
style: TextStyle(
fontWeight: FontWeight.w600,
fontFamily: 'Merriweather',
color: Colors.white,
),
),
dotsDecorator: DotsDecorator(
size: Size(10.0.w, 10.0.w),
color: Colors.white24,
activeColor: Colors.white,
activeSize: Size(22.0.w, 10.0.w),
activeShape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(25.0.w)),
),
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/widgets/CustomSOSTile.dart | import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:share/share.dart' as ShareFunction;
class CustomSOSTile extends StatelessWidget {
final String disaster;
CustomSOSTile({@required this.disaster});
@override
Widget build(BuildContext context) {
ScreenUtil.init(
context,
width: 375.0,
height: 667.0,
allowFontScaling: true,
);
// ${NewsBody.disasterType} _sendSMS();
// _sendSMS() async {
// List<String> recipients = [
// "9920238345", //del
// "9869200737", //jay
// '80804 08783', //dwy
// ];
// String _result = await FlutterSms.sendSMS(
// message:
// " Hi, Right now I am in a disaster zone of Earthquake, Please help me, My location is <location>, call an ambulance at my location. The nearest hospital is <hospital name> and contact no of it is <number>. Thank you.",
// recipients: recipients)
// .catchError((onError) {
// print(onError);
// });
// print(_result);
// }
return Padding(
padding: EdgeInsets.only(bottom: 10.0.h, left: 15.0.w, right: 15.0.w),
child: GestureDetector(
onTap: () {
ShareFunction.Share.share(
"Hi Vinit, Right now I am in a Flood disaster zone, Please help me, My location is Jp road, Andheri East, Mumbai. Call an ambulance at my location. The nearest hospital is HolySpirit hospital, Mahakali east and contact no of it is 02228248500 . Thank you.",
subject: 'Message from Response App');
},
child: Material(
elevation: 5.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0.w)),
child: Container(
height: 100.0.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.0.w),
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage('assets/images/$disaster.jpg'),
),
),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.0.w),
gradient: LinearGradient(
begin: Alignment.bottomRight,
stops: [0.1, 0.9],
colors: [
Colors.black.withOpacity(.8),
Colors.black.withOpacity(.1)
],
),
),
padding: EdgeInsets.symmetric(horizontal: 20.0.w),
child: Center(
child: Text(
'$disaster',
style: TextStyle(
fontSize: ScreenUtil().setSp(18.0),
fontFamily: 'WorkSans-Black',
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
),
),
),
),
),
);
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/widgets/SubscriptionBottomModalSheet.dart | import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:response/utilities/constants.dart';
import 'ReusableTextField.dart';
class SubscriptionBottomModalSheet extends StatefulWidget {
@override
_SubscriptionBottomModalSheetState createState() =>
_SubscriptionBottomModalSheetState();
}
class _SubscriptionBottomModalSheetState
extends State<SubscriptionBottomModalSheet> {
@override
Widget build(BuildContext context) {
String email = '';
String phoneNumber = '';
String name = '';
bool _isClicked = false;
final _firestore = Firestore.instance;
// String _validateName(String value) {
// if (value.isEmpty) {
// return 'Please enter a Name ';
// }
// return null;
// }
//
// String _validateEmail(String value) {
// if (value.isEmpty) {
// return 'Please enter an Email Address';
// } else if (!validator.isEmail(email)) {
// return 'Please enter a valid Email';
// }
// return null;
// }
//
// String validatePhoneNum(String value) {
// String pattern = r'(^(?:[+0]9)?[0-9]{10,12}$)';
// RegExp regExp = RegExp(pattern);
//
// if (value.contains('+91', 0)) {
// return null;
// } else {
// if (value.isEmpty) {
// return 'Please enter a phone number';
// } else if (!regExp.hasMatch(value)) {
// return 'Please enter a valid phone number';
// }
// }
//
// return null;
// }
ScreenUtil.init(
context,
width: 375.0,
height: 667.0,
allowFontScaling: true,
);
return Container(
padding: EdgeInsets.all(25.0.w),
margin: EdgeInsets.symmetric(horizontal: 10.0.w, vertical: 20.0.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(45.0.w),
topRight: Radius.circular(45.0.w),
bottomRight: Radius.circular(45.0.w),
),
),
child: Material(
elevation: 3.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(45.0.w),
topRight: Radius.circular(45.0.w),
bottomRight: Radius.circular(45.0.w),
),
),
child: Container(
padding: EdgeInsets.all(30.0.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(45.0.w),
topRight: Radius.circular(45.0.w),
bottomRight: Radius.circular(45.0.w),
),
border: Border.all(
color: Colors.black12,
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
_isClicked ? 'DONE' : 'Subscribe',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: ScreenUtil().setSp(30.0),
color: Colors.black87,
fontWeight: FontWeight.bold,
fontFamily: 'Merriweather',
),
),
SizedBox(height: 20.0.h),
Text('Fill in your details to subscribe to SMS and Email Alerts',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: ScreenUtil().setSp(15.0),
color: Colors.black87,
fontWeight: FontWeight.bold,
fontFamily: 'Merriweather',
)),
SizedBox(height: 20.0.h),
ReusableTextField(
hintText: 'Name',
icon: Icons.face,
keyboardType: TextInputType.name,
errorText: _isClicked
? (name.isEmpty ? 'Please input your name' : null)
: null,
onChanged: (value) {
name = value;
},
),
SizedBox(height: 20.0.h),
ReusableTextField(
hintText: 'Email',
icon: Icons.email,
keyboardType: TextInputType.emailAddress,
errorText: _isClicked
? (email.isEmpty ? 'Please input your email' : null)
: null,
onChanged: (value) {
email = value.trim();
},
),
SizedBox(height: 20.0.h),
ReusableTextField(
hintText: 'Phone no.',
keyboardType: TextInputType.number,
icon: Icons.phone,
errorText: _isClicked
? (phoneNumber.isEmpty ? 'Please input your name' : null)
: null,
onChanged: (value) {
phoneNumber = value.trim();
},
),
SizedBox(height: 30.0.h),
Wrap(
direction: Axis.horizontal,
alignment: WrapAlignment.center,
spacing: 15.0.w,
children: [
GestureDetector(
onTap: () {
setState(() {});
},
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 30.0.w, vertical: 10.0.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0.w),
border: Border.all(
color: Colors.black54,
),
),
child: Text(
'Clear',
style: kCustomNewsTileDisasterTextStyle.copyWith(
fontSize: ScreenUtil().setSp(13.0),
color: Colors.black54),
),
),
),
GestureDetector(
onTap: () {
print(_isClicked);
setState(() {
_isClicked = true;
try {
_firestore.collection('Users').add({
'contact': phoneNumber,
'email': email,
'name': name,
});
} catch (e) {
print('$e on sign in button inside try catch');
}
});
},
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 20.0.w, vertical: 10.0.h),
decoration: BoxDecoration(
color: Colors.pinkAccent.withOpacity(0.08),
borderRadius: BorderRadius.circular(20.0.w),
border: Border.all(
color: Colors.pinkAccent,
),
),
child: Text(
'Subscribe',
style: kCustomNewsTileDisasterTextStyle.copyWith(
fontSize: ScreenUtil().setSp(13.0),
color: Colors.pinkAccent),
),
),
),
],
),
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/widgets/CustomAppBar.dart | import 'package:flutter/material.dart';
import 'package:response/custom_icons/emergency_icons.dart';
import 'package:response/utilities/constants.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:response/views/SOS.dart';
class CustomAppBar extends StatefulWidget {
@override
_CustomAppBarState createState() => _CustomAppBarState();
}
class _CustomAppBarState extends State<CustomAppBar> {
@override
Widget build(BuildContext context) {
ScreenUtil.init(
context,
width: 375.0,
height: 667.0,
allowFontScaling: true,
);
return SafeArea(
top: true,
bottom: false,
left: false,
right: false,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: Icon(Icons.menu, size: 20.0.w, color: Colors.black),
onPressed: () {
Scaffold.of(context).openDrawer();
}),
Text(
'RESPONSE',
style: kCustomAppBarResponseLogoTextStyle,
),
IconButton(
icon: Icon(Emergency.warning, size: 20.0.w, color: Colors.black),
onPressed: () {
Navigator.pushNamed(context, SOS.id);
},
),
],
),
);
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/widgets/CustomNewsTile.dart | import 'package:flutter/material.dart';
import 'package:response/utilities/constants.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:response/views/DetailedNewsPage.dart';
class CustomNewsTile extends StatefulWidget {
final String date;
final String description;
final String distype;
final String headline;
final String imageurl;
final String location;
final String url;
CustomNewsTile(
{this.distype,
this.imageurl,
this.headline,
this.date,
this.location,
this.description,
this.url});
@override
_CustomNewsTileState createState() => _CustomNewsTileState();
}
class _CustomNewsTileState extends State<CustomNewsTile>
with SingleTickerProviderStateMixin {
AnimationController _animationController;
void initState() {
super.initState();
_animationController =
AnimationController(vsync: this, duration: Duration(seconds: 1));
_animationController.repeat(reverse: true);
}
@override
void dispose() {
_animationController.dispose();
super.dispose();
}
// String imageUrl;
// NetworkImage _buildImage() {
// imageUrl = widget.imageurl;
// try {
// return NetworkImage(widget.imageurl);
// } catch (e) {
// imageUrl =
// 'https://images.pexels.com/photos/70573/fireman-firefighter-rubble-9-11-70573.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940';
// return NetworkImage(
// 'https://images.pexels.com/photos/70573/fireman-firefighter-rubble-9-11-70573.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940');
// }
// }
@override
Widget build(BuildContext context) {
ScreenUtil.init(
context,
width: 375.0,
height: 667.0,
allowFontScaling: true,
);
return GestureDetector(
onTap: () {
//TODO: Navigate to the respective DetailedNewsPage
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailedNewsPage(
date: widget.date,
description: widget.description,
distype: widget.distype,
headline: widget.headline,
imageurl: widget.imageurl,
location: widget.location,
url: widget.url,
)),
);
},
child: Padding(
padding: EdgeInsets.symmetric(vertical: 5.0.h, horizontal: 15.0.w),
child: Material(
elevation: 5.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0.w)),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.0.w, vertical: 10.0.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0.w),
border: Border.all(
color: Colors.black12,
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${widget.distype}',
style: kCustomNewsTileDisasterTextStyle,
),
Visibility(
visible: true, //TODO: Visible if the news is live
child: FadeTransition(
opacity: _animationController
.drive(CurveTween(curve: Curves.easeOut)),
child: Container(
padding: EdgeInsets.symmetric(
vertical: 2.0.h, horizontal: 10.0.w),
decoration: BoxDecoration(
color: Color(0xff92F0AD),
borderRadius:
BorderRadius.all(Radius.circular(10.0.w)),
),
child: Text(
'LIVE',
style: TextStyle(
fontSize: ScreenUtil().setSp(12),
fontFamily: 'FredokaOne',
fontWeight: FontWeight.w500,
color: Color(0xff132418),
),
),
),
),
),
],
),
Container(
height: 100.0.h,
margin: EdgeInsets.only(top: 8.0.h, bottom: 15.0.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10.0.w),
topRight: Radius.circular(10.0.w)),
image: DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(widget.imageurl),
),
),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10.0.h),
topRight: Radius.circular(10.0.h)),
gradient: LinearGradient(
begin: Alignment.bottomRight,
stops: [0.1, 0.9],
colors: [
Colors.black.withOpacity(.8),
Colors.black.withOpacity(.1)
],
),
),
),
),
Text(
widget.headline,
style: kCustomNewsTileHeadlineTextStyle,
),
SizedBox(height: 10.0.h),
Text(
'${widget.date} • ${widget.location}',
// '• ${widget.location}',
style: kCustomNewsTileDateTimeTextStyle,
),
],
),
),
),
),
);
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/widgets/CustomPrecautionListTile.dart | import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../views/Flood.dart';
//import 'package:url_launcher/url_launcher.dart';
class CustomPrecautionListTile extends StatelessWidget {
final String disaster;
final Function onPressed;
CustomPrecautionListTile({@required this.disaster, this.onPressed});
@override
Widget build(BuildContext context) {
ScreenUtil.init(
context,
width: 375.0,
height: 667.0,
allowFontScaling: true,
);
return Padding(
padding: EdgeInsets.only(bottom: 10.0.h, left: 15.0.w, right: 15.0.w),
child: Material(
elevation: 5.0,
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(15.0.w)),
child: Container(
height: 100.0.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.0.w),
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage('assets/images/$disaster.jpg'),
),
),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.0.w),
gradient: LinearGradient(
begin: Alignment.bottomRight,
stops: [0.1, 0.9],
colors: [
Colors.black.withOpacity(.8),
Colors.black.withOpacity(.1)
],
),
),
padding: EdgeInsets.symmetric(horizontal: 20.0.w),
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'$disaster',
style: TextStyle(
fontSize: ScreenUtil().setSp(18.0),
fontFamily: 'WorkSans-Black',
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
IconButton(
icon: Icon(
Icons.arrow_forward_ios,
color: Colors.white,
),
onPressed: () async {
print(disaster);
Navigator.pushNamed(context, Flood.id);
// try {
// await launch(
// 'https://immohann.github.io/Crisis-Management/earthquake.html');
// } catch (e) {
// print('$e : Could not launch urk on DetailedNewsPage');
// }
},
)
],
),
),
),
),
),
);
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/widgets/ReusableTextField.dart | import 'package:flutter/material.dart';
import 'package:response/utilities/constants.dart';
class ReusableTextField extends StatefulWidget {
final String hintText;
final String errorText;
final TextInputType keyboardType;
final Function onChanged;
final IconData icon;
ReusableTextField(
{this.hintText,
this.errorText,
this.keyboardType,
this.onChanged,
this.icon});
@override
_ReusableTextFieldState createState() => _ReusableTextFieldState();
}
class _ReusableTextFieldState extends State<ReusableTextField> {
bool _hidden = true;
@override
Widget build(BuildContext context) {
return Stack(
children: [
TextField(
style: TextStyle(color: Color.fromRGBO(38, 50, 56, .50)),
keyboardType: widget.keyboardType,
obscureText: widget.keyboardType == TextInputType.visiblePassword
? _hidden
: false,
decoration: InputDecoration(
icon: Icon(widget.icon),
hintText: widget.hintText,
hintStyle: TextStyle(
color: Color.fromRGBO(38, 50, 56, 0.30),
fontSize: 15.0,
fontFamily: 'WorkSans',
),
errorText: widget.errorText,
errorStyle: TextStyle(
color: Colors.red,
fontSize: 12.0,
fontFamily: 'WorkSans',
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.red, width: 2.5),
borderRadius: BorderRadius.all(Radius.circular(15.0)),
),
border: OutlineInputBorder(
borderSide: BorderSide(color: Colors.blueGrey, width: 1.0),
borderRadius: BorderRadius.all(Radius.circular(12.0)),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.blueAccent, width: 1.0),
borderRadius: BorderRadius.all(Radius.circular(12.0)),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.blue, width: 1.0),
borderRadius: BorderRadius.all(Radius.circular(12.0)),
),
filled: true,
fillColor: Colors.lightBlueAccent.withOpacity(0.05),
contentPadding:
EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
),
onChanged: widget.onChanged,
),
Visibility(
visible: widget.keyboardType == TextInputType.visiblePassword
? true
: false,
child: Align(
alignment: Alignment.bottomRight,
child: IconButton(
icon:
_hidden ? Icon(Icons.visibility) : Icon(Icons.visibility_off),
iconSize: 25.0,
color: kDarkPinkRedColor,
onPressed: () {
setState(() {
_hidden = !_hidden;
});
},
),
),
),
],
);
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/utilities/constants.dart | import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
EdgeInsetsGeometry kStandardPadding =
EdgeInsets.symmetric(horizontal: 20.0.w, vertical: 20.0.h);
const Color kLightPinkColor = Color(0xffF7C7CC);
const Color kFadedWhiteColour = Colors.white70;
const Color kPrimaryRed = Color(0xffED4C61);
const Color kDarkPinkRedColor = Color(0xff8D1D1A);
const Color kLightRed = Color(0xffEC6C6D);
TextStyle kWhatToDoTitleStyle = TextStyle(
fontSize: ScreenUtil().setSp(20.0),
fontFamily: 'WorkSans',
fontWeight: FontWeight.bold,
color: Colors.black,
);
TextStyle kCustomAppBarResponseLogoTextStyle = TextStyle(
fontSize: ScreenUtil().setSp(20.0),
fontFamily: 'BungeeShade',
color: kPrimaryRed,
fontWeight: FontWeight.w500);
TextStyle kWhatToDoPageTextStyle = TextStyle(
fontSize: ScreenUtil().setSp(15.0),
color: Colors.black87,
fontWeight: FontWeight.bold,
fontFamily: 'Merriweather',
);
TextStyle kActiveTitleNewsPageTextStyle = TextStyle(
fontSize: ScreenUtil().setSp(28.0),
fontFamily: 'PlayfairDisplay-Bold',
);
TextStyle kInactiveTitleNewsPageTextStyle = TextStyle(
fontSize: ScreenUtil().setSp(25.0),
color: Colors.black38,
fontFamily: 'PlayfairDisplay-Regular',
);
TextStyle kCustomNewsTileDisasterTextStyle = TextStyle(
fontSize: ScreenUtil().setSp(13.0),
color: Colors.black38,
fontFamily: 'Merriweather',
);
TextStyle kCustomNewsTileHeadlineTextStyle = TextStyle(
fontSize: ScreenUtil().setSp(13.0),
color: Colors.black,
fontFamily: 'Merriweather',
fontWeight: FontWeight.bold,
);
TextStyle kCustomNewsTileDateTimeTextStyle = TextStyle(
fontSize: ScreenUtil().setSp(12.0),
color: Colors.black38,
fontFamily: 'WorkSans',
);
TextStyle kCustomNewsTileDropCapTextStyle = TextStyle(
fontSize: ScreenUtil().setSp(50.0),
color: Colors.black,
fontFamily: 'Lora',
);
TextStyle kCustomNewsTileDropCapBodyTextStyle = TextStyle(
fontSize: ScreenUtil().setSp(18.0),
color: Colors.black,
fontFamily: 'Lora',
);
TextStyle kDrawerItemTextStyle = TextStyle(
fontSize: ScreenUtil().setSp(14.0),
fontWeight: FontWeight.bold,
fontFamily: 'WorkSans',
color: Colors.white);
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/utilities/LocationService.dart | import 'package:geolocator/geolocator.dart';
import 'package:geocoder/geocoder.dart';
import 'dart:async';
class LocationService {
String _userLocation = 'INDIA';
double latitude;
double longitude;
Future<String> getLocation() async {
GeolocationStatus geolocationStatus =
await Geolocator().checkGeolocationPermissionStatus();
try {
Position position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
// Position position = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.medium);
final coordinates = Coordinates(position.latitude, position.longitude);
var addresses =
await Geocoder.local.findAddressesFromCoordinates(coordinates);
var first = addresses.first;
var country = first.countryName;
var adminArea = first.adminArea;
var subAdminArea = first.subAdminArea;
var locality = first.locality;
var subLocality = first.subLocality;
_userLocation = country +
' ' +
adminArea +
' ' +
subAdminArea +
' ' +
locality +
' ' +
subLocality;
_userLocation = _userLocation.toString().toUpperCase();
return _userLocation;
} catch (e) {
print('$e : occurred in LocationService.dart');
return _userLocation;
}
}
Future<double> getLat() async {
try {
Position position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.low);
print("here ${position.latitude}");
return position.latitude;
} catch (e) {
print(e);
return 20.5937;
}
}
Future<double> getLong() async {
try {
Position position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.low);
return position.longitude;
} catch (e) {
print(e);
return 78.9629;
}
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/scraped/SignUpWithEmail.dart | //import 'package:flutter/material.dart';
//import 'package:firebase_auth/firebase_auth.dart';
//import 'package:flutter/services.dart';
//import 'package:response/utilities/constants.dart';
//import 'package:validators/validators.dart' as validator;
//import 'package:modal_progress_hud/modal_progress_hud.dart';
//
//import 'package:response/widgets/ReusableTextField.dart';
//import 'OnboardingScreen.dart';
//
//class SignUpWithEmail extends StatefulWidget {
// static String id = '/SignUpWithEmail';
//
// @override
// _SignUpWithEmailState createState() => _SignUpWithEmailState();
//}
//
//class _SignUpWithEmailState extends State<SignUpWithEmail>
// with SingleTickerProviderStateMixin {
// bool _showSpinner = false;
//
// String email = '';
// String password = '';
//
// bool _isClicked = false;
//
// final FirebaseAuth _auth = FirebaseAuth.instance;
//
// AnimationController _animationController;
// Animation _animation;
//
// String _validateEmail(String value) {
// if (value == 'ERROR_EMAIL_ALREADY_IN_USE') {
// return 'This email is already in use';
// } else {
// if (value.isEmpty) {
// return 'Please enter an Email Address';
// } else if (!validator.isEmail(email)) {
// return 'Please enter a valid Email';
// }
// }
// return null;
// }
//
// String _validatePassword(String value) {
// if (value.isEmpty) {
// return 'Please enter a Password';
// } else if (value.length < 6) {
// return 'Please enter a stronger Password';
// }
// return null;
// }
//
// void initState() {
// super.initState();
//
// _animationController =
// AnimationController(vsync: this, duration: Duration(seconds: 1));
// _animationController.repeat(reverse: true);
// _animation = Tween(begin: 2.0, end: 15.0).animate(_animationController)
// ..addListener(() {
// setState(() {});
// });
// }
//
// @override
// void dispose() {
// _animationController.dispose();
// super.dispose();
// }
//
// @override
// Widget build(BuildContext context) {
// var _width = MediaQuery.of(context).size.width;
// var _height = MediaQuery.of(context).size.height;
//
// return Scaffold(
// backgroundColor: Colors.transparent,
// resizeToAvoidBottomPadding: false,
// body: ModalProgressHUD(
// inAsyncCall: _showSpinner,
// color: Colors.white,
// child: GestureDetector(
// onTap: () => FocusScope.of(context).unfocus(),
// child: Container(
// width: _width,
// height: _height,
// decoration: BoxDecoration(
// gradient: LinearGradient(
// colors: [kLightRed, kPrimaryRed],
// stops: [0.4, 0.9],
// begin: Alignment.topCenter,
// ),
// ),
// child: Stack(
// children: [
// SafeArea(
// child: IconButton(
// icon: Icon(
// Icons.arrow_back_ios,
// color: Colors.black,
// ),
// onPressed: () => Navigator.pop(context),
// ),
// ),
// Positioned(
// left: _width / 2.8,
// top: 40.0,
// child: Container(
// width: 100,
// height: 120,
// child: Image.asset('assets/images/appicon.png',
// width: 100, height: 100),
// decoration: BoxDecoration(
// shape: BoxShape.circle,
// boxShadow: [
// BoxShadow(
// color: Colors.white30,
// blurRadius: _animation.value * 4.5,
// spreadRadius: _animation.value * 2,
// )
// ],
// ),
// ),
// ),
// Positioned(
// top: 160.0,
// left: 50.0, //center //TODO test !
// child: Text(
// 'RESPONSE',
// textAlign: TextAlign.center,
// style: TextStyle(
// fontSize: 50.0,
// fontFamily: 'Bungee',
// color: Colors.white,
// ),
// ),
// ),
// Positioned(
// top: 310.0,
// left: _width / 11,
// child: Container(
// width: _width / 1.2,
// child: Column(
// children: [
// SizedBox(height: 40.0),
// ReusableTextField(
// hintText: 'Password',
// keyboardType: TextInputType.visiblePassword,
// errorText:
// _isClicked ? _validatePassword(password) : null,
// onChanged: (value) {
// password = value;
// },
// ),
// ],
// ),
// ),
// ),
// Positioned(
// bottom: 75.0,
// left: _width / 4.25,
// child: MaterialButton(
// color: Color(0xff44B0F1),
// //TODO: Change color!
// padding: EdgeInsets.symmetric(horizontal: 60.0),
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.all(Radius.circular(12.0)),
// ),
// onPressed: () async {
// try {
// setState(() {
// _showSpinner = true;
// });
// final newUser =
// await _auth.createUserWithEmailAndPassword(
// email: email,
// password: password,
// );
//
// if (newUser != null) {
// print('user authenticated by registration');
// Navigator.pushNamed(context, OnboardingScreen.id);
// } else {
// //Todo User not authenticated alert box!
// }
// } catch (e) {
// setState(() {
// _showSpinner = false;
// });
// if (e.code == 'ERROR_EMAIL_ALREADY_IN_USE') {
// print('$e : SIGN UP WITH EMAIL PAGE');
// email = e.code;
// }
// }
// },
// height: 50,
// child: Text(
// 'SIGN IN',
// style: TextStyle(
// color: Colors.white, //TODO: Change color!
// fontWeight: FontWeight.bold,
// fontSize: 18.0,
// ),
// ),
// ),
// ),
// Positioned(
// bottom: 30.0,
// left: _width / 3.13,
// child: GestureDetector(
// onTap: () {
// //TODO: Navigate to 'Terms & Conditions' page
// },
// child: Text(
// 'Terms & Conditions',
// textAlign: TextAlign.center,
// style: TextStyle(
// color: Colors.white70,
// fontFamily: 'WorkSans',
// fontSize: 15.0,
// ),
// ),
// ),
// ),
// ],
// ),
// ),
// ),
// ),
// );
// }
//}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/scraped/LoginPage.dart | 0 |
|
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/scraped/HelloPage.dart | //import 'package:flutter/material.dart';
//import 'package:response/screens/LoginPage.dart';
//import 'package:response/screens/OnboardingScreen.dart';
//import 'package:response/screens/SignInWithPhone.dart';
//import 'package:response/screens/SignUpWithEmail.dart';
//import 'package:response/utilities/constants.dart';
//
//class HelloPage extends StatefulWidget {
// static String id = '/HelloPage';
//
// @override
// _HelloPageState createState() => _HelloPageState();
//}
//
//class _HelloPageState extends State<HelloPage>
// with SingleTickerProviderStateMixin {
// AnimationController _animationController;
// Animation _animation;
//
// void initState() {
// super.initState();
//
// _animationController =
// AnimationController(vsync: this, duration: Duration(seconds: 1));
// _animationController.repeat(reverse: true);
// _animation = Tween(begin: 2.0, end: 15.0).animate(_animationController)
// ..addListener(() {
// setState(() {});
// });
// }
//
// @override
// void dispose() {
// _animationController.dispose();
// super.dispose();
// }
//
// @override
// Widget build(BuildContext context) {
// var _width = MediaQuery.of(context).size.width;
// var _height = MediaQuery.of(context).size.height;
//
// return Scaffold(
// backgroundColor: Colors.transparent,
// body: Container(
// width: _width,
// height: _height,
// decoration: BoxDecoration(
// gradient: LinearGradient(
// colors: [kLightRed, kPrimaryRed],
// stops: [0.4, 0.9],
// begin: Alignment.topCenter,
// ),
// ),
// child: Stack(
// children: [
// Positioned(
// left: _width / 2.8,
// top: 40.0,
// child: Container(
// width: 100,
// height: 120,
// child: Image.asset('assets/images/appicon.png',
// width: 100, height: 100),
// decoration: BoxDecoration(
// shape: BoxShape.circle,
// boxShadow: [
// BoxShadow(
// color: Colors.white30,
// blurRadius: _animation.value * 4.5,
// spreadRadius: _animation.value * 2,
// )
// ],
// ),
// ),
// ),
// Positioned(
// top: 160.0,
// left: 50.0, //center
// child: Text(
// 'RESPONSE',
// textAlign: TextAlign.center,
// style: TextStyle(
// fontSize: 50.0,
// fontFamily: 'Bungee',
// color: Colors.white,
// ),
// ),
// ),
// Align(
// alignment: Alignment.bottomCenter,
// child: Container(
// width: _width,
// height: 140.0,
// decoration: BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.only(
// topRight: Radius.circular(35),
// topLeft: Radius.circular(35)),
// ),
// ),
// ),
// Positioned(
// bottom: _height / 2.3,
// left: _width / 5.5,
// child: RaisedButton(
// color: Colors.white,
// padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 90.0),
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.all(Radius.circular(10.0)),
// ),
// onPressed: () {
// Navigator.pushNamed(context, SignUpWithEmail.id);
// },
// child: Text(
// 'SIGN UP',
// style: TextStyle(
// color: Colors.black,
// fontWeight: FontWeight.bold,
// fontFamily: 'WorkSans',
// fontSize: 15.0,
// ),
// ),
// ),
// ),
// Positioned(
// bottom: _height / 3,
// left: _width / 5.5,
// child: RaisedButton(
// color: Colors.white,
// padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 97.0),
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.all(Radius.circular(10.0)),
// ),
// onPressed: () {
// Navigator.pushNamed(context, LoginPage.id);
// },
// child: Text(
// 'LOGIN',
// style: TextStyle(
// color: Colors.black,
// fontWeight: FontWeight.bold,
// fontFamily: 'WorkSans',
// fontSize: 15.0,
// ),
// ),
// ),
// ),
// Positioned(
// bottom: _height / 3.65,
// left: _width / 2.65,
// child: GestureDetector(
// onTap: () {
// Navigator.pushNamed(context, OnboardingScreen.id);
// },
// child: Text(
// 'Skip for now',
// style: TextStyle(
// color: Colors.white70,
// fontFamily: 'WorkSans',
// fontSize: 15.0,
// ),
// ),
// ),
// ),
// Positioned(
// bottom: 110.0,
// left: _width / 2.35,
// child: FloatingActionButton(
// backgroundColor: Colors.white,
// onPressed: () {},
// child: Text(
// 'OR',
// textAlign: TextAlign.center,
// style: TextStyle(
// fontSize: 20.0,
// color: Colors.black,
// ),
// ),
// ),
// ),
// Positioned(
// bottom: 43.0,
// child: Container(
// width: _width,
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// children: [
// Stack(
// children: [
// MaterialButton(
// color: Colors.blue,
// padding: EdgeInsets.only(left: 55.0, right: 15.0),
// shape: RoundedRectangleBorder(
// borderRadius:
// BorderRadius.all(Radius.circular(20.0))),
// onPressed: () {
// //TODO: Implement Google login functionality.
// },
// height: 50,
// child: Text(
// 'Sign In with Google',
// style: TextStyle(
// color: Colors.white,
// fontWeight: FontWeight.bold,
// fontFamily: 'WorkSans',
// fontSize: 10.0,
// ),
// ),
// ),
// Align(
// alignment: Alignment.bottomLeft,
// child: Container(
// width: 50.0,
// height: 50.0,
// decoration: BoxDecoration(
// image: DecorationImage(
// scale: 2,
// image: AssetImage('assets/images/google.png'),
// ),
// borderRadius:
// BorderRadius.all(Radius.circular(20.0)),
// color: Colors.white,
// ),
// ),
// ),
// ],
// ),
// Stack(
// children: [
// MaterialButton(
// color: Colors.black,
// onPressed: () {
// Navigator.pushNamed(context, SignInWithPhone.id);
// },
// padding: EdgeInsets.only(left: 55.0, right: 10.0),
// shape: RoundedRectangleBorder(
// borderRadius:
// BorderRadius.all(Radius.circular(20.0))),
// height: 50,
// child: Text(
// 'Sign In with Phone no.',
// style: TextStyle(
// color: Colors.white,
// fontWeight: FontWeight.bold,
// fontFamily: 'WorkSans',
// fontSize: 10.0,
// ),
// ),
// ),
// Align(
// alignment: Alignment.bottomLeft,
// child: Container(
// width: 50.0,
// height: 50.0,
// decoration: BoxDecoration(
// image: DecorationImage(
// scale: 3.5,
// image: AssetImage('assets/images/phone.png'),
// ),
// borderRadius:
// BorderRadius.all(Radius.circular(20.0)),
// color: Colors.white,
// ),
// ),
// )
// ],
// ),
// ],
// ),
// ),
// ),
// Positioned(
// bottom: 10.0,
// left: _width / 3.1,
// child: GestureDetector(
// onTap: () {
// //TODO: Navigate to 'Terms & Conditions' page
// },
// child: Text(
// 'Terms & Conditions',
// textAlign: TextAlign.center,
// style: TextStyle(
// fontSize: 15.0,
// fontFamily: 'WorkSans',
// color: Colors.black,
// ),
// ),
// ),
// ),
// ],
// ),
// ),
// );
// }
//}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/scraped/ForgotYourPasswordPage.dart | //import 'package:firebase_auth/firebase_auth.dart';
//import 'package:flutter/material.dart';
//import 'package:flutter/rendering.dart';
//import 'package:flutter/services.dart';
//import 'package:modal_progress_hud/modal_progress_hud.dart';
//import 'package:validators/validators.dart' as validator;
//import 'package:response/utilities/constants.dart';
//import 'package:giffy_dialog/giffy_dialog.dart';
//
//class ForgotYourPasswordPage extends StatefulWidget {
// static String id = '/ForgotYourPasswordPage';
// @override
// _ForgotYourPasswordPageState createState() => _ForgotYourPasswordPageState();
//}
//
//class _ForgotYourPasswordPageState extends State<ForgotYourPasswordPage> {
// bool _showSpinner = false;
//
// String email = '';
// bool _isClicked = false;
//
// final _auth = FirebaseAuth.instance;
//
// String _validateEmail(String value) {
// if (value == 'ERROR_USER_NOT_FOUND') {
// return 'User does not exist, Please check your email';
// } else {
// if (value.isEmpty) {
// return 'Please enter an Email Address';
// } else if (!validator.isEmail(email)) {
// return 'Please enter a valid Email';
// }
// }
// return null;
// }
//
// @override
// Widget build(BuildContext context) {
// var _width = MediaQuery.of(context).size.width;
// var _height = MediaQuery.of(context).size.height;
// return Scaffold(
// backgroundColor: Colors.white,
// resizeToAvoidBottomPadding: false,
// body: ModalProgressHUD(
// inAsyncCall: _showSpinner,
// color: Colors.white,
// child: GestureDetector(
// onTap: () => FocusScope.of(context).unfocus(),
// child: Container(
// width: _width,
// height: _height,
// //background image
// decoration: BoxDecoration(
// image: DecorationImage(
// fit: BoxFit.cover,
// colorFilter: ColorFilter.mode(
// Colors.white.withOpacity(0.05), BlendMode.dstATop),
// image: AssetImage('assets/images/questions.png'),
// ),
// ),
// child: Stack(
// children: [
// SafeArea(
// child: Padding(
// padding: EdgeInsets.only(top: 8.0),
// child: IconButton(
// icon: Icon(
// Icons.arrow_back_ios,
// color: Colors.black,
// ),
// onPressed: () => Navigator.pop(context),
// ),
// ),
// ),
// SafeArea(
// child: Padding(
// padding: EdgeInsets.only(top: 18.0, left: _width / 4.5),
// child: Text(
// 'Forgot Password?',
// style: TextStyle(
// fontSize: 25.0,
// fontFamily: 'WorkSans',
// fontWeight: FontWeight.bold,
// color: kPrimaryRed,
// ),
// ),
// ),
// ),
// Positioned(
// top: 45.0,
// left: _width / 4,
// child: Container(
// width: 200,
// height: 200,
// child: Image.asset('assets/images/forgot.png'),
// ),
// ),
// Positioned(
// top: 260.0,
// left: 20.0,
// right: 20.0,
// child: Text(
// 'Enter the email address of your account.',
// textAlign: TextAlign.center,
// style: TextStyle(
// fontSize: 18.0,
// fontFamily: 'WorkSans',
// fontWeight: FontWeight.w600,
// color: Colors.black,
// ),
// ),
// ),
// Positioned(
// top: 335.0,
// left: _width / 11,
// child: Container(
// width: _width / 1.2,
// child: TextField(
// keyboardType: TextInputType.emailAddress,
// onChanged: (value) {
// email = value;
// },
// decoration: InputDecoration(
// hintText: 'Email',
// hintStyle: TextStyle(
// color: kTextFieldForgotPageBorderColor,
// fontSize: 15.0,
// fontFamily: 'WorkSans',
// ),
// errorText: _isClicked ? _validateEmail(email) : null,
// errorStyle: TextStyle(
// color: Colors.red,
// fontSize: 12.0,
// fontFamily: 'WorkSans',
// ),
// errorBorder: OutlineInputBorder(
// borderSide: BorderSide(color: Colors.red, width: 2.5),
// borderRadius: BorderRadius.all(Radius.circular(20.0)),
// ),
// border: OutlineInputBorder(
// borderSide: BorderSide(
// color: kTextFieldForgotPageBorderColor,
// width: 1.0),
// borderRadius: BorderRadius.all(Radius.circular(15.0)),
// ),
// enabledBorder: OutlineInputBorder(
// borderSide: BorderSide(
// color: kTextFieldForgotPageBorderColor,
// width: 1.0),
// borderRadius: BorderRadius.all(Radius.circular(15.0)),
// ),
// focusedBorder: OutlineInputBorder(
// borderSide: BorderSide(
// color: kTextFieldForgotPageBorderColor,
// width: 1.0),
// borderRadius: BorderRadius.all(Radius.circular(15.0)),
// ),
// filled: true,
// fillColor: kTextFieldForgotPageColor,
// contentPadding: EdgeInsets.symmetric(
// vertical: 10.0, horizontal: 20.0),
// ),
// ),
// ),
// ),
// Positioned(
// bottom: 75.0,
// left: _width / 5,
// child: MaterialButton(
// color: kPrimaryRed,
// padding: EdgeInsets.symmetric(horizontal: 30.0),
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.all(Radius.circular(12.0)),
// ),
// onPressed: () async {
// try {
// setState(() {
// _showSpinner = true;
// });
// await _auth.sendPasswordResetEmail(email: email);
// setState(() {
// _showSpinner = false;
// });
//
// showDialog(
// context: context,
// builder: (_) => AssetGiffyDialog(
// image: Image.asset('assets/images/mail.gif'),
// title: Text(
// 'Email Sent!',
// style: TextStyle(
// fontSize: 22.0,
// fontWeight: FontWeight.w600,
// ),
// ),
// description: Text(
// 'Please check your email and click on the reset password link.',
// textAlign: TextAlign.center,
// style: TextStyle(),
// ),
// entryAnimation: EntryAnimation.DEFAULT,
// onlyOkButton: true,
// onOkButtonPressed: () {
// Navigator.pop(context);
// },
// ));
// } catch (e) {
// print('$e : Forgot your pswd PAGE');
//
// setState(() {
// _showSpinner = false;
// });
//
// if (e.code == 'ERROR_USER_NOT_FOUND') {
// //Test case when user doesn't exist!
// setState(() {
// _isClicked = true;
// email = e.code;
// });
// }
// }
// },
// height: 50,
// child: Text(
// 'RESET PASSWORD',
// style: TextStyle(
// color: Colors.white,
// fontWeight: FontWeight.bold,
// fontSize: 18.0,
// ),
// ),
// ),
// ),
// Positioned(
// bottom: 30.0,
// left: _width / 3.13,
// child: GestureDetector(
// onTap: () {
// //TODO: Navigate to 'Terms & Conditions' page
// },
// child: Text(
// 'Terms & Conditions',
// textAlign: TextAlign.center,
// style: TextStyle(
// color: Colors.black,
// fontFamily: 'WorkSans',
// fontSize: 15.0,
// ),
// ),
// ),
// ),
// ],
// ),
// ),
// ),
// ),
// );
// }
//}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/scraped/SignInWithPhone.dart | //import 'dart:async';
//
//import 'package:firebase_auth/firebase_auth.dart';
//import 'package:flutter/material.dart';
//import 'package:modal_progress_hud/modal_progress_hud.dart';
//import 'package:response/screens/HomePage.dart';
//import 'package:response/utilities/constants.dart';
//import 'package:response/widgets/ReusableTextField.dart';
//import 'package:pin_code_fields/pin_code_fields.dart';
//
//import 'OnboardingScreen.dart';
//
//class SignInWithPhone extends StatefulWidget {
// static String id = '/SignInWithPhone';
//
// @override
// _SignInWithPhoneState createState() => _SignInWithPhoneState();
//}
//
//class _SignInWithPhoneState extends State<SignInWithPhone>
// with SingleTickerProviderStateMixin {
// AnimationController _animationController;
// Animation _animation;
//
// TextEditingController _phoneNumberController = TextEditingController();
//
// bool _showSpinner = false;
// bool _isClicked = false;
// bool _errorInOTP = false;
//
// String phoneNumber = '';
// String smsCode = '';
//
// FirebaseUser _firebaseUser;
// AuthCredential _phoneAuthCredential;
// String _verificationId;
//
// String validatePhoneNum(String value) {
// String pattern = r'(^(?:[+0]9)?[0-9]{10,12}$)';
// RegExp regExp = RegExp(pattern);
//
// if (value.contains('+91', 0)) {
// return null;
// } else {
// if (value.isEmpty) {
// return 'Please enter a phone number';
// } else if (!regExp.hasMatch(value)) {
// return 'Please enter a valid phone number';
// }
// }
//
// return null;
// }
//
// void initState() {
// super.initState();
//
// _animationController =
// AnimationController(vsync: this, duration: Duration(seconds: 1));
// _animationController.repeat(reverse: true);
// _animation = Tween(begin: 2.0, end: 15.0).animate(_animationController)
// ..addListener(() {
// setState(() {});
// });
// }
//
// @override
// void dispose() {
// _animationController.dispose();
// super.dispose();
// }
//
// //Step 1: After the phoneNumber is valid and working, this function will send a otp and handle backend
// Future<void> _submitPhoneNumber() async {
// print('inside _submitPhoneNumber');
// //Assuming Indian Number used!
// phoneNumber = "+91 " + phoneNumber;
// print(phoneNumber);
// void verificationCompleted(AuthCredential phoneAuthCredential) {
// print('verificationCompleted');
// _phoneAuthCredential = phoneAuthCredential;
// print(phoneAuthCredential);
// }
//
// void verificationFailed(AuthException authException) {
// setState(() {
// _showSpinner = false;
// errorController.add(ErrorAnimationType.shake);
// });
//
// print('verificationFailed');
// print('Line 81: ${authException.message}');
//
// String status = '${authException.message}';
//
// print("Error message: " + status);
// if (authException.message.contains('not authorized'))
// status = 'Something has gone wrong, please try later';
// else if (authException.message.contains('Network'))
// status = 'Please check your internet connection and try again';
// else
// status = 'Something has gone wrong, please try later';
// }
//
// void codeSent(String verificationId, [int code]) {
// print('codeSent');
// _verificationId = verificationId;
// print(verificationId);
// print(code.toString());
// }
//
// void codeAutoRetrievalTimeout(String verificationId) {
// print('codeAutoRetrievalTimeout');
// _verificationId = verificationId;
// }
//
// await FirebaseAuth.instance.verifyPhoneNumber(
// phoneNumber: phoneNumber,
//
// timeout: Duration(seconds: 60),
//
// // If the SIM (with phoneNumber) is in the current device this function is called.
// verificationCompleted: verificationCompleted,
//
// // Called when the verification is failed
// verificationFailed: verificationFailed,
//
// /// This is called after the OTP is sent. Gives a `verificationId` and `code`
// codeSent: codeSent,
//
// /// After automatic code retrieval `timeout` this function is called
// codeAutoRetrievalTimeout: codeAutoRetrievalTimeout,
// );
//
// setState(() {
// _showSpinner = false;
// });
// _displayDialog(context);
// }
//
// //Step 2: To enter otp manually - backend
// void _submitOTP() {
// print('inside _submitOTP');
//
// /// we need to use OTP to get `phoneAuthCredential` which is in turn used to signIn/login
// _phoneAuthCredential = PhoneAuthProvider.getCredential(
// verificationId: _verificationId, smsCode: smsCode);
//
// _login();
// }
//
// //Step 3: Finally login
// Future<void> _login() async {
// print('inside _login');
//
// /// This method is used to login the user
// /// `AuthCredential`(`_phoneAuthCredential`) is needed for the signIn method
// /// After the signIn method from `AuthResult` we can get `FirebaseUser`(`_firebaseUser`)
// try {
// await FirebaseAuth.instance
// .signInWithCredential(this._phoneAuthCredential)
// .then((AuthResult authRes) {
// _firebaseUser = authRes.user;
// print('firebase user : line 143 ${_firebaseUser.toString()}');
//
// setState(() {
// _showSpinner = false;
// });
//
// if (authRes.additionalUserInfo.isNewUser) {
// Navigator.pushNamed(context, OnboardingScreen.id);
// } else {
// Navigator.pushNamed(context, HomePage.id);
// }
// });
// } catch (e) {
// setState(() {
// _showSpinner = false;
// _errorInOTP = true;
// errorController.add(ErrorAnimationType.shake);
// });
//
// //TODO : didn't work!
// print('$e : SIGN IN WITH PHONE');
// }
// }
//
// StreamController<ErrorAnimationType> errorController =
// StreamController<ErrorAnimationType>.broadcast();
//
// _displayDialog(BuildContext context) async {
// print('inside _displayDialog');
//
// return showDialog(
// useSafeArea: true,
// context: context,
// builder: (context) {
// return AlertDialog(
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.all(Radius.circular(10.0))),
// title: Text(
// "Please enter the OTP sent on '$phoneNumber'",
// textAlign: TextAlign.center,
// style: TextStyle(
// color: Colors.black,
// fontFamily: 'WorkSans',
// fontWeight: FontWeight.bold,
// fontSize: 15.0,
// ),
// ),
// content: PinCodeTextField(
// length: 6,
// obsecureText: false,
// animationType: AnimationType.fade,
// autoDisposeControllers: false,
// pinTheme: PinTheme(
// shape: PinCodeFieldShape.underline,
// borderRadius: BorderRadius.circular(5),
// fieldHeight: 50,
// fieldWidth: 30,
// activeColor: kDarkPinkRedColor,
// selectedColor: kLightPinkColor,
// ),
// animationDuration: Duration(milliseconds: 300),
// errorAnimationController: errorController,
// onCompleted: (value) {
// smsCode = value;
// print('smsCode: $smsCode');
//
// //
// },
// onChanged: (value) {},
// beforeTextPaste: (text) {
// //if you return true then it will show the paste confirmation dialog. Otherwise if false, then nothing will happen.
// return true;
// },
// ),
// actions: <Widget>[
// FlatButton(
// splashColor: kLightRed,
// child: Text(
// 'SUBMIT',
// style: TextStyle(
// color: kPrimaryRed,
// fontFamily: 'WorkSans',
// fontWeight: FontWeight.bold,
// fontSize: 15.0,
// ),
// ),
// onPressed: () {
// setState(() {
// _showSpinner = true;
// });
// _submitOTP();
// if (!_errorInOTP) {
// Navigator.pop(context);
// }
// },
// )
// ],
// );
// });
// }
//
// @override
// Widget build(BuildContext context) {
// var _width = MediaQuery.of(context).size.width;
// var _height = MediaQuery.of(context).size.height;
//
// return Scaffold(
// backgroundColor: Colors.transparent,
// resizeToAvoidBottomPadding: false,
// body: ModalProgressHUD(
// inAsyncCall: _showSpinner,
// color: Colors.white,
// child: GestureDetector(
// onTap: () => FocusScope.of(context).unfocus(),
// child: Container(
// width: _width,
// height: _height,
// decoration: BoxDecoration(
// gradient: LinearGradient(
// colors: [kLightRed, kPrimaryRed],
// stops: [0.4, 0.9],
// begin: Alignment.topCenter,
// ),
// ),
// child: Stack(
// children: [
// SafeArea(
// child: IconButton(
// icon: Icon(
// Icons.arrow_back_ios,
// color: Colors.black,
// ),
// onPressed: () => Navigator.pop(context),
// ),
// ),
// Positioned(
// left: _width / 2.8,
// top: 40.0,
// child: Container(
// width: 100,
// height: 120,
// child: Image.asset('assets/images/appicon.png',
// width: 100, height: 100),
// decoration: BoxDecoration(
// shape: BoxShape.circle,
// boxShadow: [
// BoxShadow(
// color: Colors.white30,
// blurRadius: _animation.value * 4.5,
// spreadRadius: _animation.value * 2,
// )
// ],
// ),
// ),
// ),
// Positioned(
// top: 160.0,
// left: 50.0,
// child: Text(
// 'RESPONSE',
// textAlign: TextAlign.center,
// style: TextStyle(
// fontSize: 50.0,
// fontFamily: 'Bungee',
// color: Colors.white,
// ),
// ),
// ),
// Positioned(
// top: 290.0,
// left: _width / 11,
// child: Container(
// width: _width / 1.2,
// child: ,
// ),
// ),
// Positioned(
// bottom: 75.0,
// left: _width / 3.25,
// child: MaterialButton(
// color: Colors.black87, //TODO: Change color!
// padding: EdgeInsets.symmetric(horizontal: 40.0),
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.all(Radius.circular(12.0)),
// ),
// onPressed: () async {
// setState(() {
// _isClicked = true;
//
// try {
// _showSpinner = true;
// if (validatePhoneNum(phoneNumber) == null) {
// _submitPhoneNumber();
// } else {
// _showSpinner = false;
// }
// } catch (e) {
// _showSpinner = false;
// print('$e on sign in button inside try catch');
// }
// });
// },
// height: 50,
// child: Text(
// 'SIGN IN',
// style: TextStyle(
// color: Colors.white,
// fontWeight: FontWeight.bold,
// fontSize: 18.0,
// ),
// ),
// ),
// ),
// Positioned(
// bottom: 30.0,
// left: _width / 3.13,
// child: GestureDetector(
// onTap: () {
// //TODO: Navigate to 'Terms & Conditions' page
// },
// child: Text(
// 'Terms & Conditions',
// textAlign: TextAlign.center,
// style: TextStyle(
// color: Colors.white70,
// fontFamily: 'WorkSans',
// fontSize: 15.0,
// ),
// ),
// ),
// ),
// ],
// ),
// ),
// ),
// ),
// );
// }
//}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/models/ScreenUtilClass.dart | import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ScreenUtil {
static ScreenUtil instance = new ScreenUtil();
int width;
int height;
bool allowFontScaling;
static MediaQueryData _mediaQueryData;
static double _screenWidth;
static double _screenHeight;
static double _pixelRatio;
static double _statusBarHeight;
static double _bottomBarHeight;
static double _textScaleFactor;
ScreenUtil({
this.width = 1080,
this.height = 1920,
this.allowFontScaling = false,
});
static ScreenUtil getInstance() {
return instance;
}
void init(BuildContext context) {
MediaQueryData mediaQuery = MediaQuery.of(context);
_mediaQueryData = mediaQuery;
_pixelRatio = mediaQuery.devicePixelRatio;
_screenWidth = mediaQuery.size.width;
_screenHeight = mediaQuery.size.height;
_statusBarHeight = mediaQuery.padding.top;
_bottomBarHeight = _mediaQueryData.padding.bottom;
_textScaleFactor = mediaQuery.textScaleFactor;
}
static MediaQueryData get mediaQueryData => _mediaQueryData;
static double get textScaleFactory => _textScaleFactor;
static double get pixelRatio => _pixelRatio;
static double get screenWidthDp => _screenWidth;
static double get screenHeightDp => _screenHeight;
static double get screenWidth => _screenWidth * _pixelRatio;
static double get screenHeight => _screenHeight * _pixelRatio;
static double get statusBarHeight => _statusBarHeight * _pixelRatio;
static double get bottomBarHeight => _bottomBarHeight * _pixelRatio;
get scaleWidth => _screenWidth / instance.width;
get scaleHeight => _screenHeight / instance.height;
setWidth(int width) => width * scaleWidth;
setHeight(int height) => height * scaleHeight;
setSp(int fontSize) => allowFontScaling
? setWidth(fontSize)
: setWidth(fontSize) / _textScaleFactor;
void printScreenInformation() {
print('Device width dp:${ScreenUtil.screenWidth}'); //Device width
print('Device height dp:${ScreenUtil.screenHeight}'); //Device height
print(
'Device pixel density:${ScreenUtil.pixelRatio}'); //Device pixel density
print(
'Bottom safe zone distance dp:${ScreenUtil.bottomBarHeight}'); //Bottom safe zone distance,suitable for buttons with full screen
print(
'Status bar height px:${ScreenUtil.statusBarHeight}dp'); //Status bar height , Notch will be higher Unit px
print(
'Ratio of actual width dp to design draft px:${ScreenUtil().scaleWidth}');
print(
'Ratio of actual height dp to design draft px:${ScreenUtil().scaleHeight}');
print(
'The ratio of font and width to the size of the design:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}');
print(
'The ratio of height width to the size of the design:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}');
print('System font scaling:${ScreenUtil.textScaleFactory}');
print('0.5 times the screen width:${0.5.wp}');
print('0.5 times the screen height:${0.5.hp}');
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/models/MenuItem.dart | import 'package:flutter/material.dart';
class MenuItem {
String title;
IconData icon;
Function onPressed;
MenuItem(this.icon, this.title, this.onPressed);
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/models/OnboardingModel.dart | class OnboardingPageModel {
String title;
String info;
OnboardingPageModel({this.title, this.info});
}
class OnboardingPage {
static List<OnboardingPageModel> _page = [
OnboardingPageModel(
title: 'DISASTER NEWS',
info:
'Based on your location, Response shows national and local news on News Screen'),
OnboardingPageModel(
title: 'HEALTH CARE FACILITIES',
info:
'Be prepared before, during and after a disaster with steps from top doctors'),
OnboardingPageModel(
title: 'MAP SERVICES',
info:
'Locate closest helpline facilities in your periphery & be informed of any incoming fatal situations via gps.'),
OnboardingPageModel(
title: 'SOS BUTTON',
info:
'Use the emergency SOS button to notify your contacts when you\'re in need.'),
];
String getTitle(int pageNumber) {
return _page[pageNumber].title;
}
String getInfo(int pageNumber) {
return _page[pageNumber].info;
}
static int getNumOfPages() {
return _page.length;
}
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/custom_icons/maps_icons.dart | /// Flutter icons Maps
/// Copyright (C) 2020 by original authors @ fluttericon.com, fontello.com
/// This font was generated by FlutterIcon.com, which is derived from Fontello.
///
/// To use this font, place it in your fonts/ directory and include the
/// following in your pubspec.yaml
///
/// flutter:
/// fonts:
/// - family: Maps
/// fonts:
/// - asset: fonts/Maps.ttf
///
///
/// * Elusive, Copyright (C) 2013 by Aristeides Stathopoulos
/// Author: Aristeides Stathopoulos
/// License: SIL (http://scripts.sil.org/OFL)
/// Homepage: http://aristeides.com/
///
import 'package:flutter/widgets.dart';
class Maps {
Maps._();
static const _kFontFam = 'Maps';
static const _kFontPkg = null;
static const IconData location = IconData(0xe800, fontFamily: _kFontFam, fontPackage: _kFontPkg);
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/custom_icons/arrow_front_icons.dart | /// Flutter icons ArrowFront
/// Copyright (C) 2020 by original authors @ fluttericon.com, fontello.com
/// This font was generated by FlutterIcon.com, which is derived from Fontello.
///
/// To use this font, place it in your fonts/ directory and include the
/// following in your pubspec.yaml
///
/// flutter:
/// fonts:
/// - family: ArrowFront
/// fonts:
/// - asset: fonts/ArrowFront.ttf
///
///
/// * Typicons, (c) Stephen Hutchings 2012
/// Author: Stephen Hutchings
/// License: SIL (http://scripts.sil.org/OFL)
/// Homepage: http://typicons.com/
///
import 'package:flutter/widgets.dart';
class ArrowFront {
ArrowFront._();
static const _kFontFam = 'ArrowFront';
static const _kFontPkg = null;
static const IconData right_outline = IconData(0xe800, fontFamily: _kFontFam, fontPackage: _kFontPkg);
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/custom_icons/heart_icon_icons.dart | /// Flutter icons HeartIcon
/// Copyright (C) 2020 by original authors @ fluttericon.com, fontello.com
/// This font was generated by FlutterIcon.com, which is derived from Fontello.
///
/// To use this font, place it in your fonts/ directory and include the
/// following in your pubspec.yaml
///
/// flutter:
/// fonts:
/// - family: HeartIcon
/// fonts:
/// - asset: fonts/HeartIcon.ttf
///
///
/// * Linecons, Copyright (C) 2013 by Designmodo
/// Author: Designmodo for Smashing Magazine
/// License: CC BY ()
/// Homepage: http://designmodo.com/linecons-free/
///
import 'package:flutter/widgets.dart';
class HeartIcon {
HeartIcon._();
static const _kFontFam = 'HeartIcon';
static const _kFontPkg = null;
static const IconData heart = IconData(0xe805, fontFamily: _kFontFam, fontPackage: _kFontPkg);
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/custom_icons/share_icons.dart | /// Flutter icons Share
/// Copyright (C) 2020 by original authors @ fluttericon.com, fontello.com
/// This font was generated by FlutterIcon.com, which is derived from Fontello.
///
/// To use this font, place it in your fonts/ directory and include the
/// following in your pubspec.yaml
///
/// flutter:
/// fonts:
/// - family: Share
/// fonts:
/// - asset: fonts/Share.ttf
///
///
///
import 'package:flutter/widgets.dart';
class Share {
Share._();
static const _kFontFam = 'Share';
static const _kFontPkg = null;
static const IconData icons8_share = IconData(0xe803, fontFamily: _kFontFam, fontPackage: _kFontPkg);
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/custom_icons/idea_icons.dart | /// Flutter icons Idea
/// Copyright (C) 2020 by original authors @ fluttericon.com, fontello.com
/// This font was generated by FlutterIcon.com, which is derived from Fontello.
///
/// To use this font, place it in your fonts/ directory and include the
/// following in your pubspec.yaml
///
/// flutter:
/// fonts:
/// - family: Idea
/// fonts:
/// - asset: fonts/Idea.ttf
///
///
///
import 'package:flutter/widgets.dart';
class Idea {
Idea._();
static const _kFontFam = 'Idea';
static const _kFontPkg = null;
static const IconData icons8_idea = IconData(0xe802, fontFamily: _kFontFam, fontPackage: _kFontPkg);
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/custom_icons/news_icons.dart | /// Flutter icons News
/// Copyright (C) 2020 by original authors @ fluttericon.com, fontello.com
/// This font was generated by FlutterIcon.com, which is derived from Fontello.
///
/// To use this font, place it in your fonts/ directory and include the
/// following in your pubspec.yaml
///
/// flutter:
/// fonts:
/// - family: News
/// fonts:
/// - asset: fonts/News.ttf
///
///
///
import 'package:flutter/widgets.dart';
class News {
News._();
static const _kFontFam = 'News';
static const _kFontPkg = null;
static const IconData icons8_news = IconData(0xe801, fontFamily: _kFontFam, fontPackage: _kFontPkg);
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/custom_icons/emergency_icons.dart | /// Flutter icons Emergency
/// Copyright (C) 2020 by original authors @ fluttericon.com, fontello.com
/// This font was generated by FlutterIcon.com, which is derived from Fontello.
///
/// To use this font, place it in your fonts/ directory and include the
/// following in your pubspec.yaml
///
/// flutter:
/// fonts:
/// - family: Emergency
/// fonts:
/// - asset: fonts/Emergency.ttf
///
///
///
import 'package:flutter/widgets.dart';
class Emergency {
Emergency._();
static const _kFontFam = 'Emergency';
static const _kFontPkg = null;
static const IconData warning = IconData(0xe800, fontFamily: _kFontFam, fontPackage: _kFontPkg);
}
| 0 |
mirrored_repositories/Response/ResponseApp/lib | mirrored_repositories/Response/ResponseApp/lib/custom_icons/drawer_icon_icons.dart | import 'package:flutter/widgets.dart';
class DrawerIcon {
DrawerIcon._();
static const _kFontFam = 'DrawerIcon';
static const _kFontPkg = null;
static const IconData terms_and_conditions =
IconData(0xe800, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData subscribe =
IconData(0xe801, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData speak =
IconData(0xe802, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData feedback =
IconData(0xe803, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData home_run =
IconData(0xe804, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData question_mark =
IconData(0xe805, fontFamily: _kFontFam, fontPackage: _kFontPkg);
}
| 0 |
mirrored_repositories/Response/ResponseApp | mirrored_repositories/Response/ResponseApp/test/widget_test.dart | 0 |
|
mirrored_repositories/Response/ResponseApp/ios | mirrored_repositories/Response/ResponseApp/ios/resources/application_localizations.dart | import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class ApplicationLocalizations {
final Locale appLocale;
ApplicationLocalizations(this.appLocale);
static ApplicationLocalizations of(BuildContext context) {
return Localizations.of<ApplicationLocalizations>(
context, ApplicationLocalizations);
}
Map<String, String> _localizedStrings;
Future<bool> load() async {
// Load JSON file from the "language" folder
String jsonString = await rootBundle
.loadString('resources/language/${appLocale.languageCode}.json');
Map<String, dynamic> jsonLanguageMap = json.decode(jsonString);
_localizedStrings = jsonLanguageMap.map((key, value) {
return MapEntry(key, value.toString());
});
return true;
}
// called from every widget which needs a localized text
String translate(String jsonkey) {
return _localizedStrings[jsonkey];
}
}
| 0 |
mirrored_repositories/Response/ResponseApp | mirrored_repositories/Response/ResponseApp/localization/language.dart | class Language {
final int id;
// final String flag;
final String name;
final String languageCode;
Language(this.id, this.name, this.languageCode);
static List<Language> languageList() {
return <Language>[
Language(1, "English", "en"),
Language(4, "हिंदी", "hi"),
Language(7, "मराठी", "mr"),
];
}
}
| 0 |
mirrored_repositories/Response/ResponseApp | mirrored_repositories/Response/ResponseApp/localization/appLocalization.dart | //import 'dart:convert';
//import 'dart:ui';
//import 'package:flutter/material.dart';
//import 'package:flutter/services.dart';
//
//class AppLocalizations {
// final Locale locale;
//
// AppLocalizations(this.locale);
//
// // Helper method to keep the code in the widgets concise
// // Localizations are accessed using an InheritedWidget "of" syntax
// static AppLocalizations of(BuildContext context) {
// return Localizations.of<AppLocalizations>(context, AppLocalizations);
// }
//
// // Static member to have a simple access to the delegate from the MaterialApp
// static const LocalizationsDelegate<AppLocalizations> delegate =
// _AppLocalizationsDelegate();
//
// Map<String, String> _localizedStrings;
//
// Future<bool> load() async {
// // Load the language JSON file from the "lang" folder
// String jsonString = await rootBundle
// .loadString('resources/language/${locale.languageCode}.json');
// Map<String, dynamic> jsonMap = json.decode(jsonString);
//
// _localizedStrings = jsonMap.map((key, value) {
// return MapEntry(key, value.toString());
// });
//
// return true;
// }
//
// // This method will be called from every widget which needs a localized text
// String translate(String key) {
// return _localizedStrings[key];
// }
//}
//
//class _AppLocalizationsDelegate
// extends LocalizationsDelegate<AppLocalizations> {
// // This delegate instance will never change (it doesn't even have fields!)
// // It can provide a constant constructor.
// const _AppLocalizationsDelegate();
//
// @override
// bool isSupported(Locale locale) {
// // Include all of your supported language codes here
// return ['en', 'hi', 'mr'].contains(locale.languageCode);
// }
//
// @override
// Future<AppLocalizations> load(Locale locale) async {
// // AppLocalizations class is where the JSON loading actually runs
// AppLocalizations localizations = new AppLocalizations(locale);
// await localizations.load();
// return localizations;
// }
//
// @override
// bool shouldReload(_AppLocalizationsDelegate old) => false;
//}
| 0 |
mirrored_repositories/Response/ResponseApp | mirrored_repositories/Response/ResponseApp/localization/language_constants.dart | //import 'package:flutter/material.dart';
//import 'appLocalization.dart';
//import 'package:shared_preferences/shared_preferences.dart';
//
//const String LAGUAGE_CODE = 'languageCode';
//
////languages code
//const String ENGLISH = 'en';
//const String MARATHI = 'mr';
//const String HINDI = 'hi';
//
//Future<Locale> setLocale(String languageCode) async {
// SharedPreferences _prefs = await SharedPreferences.getInstance();
// await _prefs.setString(LAGUAGE_CODE, languageCode);
// return _locale(languageCode);
//}
//
//Future<Locale> getLocale() async {
// SharedPreferences _prefs = await SharedPreferences.getInstance();
// String languageCode = _prefs.getString(LAGUAGE_CODE) ?? "en";
// // print(_prefs.getString('LANGUAGE_CODE'));
// return _locale(languageCode);
//}
//
//Locale _locale(String languageCode) {
// switch (languageCode) {
// case ENGLISH:
// return Locale(ENGLISH, 'US');
// case HINDI:
// return Locale(HINDI, "IN");
// case MARATHI:
// return Locale(MARATHI, "IN");
// default:
// return Locale(ENGLISH, 'US');
// }
//}
//
//String getTranslated(BuildContext context, String key) {
// return AppLocalizations.of(context).translate(key);
//}
| 0 |
mirrored_repositories/Response/ResponseApp | mirrored_repositories/Response/ResponseApp/localization/appLanguage.dart | //import 'package:flutter/material.dart';
//import 'package:shared_preferences/shared_preferences.dart';
//
//class AppLanguage extends ChangeNotifier {
// Locale _appLocale = Locale('en');
//
// Locale get appLocal => _appLocale ?? Locale("en");
// fetchLocale() async {
// var prefs = await SharedPreferences.getInstance();
// if (prefs.getString('language_code') == null) {
// _appLocale = Locale('en');
// return Null;
// }
// _appLocale = Locale(prefs.getString('language_code'));
// return Null;
// }
//
// void changeLanguage(Locale type) async {
// var prefs = await SharedPreferences.getInstance();
// if (_appLocale == type) {
// return;
// }
// if (type == Locale("hi")) {
// _appLocale = Locale("hi");
// await prefs.setString('language_code', 'hi');
// await prefs.setString('countryCode', 'IN');
// } else if (type == Locale("mr")) {
// _appLocale = Locale("mr");
// await prefs.setString('language_code', 'mr');
// await prefs.setString('countryCode', 'IN');
// } else {
// _appLocale = Locale("en");
// await prefs.setString('language_code', 'en');
// await prefs.setString('countryCode', 'US');
// }
// notifyListeners();
// }
//}
| 0 |
mirrored_repositories/zero_lite_flutter | mirrored_repositories/zero_lite_flutter/lib/main.dart | import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:zero_lite/pages/introPage.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations(
[
DeviceOrientation.portraitUp,
],
);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Zero Lite',
debugShowCheckedModeBanner: false,
home: IntroPageView(),
);
}
}
| 0 |
mirrored_repositories/zero_lite_flutter/lib | mirrored_repositories/zero_lite_flutter/lib/pages/detailPage.dart | import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:zero_lite/data/model/countrylist_model.dart';
import 'package:zero_lite/widget/elevatedButton.dart';
import 'package:zero_lite/widget/makeText.dart';
class DetailPage extends StatelessWidget {
final CountryList? countryList;
DetailPage({this.countryList});
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
return Scaffold(
appBar: appbar(context) as PreferredSizeWidget?,
body: ListView(
physics: NeverScrollableScrollPhysics(),
children: [
Stack(
children: [
imageShow(size),
],
),
detailCountryShow(size, context),
],
),
);
}
Widget detailCountryShow(Size size, BuildContext context) {
return Container(
height: size.height,
decoration: BoxDecoration(
color: Colors.indigo.shade400,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30),
),
),
transform: Matrix4.translationValues(0, -25, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: size.height * 0.03,
),
Center(
child: makeText(
countryList!.name!,
fontWeight: FontWeight.bold,
color: Colors.white,
size: Theme.of(context).textTheme.headline5!.fontSize,
),
),
SizedBox(
height: size.height * 0.026,
),
Padding(
padding: EdgeInsets.only(
right: size.width * 0.04,
left: size.width * 0.04,
),
child: Container(
height: size.height * 0.4,
child: GridView(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
mainAxisSpacing: size.height * 0.04,
childAspectRatio: 4.5,
),
children: [
makeChip(
context,
labelString: countryList!.capital ?? "",
avatarText: "C",
),
makeChip(
context,
labelString: countryList!.nativeName ?? "",
avatarText: "N",
),
makeChip(
context,
labelString: countryList!.callingCodes!.first,
avatarText: "CC",
),
makeChip(
context,
labelString: countryList!.population.toString(),
avatarText: "P",
),
makeChip(
context,
labelString: countryList!.area.toString(),
avatarText: "A",
),
makeChip(
context,
labelString: countryList!.region.toString(),
avatarText: "R",
),
makeChip(
context,
labelString: countryList!.subregion,
avatarText: "SR",
),
makeChip(
context,
labelString: countryList!.timezones!.first,
avatarText: "T",
),
makeChip(
context,
labelString: countryList!.languages![0].nativeName,
avatarText: "L",
),
makeChip(
context,
labelString: countryList!.demonym,
avatarText: "D",
),
makeChip(
context,
labelString: countryList!.altSpellings!.first,
avatarText: "AS",
),
makeChip(
context,
labelString: countryList!.currencies![0].symbol,
avatarText: "CS",
),
makeChip(
context,
labelString: countryList!.currencies![0].name,
avatarText: "CN",
),
],
),
),
),
SizedBox(
height: size.height * 0.02,
),
Center(
child: elevatedButton(
context,
textString: "More Information",
minimumSize: Size(size.width * 0.6, size.height * 0.06),
onPressed: () {},
),
),
],
),
);
}
Widget imageShow(Size size) {
return Container(
height: size.height * 0.33,
width: size.width,
child: SvgPicture.network(
countryList!.flag!,
cacheColorFilter: true,
allowDrawingOutsideViewBox: false,
fit: BoxFit.cover,
placeholderBuilder: (context) =>
Center(child: CircularProgressIndicator()),
height: 128.0,
),
);
}
Widget appbar(BuildContext context) {
return AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
leading: IconButton(
icon: Icon(
Icons.clear,
color: Colors.black,
),
onPressed: () {
Navigator.pop(context);
},
),
actions: [
IconButton(
icon: Icon(
Icons.info_outline,
color: Colors.black,
),
onPressed: () {
showAboutDialog(
context: context,
children: [
makeInfoRow(
context,
rowlabelOneText: "Capital",
rowOneavatarText: "C",
rowlabelTwoText: "Native Name",
rowTwoavatarText: "N",
),
makeInfoRow(
context,
rowlabelOneText: "Region",
rowOneavatarText: "R",
rowlabelTwoText: "Area",
rowTwoavatarText: "A",
),
makeInfoRow(
context,
rowlabelOneText: "Population",
rowOneavatarText: "P",
rowlabelTwoText: "Language",
rowTwoavatarText: "L",
),
makeInfoRow(
context,
rowlabelOneText: "Calling Code",
rowOneavatarText: "CC",
rowlabelTwoText: "Timezones",
rowTwoavatarText: "T",
),
makeInfoRow(
context,
rowlabelOneText: "Currency Symbol",
rowOneavatarText: "S",
rowlabelTwoText: "Code",
rowTwoavatarText: "C",
),
makeInfoRow(
context,
rowlabelOneText: "Demonym",
rowOneavatarText: "D",
rowlabelTwoText: "AltSpelling",
rowTwoavatarText: "AS",
),
makeInfoRow(
context,
rowlabelOneText: "Currency Name",
rowOneavatarText: "CN",
rowlabelTwoText: "SubRegion",
rowTwoavatarText: "SR",
),
],
);
},
),
],
);
}
Widget makeInfoRow(
BuildContext context, {
String? rowlabelOneText,
String? rowlabelTwoText,
String? rowOneavatarText,
String? rowTwoavatarText,
}) {
return Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
makeChip(
context,
labelString: rowlabelOneText,
avatarText: rowOneavatarText,
),
makeChip(
context,
labelString: rowlabelTwoText,
avatarText: rowTwoavatarText,
),
],
);
}
Widget makeChip(BuildContext context,
{String? labelString, String? avatarText}) {
return Chip(
label: makeText(labelString ?? "",
size: Theme.of(context).textTheme.caption!.fontSize),
labelPadding: EdgeInsets.all(4),
avatar: CircleAvatar(
backgroundColor: Colors.grey.shade500,
child: makeText(
avatarText ?? "",
color: Colors.white,
fontWeight: FontWeight.bold,
size: Theme.of(context).textTheme.button!.fontSize,
),
),
);
}
}
| 0 |
mirrored_repositories/zero_lite_flutter/lib | mirrored_repositories/zero_lite_flutter/lib/pages/introPage.dart | import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:intro_views_flutter/intro_views_flutter.dart';
import 'package:zero_lite/pages/homepage.dart';
import 'package:zero_lite/widget/makeText.dart';
class IntroPageView extends StatefulWidget {
@override
_IntroPageViewState createState() => _IntroPageViewState();
}
class _IntroPageViewState extends State<IntroPageView> {
final pages = [
PageViewModel(
pageColor: Colors.amberAccent.shade100,
bubble: Icon(Icons.place_rounded),
mainImage: SvgPicture.asset(
'assets/world.svg',
),
body: makeText("God made the country, and man made the town"),
title: makeText("Zero Lite"),
titleTextStyle: TextStyle(
color: Colors.black,
fontSize: 18,
fontWeight: FontWeight.bold,
),
bodyTextStyle: TextStyle(
color: Colors.black,
fontSize: 15,
),
),
PageViewModel(
pageColor: Colors.blueGrey.shade100,
bubble: Icon(Icons.security_rounded),
mainImage: SvgPicture.asset(
'assets/shield.svg',
),
body: makeText(
"Uncertainty and expectation are the joys of life. Security is an insipid thing"),
title: makeText("Zero Lite"),
titleTextStyle: TextStyle(
color: Colors.black,
fontSize: 18,
fontWeight: FontWeight.bold,
),
bodyTextStyle: TextStyle(
color: Colors.black,
fontSize: 15,
),
),
PageViewModel(
pageColor: Colors.pink.shade100,
bubble: Icon(
Icons.location_city_rounded,
),
mainImage: SvgPicture.asset(
'assets/cityscape.svg',
),
body: makeText("The city is not a concrete jungle, it is a human zoo"),
title: makeText("Zero Lite"),
titleTextStyle: TextStyle(
color: Colors.black,
fontSize: 18,
fontWeight: FontWeight.bold,
),
bodyTextStyle: TextStyle(
color: Colors.black,
fontSize: 15,
),
),
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: IntroViewsFlutter(
pages,
skipText: makeText(
"SKIP",
color: Colors.black,
size: 15,
),
backText: makeText(
"BACK",
color: Colors.black,
size: 15,
),
nextText: makeText(
"NEXT",
color: Colors.black,
size: 15,
),
doneText: makeText(
"DONE",
color: Colors.black,
size: 15,
),
showNextButton: true,
showBackButton: true,
showSkipButton: true,
onTapSkipButton: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => HomePage(title: 'Zero Lite'),
),
);
},
onTapDoneButton: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => HomePage(title: 'Zero Lite'),
), //MaterialPageRoute
);
},
pageButtonTextStyles: TextStyle(
color: Colors.white,
fontSize: 18,
),
),
);
}
}
| 0 |
mirrored_repositories/zero_lite_flutter/lib | mirrored_repositories/zero_lite_flutter/lib/pages/homepage.dart | import 'package:flutter/material.dart';
import 'package:zero_lite/data/model/countrylist_model.dart';
import 'package:zero_lite/data/services/apiService.dart';
import 'package:zero_lite/pages/detailPage.dart';
import 'package:zero_lite/pages/searchPage.dart';
import 'package:zero_lite/widget/makeText.dart';
class HomePage extends StatefulWidget {
final String? title;
HomePage({
this.title,
});
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: appbar(context) as PreferredSizeWidget?,
body: FutureBuilder(
future: ApiService().getCountryList(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (!snapshot.hasData) return LinearProgressIndicator();
return ListView.builder(
physics: BouncingScrollPhysics(),
itemCount: snapshot.data!.length,
itemBuilder: (_, index) {
List<CountryList> data = snapshot.data;
return ListTile(
leading: CircleAvatar(
backgroundColor: Colors.teal,
child: makeText(
data[index].alpha2Code!,
fontWeight: FontWeight.bold,
size: Theme.of(context).textTheme.caption!.fontSize,
),
),
title: makeText(
data[index].name!,
fontWeight: FontWeight.bold,
size: Theme.of(context).textTheme.subtitle1!.fontSize,
),
subtitle: makeText(
data[index].capital!,
size: Theme.of(context).textTheme.caption!.fontSize,
),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => DetailPage(
countryList: data[index],
),
),
);
},
);
},
);
},
),
),
);
}
Widget appbar(BuildContext context) {
return AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
title: makeText(
widget.title!,
color: Colors.indigo,
fontWeight: FontWeight.bold,
size: Theme.of(context).textTheme.headline6!.fontSize,
),
actions: [
IconButton(
icon: Icon(
Icons.search,
color: Colors.black,
),
onPressed: () {
showSearch(context: context, delegate: SearchPage());
},
),
],
);
}
}
| 0 |
mirrored_repositories/zero_lite_flutter/lib | mirrored_repositories/zero_lite_flutter/lib/pages/searchPage.dart | import 'package:flutter/material.dart';
import 'package:zero_lite/data/model/countrylist_model.dart';
import 'package:zero_lite/data/services/apiService.dart';
import 'package:zero_lite/pages/detailPage.dart';
import 'package:zero_lite/widget/makeText.dart';
class SearchPage extends SearchDelegate {
@override
List<Widget> buildActions(BuildContext context) {
return [
IconButton(
icon: Icon(
Icons.search,
color: Colors.black,
),
onPressed: () {
query = "";
},
),
];
}
@override
Widget buildLeading(BuildContext context) {
return BackButton(
color: Colors.black,
);
}
@override
Widget buildResults(BuildContext context) {
ApiService apiService = ApiService();
return FutureBuilder(
future: apiService.getSearchList(name: query),
builder: (BuildContext context, AsyncSnapshot snapshot) {
List<CountryList>? countrylist = snapshot.data;
if (!snapshot.hasData) return LinearProgressIndicator();
return ListView.builder(
itemCount: countrylist!.length,
itemBuilder: (_, index) {
return ListTile(
title: makeText(countrylist[index].name!),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => DetailPage(
countryList: countrylist[index],
)));
},
);
});
});
}
@override
Widget buildSuggestions(BuildContext context) {
return Center(
child: makeText(
'Search Country Name',
size: Theme.of(context).textTheme.headline6!.fontSize,
),
);
}
}
| 0 |
mirrored_repositories/zero_lite_flutter/lib/data | mirrored_repositories/zero_lite_flutter/lib/data/model/countrylist_model.dart | // To parse this JSON data, do
//
// final countryList = countryListFromJson(jsonString);
import 'dart:convert';
List<CountryList> countryListFromJson(String str) => List<CountryList>.from(
json.decode(str).map((x) => CountryList.fromJson(x)));
String countryListToJson(List<CountryList> data) =>
json.encode(List<dynamic>.from(data.map((x) => x.toJson())));
class CountryList {
CountryList({
this.name,
this.topLevelDomain,
this.alpha2Code,
this.alpha3Code,
this.callingCodes,
this.capital,
this.altSpellings,
this.region,
this.subregion,
this.population,
this.latlng,
this.demonym,
this.area,
this.gini,
this.timezones,
this.borders,
this.nativeName,
this.numericCode,
this.currencies,
this.languages,
this.translations,
this.flag,
this.regionalBlocs,
this.cioc,
});
String? name;
List<String>? topLevelDomain;
String? alpha2Code;
String? alpha3Code;
List<String>? callingCodes;
String? capital;
List<String>? altSpellings;
Region? region;
String? subregion;
int? population;
List<double>? latlng;
String? demonym;
double? area;
double? gini;
List<String>? timezones;
List<String>? borders;
String? nativeName;
String? numericCode;
List<Currency>? currencies;
List<Language>? languages;
Translations? translations;
String? flag;
List<RegionalBloc>? regionalBlocs;
String? cioc;
factory CountryList.fromJson(Map<String, dynamic> json) => CountryList(
name: json["name"],
topLevelDomain: List<String>.from(json["topLevelDomain"].map((x) => x)),
alpha2Code: json["alpha2Code"],
alpha3Code: json["alpha3Code"],
callingCodes: List<String>.from(json["callingCodes"].map((x) => x)),
capital: json["capital"],
altSpellings: List<String>.from(json["altSpellings"].map((x) => x)),
region: regionValues.map[json["region"]],
subregion: json["subregion"],
population: json["population"],
latlng: List<double>.from(json["latlng"].map((x) => x.toDouble())),
demonym: json["demonym"],
area: json["area"] == null ? null : json["area"].toDouble(),
gini: json["gini"] == null ? null : json["gini"].toDouble(),
timezones: List<String>.from(json["timezones"].map((x) => x)),
borders: List<String>.from(json["borders"].map((x) => x)),
nativeName: json["nativeName"],
numericCode: json["numericCode"] == null ? null : json["numericCode"],
currencies: List<Currency>.from(
json["currencies"].map((x) => Currency.fromJson(x))),
languages: List<Language>.from(
json["languages"].map((x) => Language.fromJson(x))),
translations: Translations.fromJson(json["translations"]),
flag: json["flag"],
regionalBlocs: List<RegionalBloc>.from(
json["regionalBlocs"].map((x) => RegionalBloc.fromJson(x))),
cioc: json["cioc"] == null ? null : json["cioc"],
);
Map<String, dynamic> toJson() => {
"name": name,
"topLevelDomain": List<dynamic>.from(topLevelDomain!.map((x) => x)),
"alpha2Code": alpha2Code,
"alpha3Code": alpha3Code,
"callingCodes": List<dynamic>.from(callingCodes!.map((x) => x)),
"capital": capital,
"altSpellings": List<dynamic>.from(altSpellings!.map((x) => x)),
"region": regionValues.reverse![region!],
"subregion": subregion,
"population": population,
"latlng": List<dynamic>.from(latlng!.map((x) => x)),
"demonym": demonym,
"area": area == null ? null : area,
"gini": gini == null ? null : gini,
"timezones": List<dynamic>.from(timezones!.map((x) => x)),
"borders": List<dynamic>.from(borders!.map((x) => x)),
"nativeName": nativeName,
"numericCode": numericCode == null ? null : numericCode,
"currencies": List<dynamic>.from(currencies!.map((x) => x.toJson())),
"languages": List<dynamic>.from(languages!.map((x) => x.toJson())),
"translations": translations!.toJson(),
"flag": flag,
"regionalBlocs":
List<dynamic>.from(regionalBlocs!.map((x) => x.toJson())),
"cioc": cioc == null ? null : cioc,
};
}
class Currency {
Currency({
this.code,
this.name,
this.symbol,
});
String? code;
String? name;
String? symbol;
factory Currency.fromJson(Map<String, dynamic> json) => Currency(
code: json["code"] == null ? null : json["code"],
name: json["name"] == null ? null : json["name"],
symbol: json["symbol"] == null ? null : json["symbol"],
);
Map<String, dynamic> toJson() => {
"code": code == null ? null : code,
"name": name == null ? null : name,
"symbol": symbol == null ? null : symbol,
};
}
class Language {
Language({
this.iso6391,
this.iso6392,
this.name,
this.nativeName,
});
String? iso6391;
String? iso6392;
String? name;
String? nativeName;
factory Language.fromJson(Map<String, dynamic> json) => Language(
iso6391: json["iso639_1"] == null ? null : json["iso639_1"],
iso6392: json["iso639_2"],
name: json["name"],
nativeName: json["nativeName"],
);
Map<String, dynamic> toJson() => {
"iso639_1": iso6391 == null ? null : iso6391,
"iso639_2": iso6392,
"name": name,
"nativeName": nativeName,
};
}
enum Region { ASIA, EUROPE, AFRICA, OCEANIA, AMERICAS, POLAR, EMPTY }
final regionValues = EnumValues({
"Africa": Region.AFRICA,
"Americas": Region.AMERICAS,
"Asia": Region.ASIA,
"": Region.EMPTY,
"Europe": Region.EUROPE,
"Oceania": Region.OCEANIA,
"Polar": Region.POLAR
});
class RegionalBloc {
RegionalBloc({
this.acronym,
this.name,
this.otherAcronyms,
this.otherNames,
});
Acronym? acronym;
Name? name;
List<OtherAcronym>? otherAcronyms;
List<OtherName>? otherNames;
factory RegionalBloc.fromJson(Map<String, dynamic> json) => RegionalBloc(
acronym: acronymValues.map[json["acronym"]],
name: nameValues.map[json["name"]],
otherAcronyms: List<OtherAcronym>.from(
json["otherAcronyms"].map((x) => otherAcronymValues.map[x])),
otherNames: List<OtherName>.from(
json["otherNames"].map((x) => otherNameValues.map[x])),
);
Map<String, dynamic> toJson() => {
"acronym": acronymValues.reverse![acronym!],
"name": nameValues.reverse![name!],
"otherAcronyms": List<dynamic>.from(
otherAcronyms!.map((x) => otherAcronymValues.reverse![x])),
"otherNames": List<dynamic>.from(
otherNames!.map((x) => otherNameValues.reverse![x])),
};
}
enum Acronym {
SAARC,
EU,
CEFTA,
AU,
AL,
CARICOM,
USAN,
EEU,
CAIS,
ASEAN,
NAFTA,
PA,
EFTA
}
final acronymValues = EnumValues({
"AL": Acronym.AL,
"ASEAN": Acronym.ASEAN,
"AU": Acronym.AU,
"CAIS": Acronym.CAIS,
"CARICOM": Acronym.CARICOM,
"CEFTA": Acronym.CEFTA,
"EEU": Acronym.EEU,
"EFTA": Acronym.EFTA,
"EU": Acronym.EU,
"NAFTA": Acronym.NAFTA,
"PA": Acronym.PA,
"SAARC": Acronym.SAARC,
"USAN": Acronym.USAN
});
enum Name {
SOUTH_ASIAN_ASSOCIATION_FOR_REGIONAL_COOPERATION,
EUROPEAN_UNION,
CENTRAL_EUROPEAN_FREE_TRADE_AGREEMENT,
AFRICAN_UNION,
ARAB_LEAGUE,
CARIBBEAN_COMMUNITY,
UNION_OF_SOUTH_AMERICAN_NATIONS,
EURASIAN_ECONOMIC_UNION,
CENTRAL_AMERICAN_INTEGRATION_SYSTEM,
ASSOCIATION_OF_SOUTHEAST_ASIAN_NATIONS,
NORTH_AMERICAN_FREE_TRADE_AGREEMENT,
PACIFIC_ALLIANCE,
EUROPEAN_FREE_TRADE_ASSOCIATION
}
final nameValues = EnumValues({
"African Union": Name.AFRICAN_UNION,
"Arab League": Name.ARAB_LEAGUE,
"Association of Southeast Asian Nations":
Name.ASSOCIATION_OF_SOUTHEAST_ASIAN_NATIONS,
"Caribbean Community": Name.CARIBBEAN_COMMUNITY,
"Central American Integration System":
Name.CENTRAL_AMERICAN_INTEGRATION_SYSTEM,
"Central European Free Trade Agreement":
Name.CENTRAL_EUROPEAN_FREE_TRADE_AGREEMENT,
"Eurasian Economic Union": Name.EURASIAN_ECONOMIC_UNION,
"European Free Trade Association": Name.EUROPEAN_FREE_TRADE_ASSOCIATION,
"European Union": Name.EUROPEAN_UNION,
"North American Free Trade Agreement":
Name.NORTH_AMERICAN_FREE_TRADE_AGREEMENT,
"Pacific Alliance": Name.PACIFIC_ALLIANCE,
"South Asian Association for Regional Cooperation":
Name.SOUTH_ASIAN_ASSOCIATION_FOR_REGIONAL_COOPERATION,
"Union of South American Nations": Name.UNION_OF_SOUTH_AMERICAN_NATIONS
});
enum OtherAcronym { UNASUR, UNASUL, UZAN, EAEU, SICA }
final otherAcronymValues = EnumValues({
"EAEU": OtherAcronym.EAEU,
"SICA": OtherAcronym.SICA,
"UNASUL": OtherAcronym.UNASUL,
"UNASUR": OtherAcronym.UNASUR,
"UZAN": OtherAcronym.UZAN
});
enum OtherName {
EMPTY,
UNION_AFRICAINE,
UNIO_AFRICANA,
UNIN_AFRICANA,
UMOJA_WA_AFRIKA,
OTHER_NAME,
JMI_AT_AD_DUWAL_AL_ARABYAH,
LEAGUE_OF_ARAB_STATES,
COMUNIDAD_DEL_CARIBE,
COMMUNAUT_CARIBENNE,
CARIBISCHE_GEMEENSCHAP,
UNIN_DE_NACIONES_SURAMERICANAS,
UNIO_DE_NAES_SUL_AMERICANAS,
UNIE_VAN_ZUID_AMERIKAANSE_NATIES,
SOUTH_AMERICAN_UNION,
SISTEMA_DE_LA_INTEGRACIN_CENTROAMERICANA,
TRATADO_DE_LIBRE_COMERCIO_DE_AMRICA_DEL_NORTE,
ACCORD_DE_LIBRE_CHANGE_NORD_AMRICAIN,
ALIANZA_DEL_PACFICO
}
final otherNameValues = EnumValues({
"Accord de Libre-échange Nord-Américain":
OtherName.ACCORD_DE_LIBRE_CHANGE_NORD_AMRICAIN,
"Alianza del Pacífico": OtherName.ALIANZA_DEL_PACFICO,
"Caribische Gemeenschap": OtherName.CARIBISCHE_GEMEENSCHAP,
"Communauté Caribéenne": OtherName.COMMUNAUT_CARIBENNE,
"Comunidad del Caribe": OtherName.COMUNIDAD_DEL_CARIBE,
"الاتحاد الأفريقي": OtherName.EMPTY,
"Jāmiʻat ad-Duwal al-ʻArabīyah": OtherName.JMI_AT_AD_DUWAL_AL_ARABYAH,
"League of Arab States": OtherName.LEAGUE_OF_ARAB_STATES,
"جامعة الدول العربية": OtherName.OTHER_NAME,
"Sistema de la Integración Centroamericana,":
OtherName.SISTEMA_DE_LA_INTEGRACIN_CENTROAMERICANA,
"South American Union": OtherName.SOUTH_AMERICAN_UNION,
"Tratado de Libre Comercio de América del Norte":
OtherName.TRATADO_DE_LIBRE_COMERCIO_DE_AMRICA_DEL_NORTE,
"Umoja wa Afrika": OtherName.UMOJA_WA_AFRIKA,
"Unie van Zuid-Amerikaanse Naties":
OtherName.UNIE_VAN_ZUID_AMERIKAANSE_NATIES,
"Unión Africana": OtherName.UNIN_AFRICANA,
"Unión de Naciones Suramericanas": OtherName.UNIN_DE_NACIONES_SURAMERICANAS,
"Union africaine": OtherName.UNION_AFRICAINE,
"União Africana": OtherName.UNIO_AFRICANA,
"União de Nações Sul-Americanas": OtherName.UNIO_DE_NAES_SUL_AMERICANAS
});
class Translations {
Translations({
this.de,
this.es,
this.fr,
this.ja,
this.it,
this.br,
this.pt,
this.nl,
this.hr,
this.fa,
});
String? de;
String? es;
String? fr;
String? ja;
String? it;
String? br;
String? pt;
String? nl;
String? hr;
String? fa;
factory Translations.fromJson(Map<String, dynamic> json) => Translations(
de: json["de"] == null ? null : json["de"],
es: json["es"] == null ? null : json["es"],
fr: json["fr"] == null ? null : json["fr"],
ja: json["ja"] == null ? null : json["ja"],
it: json["it"] == null ? null : json["it"],
br: json["br"],
pt: json["pt"],
nl: json["nl"] == null ? null : json["nl"],
hr: json["hr"] == null ? null : json["hr"],
fa: json["fa"],
);
Map<String, dynamic> toJson() => {
"de": de == null ? null : de,
"es": es == null ? null : es,
"fr": fr == null ? null : fr,
"ja": ja == null ? null : ja,
"it": it == null ? null : it,
"br": br,
"pt": pt,
"nl": nl == null ? null : nl,
"hr": hr == null ? null : hr,
"fa": fa,
};
}
class EnumValues<T> {
Map<String, T> map;
Map<T, String>? reverseMap;
EnumValues(this.map);
Map<T, String>? get reverse {
if (reverseMap == null) {
reverseMap = map.map((k, v) => new MapEntry(v, k));
}
return reverseMap;
}
}
| 0 |
mirrored_repositories/zero_lite_flutter/lib/data | mirrored_repositories/zero_lite_flutter/lib/data/services/apiService.dart | import 'dart:async';
import 'package:zero_lite/data/model/countrylist_model.dart';
import 'package:http/http.dart' as http;
class ApiService {
String url = "https://restcountries.eu/rest/v2/all";
Iterable<CountryList> countryData = [];
Future<List<CountryList>> getCountryList() async {
var resp = await http.get(Uri.parse(url));
countryData = countryListFromJson(resp.body);
return countryData as FutureOr<List<CountryList>>;
}
Future<List<CountryList>> getSearchList({String? name}) async {
var resp = await http.get(Uri.parse(url));
countryData = countryListFromJson(resp.body);
if (name != null) {
countryData = countryData
.where((element) => element.name!.toLowerCase().contains(name))
.toList();
}
return countryData as FutureOr<List<CountryList>>;
}
}
| 0 |
mirrored_repositories/zero_lite_flutter/lib | mirrored_repositories/zero_lite_flutter/lib/widget/elevatedButton.dart | import 'package:flutter/material.dart';
import 'makeText.dart';
Widget elevatedButton(
context, {
required String textString,
Function? onPressed,
Size? minimumSize,
}) {
return ElevatedButton(
onPressed: onPressed as void Function()?,
child: makeText(
textString,
color: Colors.white,
size: Theme.of(context).textTheme.button!.fontSize,
),
style: ElevatedButton.styleFrom(
primary: Colors.teal,
minimumSize: minimumSize,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
),
);
}
| 0 |
mirrored_repositories/zero_lite_flutter/lib | mirrored_repositories/zero_lite_flutter/lib/widget/makeText.dart | import 'package:flutter/material.dart';
Widget makeText(
String textString, {
Color? color,
FontWeight? fontWeight,
double? size,
}) {
return Text(
textString,
style: TextStyle(
color: color,
fontSize: size,
fontWeight: fontWeight,
),
);
}
| 0 |
mirrored_repositories/zero_lite_flutter | mirrored_repositories/zero_lite_flutter/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:zero_lite/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/quiz_app | mirrored_repositories/quiz_app/lib/quiz.dart | import 'package:flutter/material.dart';
import 'package:quiz/data/questions.dart';
import 'package:quiz/questions_screen.dart';
import 'package:quiz/result_screen.dart';
import 'package:quiz/start_screen.dart';
class Quiz extends StatefulWidget {
const Quiz({super.key});
@override
State<Quiz> createState() {
return _QuizState();
}
}
class _QuizState extends State<Quiz> {
List<String> selectedAnswer = [];
var activeScreen = 'start-screen';
void switchScreen() {
setState(() {
activeScreen = 'question-screen';
});
}
void chooseAnswer(String answer) {
selectedAnswer.add(answer);
if (selectedAnswer.length == questions.length) {
setState(() {
activeScreen = 'result-screen';
});
}
}
void restartQuiz() {
setState(() {
selectedAnswer = [];
activeScreen = 'question-screen';
});
}
@override
Widget build(context) {
return MaterialApp(
home: Scaffold(
body: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(colors: [
Color.fromARGB(255, 142, 35, 161),
Color.fromARGB(255, 115, 27, 131),
], begin: Alignment.topLeft, end: Alignment.bottomRight),
),
child: activeScreen == 'start-screen'
? StartScreen(switchScreen)
: activeScreen == 'result-screen'
? ResultScreen(
chosenAnswer: selectedAnswer,
restartQuiz: restartQuiz,
)
: QuestionsScreen(onSelectAnswer: chooseAnswer),
),
),
);
}
}
| 0 |
mirrored_repositories/quiz_app | mirrored_repositories/quiz_app/lib/result_screen.dart | import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:quiz/data/questions.dart';
import 'package:quiz/questions_summary/question_summary.dart';
class ResultScreen extends StatelessWidget {
const ResultScreen(
{super.key, required this.chosenAnswer, required this.restartQuiz});
final List<String> chosenAnswer;
final Function() restartQuiz;
List<Map<String, Object>> getSummaryData() {
final List<Map<String, Object>> summary = [];
for (var i = 0; i < chosenAnswer.length; i++) {
summary.add({
'question_index': i,
'question': questions[i].text,
'correct_answer': questions[i].answers[0],
'user_answer': chosenAnswer[i],
});
}
return summary;
}
@override
Widget build(BuildContext context) {
final summaryData = getSummaryData();
var numTotalQuestion = questions.length;
final numCorrectQuestion = summaryData.where((data) {
return data['user_answer'] == data['correct_answer'];
}).length;
return SizedBox(
width: double.infinity,
child: Container(
margin: const EdgeInsets.all(40),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
"You got $numCorrectQuestion out $numTotalQuestion correct",
textAlign: TextAlign.center,
style: GoogleFonts.lato(color: Colors.white, fontSize: 25),
),
const SizedBox(
height: 30,
),
QuestionSummary(summaryData),
const SizedBox(
height: 30,
),
TextButton.icon(
icon: const Icon(Icons.refresh),
onPressed: restartQuiz,
style: TextButton.styleFrom(foregroundColor: Colors.white),
label: const Text(
"Restart Quiz",
style: TextStyle(fontSize: 20),
),
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/quiz_app | mirrored_repositories/quiz_app/lib/questions_screen.dart | import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:quiz/data/questions.dart';
import 'package:quiz/model/answer_button.dart';
class QuestionsScreen extends StatefulWidget {
const QuestionsScreen({super.key, required this.onSelectAnswer});
final void Function(String answer) onSelectAnswer;
@override
State<QuestionsScreen> createState() {
return _QuestionsScreenState();
}
}
class _QuestionsScreenState extends State<QuestionsScreen> {
var currentQuestionIndex = 0;
void answerQuestion(String answer) {
widget.onSelectAnswer(answer);
setState(() {
currentQuestionIndex += 1;
});
}
@override
Widget build(context) {
final currentQuestion = questions[currentQuestionIndex];
return SizedBox(
width: double.infinity,
child: Container(
margin: const EdgeInsets.all(40),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
currentQuestion.text,
style: GoogleFonts.lato(
color: const Color.fromARGB(255, 201, 153, 251),
fontSize: 24,
fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
const SizedBox(
height: 30,
),
...currentQuestion.getShuffledAnswer().map((item) {
return AnswerButton(
answerText: item,
onTap: () {
answerQuestion(item);
});
}),
])));
}
}
| 0 |
mirrored_repositories/quiz_app | mirrored_repositories/quiz_app/lib/start_screen.dart | import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class StartScreen extends StatelessWidget {
const StartScreen(this.startQuiz, {super.key});
final void Function() startQuiz;
@override
Widget build(context) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
"assets/images/quiz-logo.png",
width: 300,
color: const Color.fromARGB(150, 255, 255, 255),
),
const SizedBox(
height: 80,
),
Text(
"Learn Flutter the fun way",
style: GoogleFonts.lato(
color: const Color.fromARGB(255, 237, 223, 252), fontSize: 24),
),
const SizedBox(
height: 30,
),
OutlinedButton.icon(
onPressed: startQuiz,
style: OutlinedButton.styleFrom(foregroundColor: Colors.white),
icon: const Icon(Icons.arrow_right_alt),
label: const Text("Start Quiz"),
)
],
),
);
}
}
| 0 |
mirrored_repositories/quiz_app | mirrored_repositories/quiz_app/lib/main.dart | import 'package:flutter/material.dart';
import 'package:quiz/quiz.dart';
void main() {
runApp(Quiz());
}
| 0 |
mirrored_repositories/quiz_app/lib | mirrored_repositories/quiz_app/lib/data/questions.dart | import 'package:quiz/model/quiz_question.dart';
const questions = [
QuizQuestion(
'What are the main building blocks of Flutter UIs?',
[
'Widgets',
'Components',
'Blocks',
'Functions',
],
),
QuizQuestion('How are Flutter UIs built?', [
'By combining widgets in code',
'By combining widgets in a visual editor',
'By defining widgets in config files',
'By using XCode for iOS and Android Studio for Android',
]),
QuizQuestion(
'What\'s the purpose of a StatefulWidget?',
[
'Update UI as data changes',
'Update data as UI changes',
'Ignore data changes',
'Render UI that does not depend on data',
],
),
QuizQuestion(
'Which widget should you try to use more often: StatelessWidget or StatefulWidget?',
[
'StatelessWidget',
'StatefulWidget',
'Both are equally good',
'None of the above',
],
),
QuizQuestion(
'What happens if you change data in a StatelessWidget?',
[
'The UI is not updated',
'The UI is updated',
'The closest StatefulWidget is updated',
'Any nested StatefulWidgets are updated',
],
),
QuizQuestion(
'How should you update data inside of StatefulWidgets?',
[
'By calling setState()',
'By calling updateData()',
'By calling updateUI()',
'By calling updateState()',
],
),
];
| 0 |
mirrored_repositories/quiz_app/lib | mirrored_repositories/quiz_app/lib/model/quiz_question.dart | class QuizQuestion {
const QuizQuestion(this.text, this.answers);
final String text;
final List<String> answers;
List<String> getShuffledAnswer() {
final shuffledAnswer = List.of(answers);
shuffledAnswer.shuffle();
return shuffledAnswer;
}
}
| 0 |
mirrored_repositories/quiz_app/lib | mirrored_repositories/quiz_app/lib/model/answer_button.dart | import 'package:flutter/material.dart';
class AnswerButton extends StatelessWidget {
const AnswerButton({
super.key,
required this.answerText,
required this.onTap,
});
final String answerText;
final void Function() onTap;
@override
Widget build(context) {
return ElevatedButton(
onPressed: onTap,
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 40),
backgroundColor: const Color.fromARGB(255, 33, 1, 95),
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40),
),
),
child: Text(
answerText,
textAlign: TextAlign.center,
),
);
}
}
| 0 |
mirrored_repositories/quiz_app/lib | mirrored_repositories/quiz_app/lib/questions_summary/question_summary.dart | import 'package:flutter/material.dart';
import 'package:quiz/questions_summary/summary_items.dart';
class QuestionSummary extends StatelessWidget {
const QuestionSummary(this.summaryData, {super.key});
final List<Map<String, Object>> summaryData;
@override
Widget build(BuildContext context) {
return SizedBox(
height: 300,
child: SingleChildScrollView(
child: Column(
children: summaryData.map(
(data) {
return SummaryItems(itemData: data);
},
).toList(),
),
),
);
}
}
| 0 |
mirrored_repositories/quiz_app/lib | mirrored_repositories/quiz_app/lib/questions_summary/summary_items.dart | import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:quiz/questions_summary/question_identifier.dart';
class SummaryItems extends StatelessWidget {
const SummaryItems({super.key, required this.itemData});
final Map<String, Object> itemData;
@override
Widget build(BuildContext context) {
final isCorrectAnswer =
itemData['user_answer'] == itemData['correct_answer'];
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
QuestionIdentifier(
questionIndex: itemData['question_index'] as int,
isCorrectAnswer: isCorrectAnswer),
const SizedBox(
height: 5,
width: 20,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
itemData['question'] as String,
style: GoogleFonts.lato(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16),
),
const SizedBox(
height: 5,
),
Text(
itemData['user_answer'] as String,
style: const TextStyle(color: Color.fromARGB(255, 202, 171, 152)),
),
Text(
itemData['correct_answer'] as String,
style: const TextStyle(color: Color.fromARGB(255, 181, 254, 246)),
),
const SizedBox(
height: 10,
)
],
))
],
);
}
}
| 0 |
mirrored_repositories/quiz_app/lib | mirrored_repositories/quiz_app/lib/questions_summary/question_identifier.dart | import 'package:flutter/material.dart';
class QuestionIdentifier extends StatelessWidget {
const QuestionIdentifier(
{super.key, required this.questionIndex, required this.isCorrectAnswer});
final int questionIndex;
final bool isCorrectAnswer;
@override
Widget build(BuildContext context) {
final questionNumber = questionIndex + 1;
return Container(
width: 30,
height: 30,
alignment: Alignment.center,
decoration: BoxDecoration(
color: isCorrectAnswer
? const Color.fromARGB(255, 150, 190, 241)
: const Color.fromARGB(255, 249, 133, 241),
borderRadius: BorderRadius.circular(100),
),
child: Text(
questionNumber.toString(),
style: const TextStyle(
fontWeight: FontWeight.bold, color: Color.fromARGB(255, 22, 2, 56)),
),
);
}
}
| 0 |
mirrored_repositories/quiz_app | mirrored_repositories/quiz_app/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 in the flutter_test package. 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:quiz/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const 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/objectbox_flutter | mirrored_repositories/objectbox_flutter/lib/main.dart | import 'package:faker/faker.dart';
import 'package:flutter/material.dart';
import 'package:objectbox_flutter/helper/object_box.dart';
import 'package:objectbox_flutter/model/user.dart';
late ObjectBox objectBox;
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
objectBox = await ObjectBox.init();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) => MaterialApp(
title: 'ObjectBox',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorSchemeSeed: Colors.cyan,
textTheme: const TextTheme(
bodyText2: TextStyle(fontSize: 20),
subtitle1: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
),
),
home: const Homepage(),
);
}
class Homepage extends StatefulWidget {
const Homepage({Key? key}) : super(key: key);
@override
State<Homepage> createState() => _HomepageState();
}
class _HomepageState extends State<Homepage> {
late Stream<List<User>> streamUsers;
@override
void initState() {
super.initState();
streamUsers = objectBox.getUsers();
}
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: const Text('ObjectBox'),
centerTitle: true,
),
body: StreamBuilder<List<User>>(
stream: streamUsers,
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const Center(
child: CircularProgressIndicator(),
);
} else {
final users = snapshot.data!;
return ListView.builder(
itemCount: users.length,
itemBuilder: (context, index) {
final user = users[index];
return ListTile(
title: Text(user.name),
subtitle: Text(user.email),
trailing: IconButton(
icon: const Icon(Icons.delete),
onPressed: () => objectBox.deleteUser(user.id),
),
onTap: () {
user.name = Faker().person.firstName();
user.email = Faker().internet.email();
objectBox.insertUser(user);
},
);
},
);
}
},
),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.add),
onPressed: () {
final user = User(
name: Faker().person.firstName(),
email: Faker().internet.email(),
);
objectBox.insertUser(user);
},
),
);
}
| 0 |
mirrored_repositories/objectbox_flutter | mirrored_repositories/objectbox_flutter/lib/objectbox.g.dart | // GENERATED CODE - DO NOT MODIFY BY HAND
// This code was generated by ObjectBox. To update it run the generator again:
// With a Flutter package, run `flutter pub run build_runner build`.
// With a Dart package, run `dart run build_runner build`.
// See also https://docs.objectbox.io/getting-started#generate-objectbox-code
// ignore_for_file: camel_case_types
import 'dart:typed_data';
import 'package:flat_buffers/flat_buffers.dart' as fb;
import 'package:objectbox/internal.dart'; // generated code can access "internal" functionality
import 'package:objectbox/objectbox.dart';
import 'package:objectbox_sync_flutter_libs/objectbox_sync_flutter_libs.dart';
import 'model/user.dart';
export 'package:objectbox/objectbox.dart'; // so that callers only have to import this file
final _entities = <ModelEntity>[
ModelEntity(
id: const IdUid(1, 2715258522039437150),
name: 'User',
lastPropertyId: const IdUid(3, 6375546693358906750),
flags: 2,
properties: <ModelProperty>[
ModelProperty(
id: const IdUid(1, 2402090701265386305),
name: 'id',
type: 6,
flags: 1),
ModelProperty(
id: const IdUid(2, 8645800130043026205),
name: 'name',
type: 9,
flags: 0),
ModelProperty(
id: const IdUid(3, 6375546693358906750),
name: 'email',
type: 9,
flags: 0)
],
relations: <ModelRelation>[],
backlinks: <ModelBacklink>[])
];
/// Open an ObjectBox store with the model declared in this file.
Future<Store> openStore(
{String? directory,
int? maxDBSizeInKB,
int? fileMode,
int? maxReaders,
bool queriesCaseSensitiveDefault = true,
String? macosApplicationGroup}) async =>
Store(getObjectBoxModel(),
directory: directory ?? (await defaultStoreDirectory()).path,
maxDBSizeInKB: maxDBSizeInKB,
fileMode: fileMode,
maxReaders: maxReaders,
queriesCaseSensitiveDefault: queriesCaseSensitiveDefault,
macosApplicationGroup: macosApplicationGroup);
/// ObjectBox model definition, pass it to [Store] - Store(getObjectBoxModel())
ModelDefinition getObjectBoxModel() {
final model = ModelInfo(
entities: _entities,
lastEntityId: const IdUid(1, 2715258522039437150),
lastIndexId: const IdUid(0, 0),
lastRelationId: const IdUid(0, 0),
lastSequenceId: const IdUid(0, 0),
retiredEntityUids: const [],
retiredIndexUids: const [],
retiredPropertyUids: const [],
retiredRelationUids: const [],
modelVersion: 5,
modelVersionParserMinimum: 5,
version: 1);
final bindings = <Type, EntityDefinition>{
User: EntityDefinition<User>(
model: _entities[0],
toOneRelations: (User object) => [],
toManyRelations: (User object) => {},
getId: (User object) => object.id,
setId: (User object, int id) {
object.id = id;
},
objectToFB: (User object, fb.Builder fbb) {
final nameOffset = fbb.writeString(object.name);
final emailOffset = fbb.writeString(object.email);
fbb.startTable(4);
fbb.addInt64(0, object.id);
fbb.addOffset(1, nameOffset);
fbb.addOffset(2, emailOffset);
fbb.finish(fbb.endTable());
return object.id;
},
objectFromFB: (Store store, ByteData fbData) {
final buffer = fb.BufferContext(fbData);
final rootOffset = buffer.derefObject(0);
final object = User(
id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
name: const fb.StringReader(asciiOptimization: true)
.vTableGet(buffer, rootOffset, 6, ''),
email: const fb.StringReader(asciiOptimization: true)
.vTableGet(buffer, rootOffset, 8, ''));
return object;
})
};
return ModelDefinition(model, bindings);
}
/// [User] entity fields to define ObjectBox queries.
class User_ {
/// see [User.id]
static final id = QueryIntegerProperty<User>(_entities[0].properties[0]);
/// see [User.name]
static final name = QueryStringProperty<User>(_entities[0].properties[1]);
/// see [User.email]
static final email = QueryStringProperty<User>(_entities[0].properties[2]);
}
| 0 |
mirrored_repositories/objectbox_flutter/lib | mirrored_repositories/objectbox_flutter/lib/model/user.dart | import 'package:objectbox/objectbox.dart';
@Entity()
@Sync()
class User {
int id;
String name;
String email;
User({
this.id = 0,
required this.name,
required this.email,
});
}
| 0 |
mirrored_repositories/objectbox_flutter/lib | mirrored_repositories/objectbox_flutter/lib/helper/object_box.dart | import 'dart:io';
import '../model/user.dart';
import '../objectbox.g.dart';
class ObjectBox {
late final Store _store;
late final Box<User> _userBox;
ObjectBox._init(this._store) {
_userBox = Box<User>(_store);
}
static Future<ObjectBox> init() async {
final store = await openStore();
if (Sync.isAvailable()) {
/// Or use the ip address of your server
//final ipSyncServer = '123.456.789.012';
final ipSyncServer = Platform.isAndroid ? '10.0.2.2' : '127.0.0.1';
final syncClient = Sync.client(
store,
'ws://$ipSyncServer:9999',
SyncCredentials.none(),
);
syncClient.connectionEvents.listen(print);
syncClient.start();
}
return ObjectBox._init(store);
}
User? getUser(int id) => _userBox.get(id);
Stream<List<User>> getUsers() => _userBox
.query()
.watch(triggerImmediately: true)
.map((query) => query.find());
int insertUser(User user) => _userBox.put(user);
bool deleteUser(int id) => _userBox.remove(id);
}
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.