repo_id
stringlengths 21
168
| file_path
stringlengths 36
210
| content
stringlengths 1
9.98M
| __index_level_0__
int64 0
0
|
|---|---|---|---|
mirrored_repositories/flutter_course_app/lib
|
mirrored_repositories/flutter_course_app/lib/screeens/profile_Screen.dart
|
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_course_app/components/certificate_viewer.dart';
import 'package:flutter_course_app/components/lists/completed_courses_list.dart';
import 'package:flutter_course_app/constants.dart';
class ProfileScreen extends StatelessWidget {
final List<String> badges = [
'badge-01.png',
'badge-02.png',
'badge-03.png',
'badge-04.png',
];
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: kBackgroundColor,
body: SingleChildScrollView(
child: Column(
children: [
Container(
decoration: const BoxDecoration(
color: kCardPopupBackgroundColor,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(34.0),
),
boxShadow: [
BoxShadow(
color: kShadowColor,
offset: Offset(0, 12),
blurRadius: 32.0,
),
],
),
child: SafeArea(
bottom: false,
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(
top: 24.0,
bottom: 32.0,
left: 20.0,
right: 20.0,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
RawMaterialButton(
materialTapTargetSize:
MaterialTapTargetSize.shrinkWrap,
constraints: const BoxConstraints(
minWidth: 40.0,
maxWidth: 40.0,
maxHeight: 24.0),
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
onPressed: () {
Navigator.of(context).pop();
},
child: const Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(
Icons.arrow_back,
color: kSecondaryLabelColor,
),
],
),
),
Text(
"Profile",
style: kCalloutLabelStyle,
),
Container(
width: 40.0,
height: 40.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14.0),
boxShadow: const [
BoxShadow(
color: kShadowColor,
offset: Offset(0, 12),
blurRadius: 32.0,
)
]),
child: const Icon(
Icons.settings,
color: kSecondaryLabelColor,
),
)
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Row(
children: [
Container(
height: 84.0,
width: 84.0,
decoration: BoxDecoration(
gradient: const RadialGradient(
colors: [
Color(0xFF00AEFF),
Color(0xFF0076FF),
],
),
borderRadius: BorderRadius.circular(42.0),
),
child: Padding(
padding: EdgeInsets.all(6.0),
child: Container(
padding: EdgeInsets.all(6.0),
decoration: BoxDecoration(
color: kBackgroundColor,
borderRadius: BorderRadius.circular(42.0),
),
child: const CircleAvatar(
backgroundImage:
AssetImage('asset/images/profile.jpg'),
radius: 30.0,
),
),
),
),
const SizedBox(width: 16.0),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"ArShiajs",
style: kTitle2Style,
),
const SizedBox(height: 8.0),
Text(
"Flutter Developer",
style: kSecondaryCalloutLabelStyle,
),
],
),
],
),
),
Padding(
padding: const EdgeInsets.only(top: 28.0, bottom: 16.0),
child: Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Badges",
style: kHeadlineLabelStyle,
),
Row(
children: [
Text(
"See all",
style: kSearchPlaceholderStyle,
),
const Icon(
Icons.chevron_right,
color: kSecondaryLabelColor,
),
],
)
],
),
),
],
),
),
const SizedBox(
height: 16.0,
),
Container(
height: 112.0,
child: ListView.builder(
padding: const EdgeInsets.only(bottom: 28.0),
scrollDirection: Axis.horizontal,
itemCount: badges.length,
itemBuilder: (context, index) {
return Container(
padding: EdgeInsets.only(
left: 20.0, right: index != 3 ? 0.0 : 20.0),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: kShadowColor.withOpacity(0.1),
offset: Offset(0, 12),
blurRadius: 18.0,
),
],
),
child: Image.asset('asset/badges/${badges[index]}'),
);
},
),
)
],
),
),
),
Padding(
padding: const EdgeInsets.only(
top: 22.0,
left: 20.0,
right: 20.0,
bottom: 12.0,
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Certificates",
style: kHeadlineLabelStyle,
),
Row(
children: [
Text(
"See all",
style: kSearchPlaceholderStyle,
),
const Icon(Icons.chevron_right,
color: kSecondaryLabelColor),
],
),
],
),
],
),
),
CertificateViewer(),
Padding(
padding: const EdgeInsets.only(
left: 20.0,
right: 20.0,
bottom: 12.0,
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Completed Courses",
style: kHeadlineLabelStyle,
),
Row(
children: [
Text(
"See all",
style: kSearchPlaceholderStyle,
),
const Icon(Icons.chevron_right,
color: kSecondaryLabelColor),
],
),
],
),
],
),
),
CompletedCoursesList(),
const SizedBox(
height: 18.0,
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/flutter_course_app/lib
|
mirrored_repositories/flutter_course_app/lib/components/home_screen_navbar.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_course_app/components/searchfield_widget.dart';
import 'package:flutter_course_app/components/sidebar_button.dart';
import 'package:flutter_course_app/constants.dart';
import 'package:flutter_course_app/screeens/profile_Screen.dart';
class HomeScreenNavBar extends StatelessWidget {
HomeScreenNavBar({super.key, required this.triggerAnimation});
final Function triggerAnimation;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SideBarButton(triggerAnimation: triggerAnimation),
SearchFieldWidget(),
const Icon(Icons.notifications, color: kPrimaryLabelColor,),
const SizedBox(width: 16,),
GestureDetector(
onTap: (){
Navigator.of(context).push(MaterialPageRoute(builder: (context) => ProfileScreen()));
},
child: const CircleAvatar(
radius: 25,
backgroundImage: AssetImage('asset/images/profile.jpg',),
),
)
],
),
);
}
}
| 0
|
mirrored_repositories/flutter_course_app/lib
|
mirrored_repositories/flutter_course_app/lib/components/searchfield_widget.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_course_app/constants.dart';
class SearchFieldWidget extends StatelessWidget {
const SearchFieldWidget({super.key});
@override
Widget build(BuildContext context) {
return Expanded
(child: Padding(
padding: const EdgeInsets.only(left: 12.0, right: 32),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
boxShadow: const [
BoxShadow(
color: kShadowColor,
offset: Offset(0,12),
blurRadius: 16
)
]
),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0),
child: TextField(
cursorColor: kPrimaryLabelColor,
decoration: InputDecoration(
icon: Icon(Icons.search, color: kPrimaryLabelColor, size: 20,),
border: InputBorder.none,
hintText: "Search for courses",
hintStyle: kSearchPlaceholderStyle,
),
style: kSearchTextStyle,
onChanged: (newText){
print(newText);
},
),
),
),
)
);
}
}
| 0
|
mirrored_repositories/flutter_course_app/lib
|
mirrored_repositories/flutter_course_app/lib/components/sidebar_row.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_course_app/constants.dart';
import 'package:flutter_course_app/model/sidebar.dart';
class SidebarRow extends StatelessWidget {
SidebarRow({required this.item});
final SidebarItem item;
@override
Widget build(BuildContext context) {
return Row(
children: [
Container(
width: 42,
height: 42,
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
gradient: item.background,
),
child: item.icon,
),
const SizedBox(width: 12,),
Container(child: Text(item.title, style: kCalloutLabelStyle))
],
);
}
}
| 0
|
mirrored_repositories/flutter_course_app/lib
|
mirrored_repositories/flutter_course_app/lib/components/certificate_viewer.dart
|
import 'dart:math';
import 'package:flutter/material.dart';
class CertificateViewer extends StatefulWidget {
const CertificateViewer({super.key});
@override
State<CertificateViewer> createState() => _CertificateViewerState();
}
class _CertificateViewerState extends State<CertificateViewer> {
final List<String> certificatePaths = [
'asset/certificates/certificate-01.png',
'asset/certificates/certificate-02.png',
'asset/certificates/certificate-03.png',
];
late Widget certificatedViewer;
@override
void initState() {
// TODO: implement initState
super.initState();
List<Widget> imageChildren = [];
certificatePaths.reversed.toList().asMap().forEach((index , certificate) {
int angleDegree;
if (index == certificatePaths.length - 1){
angleDegree = 0;
}else{
angleDegree = Random().nextInt(10)-5;
}
imageChildren.add(
Transform.rotate(
angle: angleDegree * (pi/100),
child: Image.asset(certificate, alignment: Alignment.center, fit: BoxFit.cover,)));
});
certificatedViewer = Stack(children: imageChildren,);
}
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(top: 20),
child: certificatedViewer,
);
}
}
| 0
|
mirrored_repositories/flutter_course_app/lib
|
mirrored_repositories/flutter_course_app/lib/components/sidebar_button.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_course_app/constants.dart';
class SideBarButton extends StatelessWidget {
const SideBarButton({
super.key, required this.triggerAnimation,
});
final Function triggerAnimation;
@override
Widget build(BuildContext context) {
return RawMaterialButton(
// this is for: when taping the buttom, it done just for bottom
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
constraints: const BoxConstraints(
maxHeight: 40,
maxWidth: 40
),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
boxShadow: const [
BoxShadow(
color: kShadowColor,
offset: Offset(0, 12),
blurRadius: 16,
)
]
),
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 14),
child: Image.asset(
'asset/icons/icon-sidebar.png',
color: kPrimaryLabelColor,
),
),
onPressed: (){
triggerAnimation();
},
);
}
}
| 0
|
mirrored_repositories/flutter_course_app/lib
|
mirrored_repositories/flutter_course_app/lib/components/completed_courses_card.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_course_app/model/course.dart';
import '../../constants.dart';
class CompletedCoursesCard extends StatelessWidget {
CompletedCoursesCard({required this.course});
final Course course;
@override
Widget build(BuildContext context) {
return Container(
child: Stack(
alignment: Alignment.topRight,
children: [
Padding(
padding: const EdgeInsets.only(
top: 20.0,
right: 20.0,
),
child: Container(
decoration: BoxDecoration(
gradient: course.background,
borderRadius: BorderRadius.circular(41.0),
boxShadow: [
BoxShadow(
color: course.background.colors[0].withOpacity(0.3),
offset: Offset(0, 20),
blurRadius: 20.0,
),
BoxShadow(
color: course.background.colors[1].withOpacity(0.3),
offset: Offset(0, 20),
blurRadius: 20.0,
)
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(41.0),
child: Container(
height: 140.0,
width: 260.0,
child: Stack(
children: [
Row(
children: [
Spacer(),
Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Image.asset(
'asset/illustrations/${course.illustration}',
fit: BoxFit.cover,
height: 140,
),
],
),
],
),
Padding(
padding: EdgeInsets.all(32.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
course.courseSubtitle,
style: kCardSubtitleStyle,
),
const SizedBox(
height: 6.0,
),
Text(
course.courseTitle,
style: kCardTitleStyle,
),
],
),
),
],
),
),
),
),
),
Container(
width: 60.0,
height: 60.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16.0),
boxShadow: const [
BoxShadow(
color: kShadowColor,
offset: Offset(0, 4),
blurRadius: 16.0,
),
],
),
padding: const EdgeInsets.only(
top: 12.5,
bottom: 13.5,
left: 20.5,
right: 14.5,
),
child: Image.asset('asset/icons/icon-play.png'),
),
],
),
);
}
}
| 0
|
mirrored_repositories/flutter_course_app/lib/components
|
mirrored_repositories/flutter_course_app/lib/components/cards/continue_watching_card.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_course_app/constants.dart';
import 'package:flutter_course_app/model/course.dart';
class ContinueWatchingCard extends StatelessWidget {
ContinueWatchingCard({super.key, required this.course});
final Course course;
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.topCenter,
child: Padding(
padding: const EdgeInsets.only(right: 20.0, top: 20),
child: ClipRRect(
borderRadius: BorderRadius.circular(41),
child: Container(
height: 180,
width: 350,
decoration: BoxDecoration(
gradient: course.background,
),
child: Padding
(padding: EdgeInsets.only(left: 32),
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(course.courseSubtitle, style: kCardSubtitleStyle,),
SizedBox(height: 6,),
Text(course.courseTitle, style: kCardTitleStyle,)
],
)),
Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Image.asset('asset/illustrations/${course.illustration}', fit: BoxFit.cover, height: 100,)
],
)
],
),
),
),
),
),
);
}
}
| 0
|
mirrored_repositories/flutter_course_app/lib/components
|
mirrored_repositories/flutter_course_app/lib/components/cards/recent_course_card.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_course_app/constants.dart';
import 'package:flutter_course_app/model/course.dart';
class RecentCourseCard extends StatelessWidget {
RecentCourseCard({required this.course});
Course course;
@override
Widget build(BuildContext context) {
return Stack(
alignment: Alignment.topRight,
children: [
Padding(
padding: const EdgeInsets.only(top: 20.0),
child: Container(
width: 240,
height: 240,
decoration: BoxDecoration(
gradient: course.background,
borderRadius: BorderRadius.circular(41),
boxShadow: [
BoxShadow(
color: course.background.colors[0].withOpacity(0.3),
offset: const Offset(0, 20),
blurRadius: 30
),
BoxShadow(
color: course.background.colors[1].withOpacity(0.3),
offset: const Offset(0, 20),
blurRadius: 30
),
]
),
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 32, left: 32, right: 32),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Hero(
tag: course.courseSubtitle,
child: Text(course.courseSubtitle, style: kCardSubtitleStyle,)),
const SizedBox(height: 6,),
Hero(
tag: course.courseTitle,
child: Text(course.courseTitle, style: kCardTitleStyle,)),
],
),
),
Expanded(
child: Hero(
tag: course.illustration,
child: Image.asset('asset/illustrations/${course.illustration}',
fit: BoxFit.cover,),
)),
],
),
),
),
Padding(
padding: const EdgeInsets.only(
right: 42,
),
child: Container(
width: 60,
height: 60,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(18),
boxShadow: const [
BoxShadow(
color: kShadowColor,
offset: Offset(0, 4),
blurRadius: 16
)
]
),
padding: const EdgeInsets.all(8),
child: Hero(
tag: course.logo,
child: Image.asset('asset/logos/${course.logo}')),
),
)
],
);
}
}
| 0
|
mirrored_repositories/flutter_course_app/lib/components
|
mirrored_repositories/flutter_course_app/lib/components/cards/explore_course_card.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_course_app/constants.dart';
import 'package:flutter_course_app/model/course.dart';
class ExploreCourseCard extends StatelessWidget {
ExploreCourseCard({super.key, required this.course});
final Course course;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(right: 20.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(41),
child: Container(
height: 120,
width: 280,
decoration: BoxDecoration(
gradient: course.background,
),
child: Padding
(padding: EdgeInsets.only(left: 32),
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(course.courseSubtitle, style: kCardSubtitleStyle,),
SizedBox(height: 6,),
Text(course.courseTitle, style: kCardTitleStyle,)
],
)),
Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Image.asset('asset/illustrations/${course.illustration}', fit: BoxFit.cover, height: 100,)
],
)
],
),
),
),
),
);
}
}
| 0
|
mirrored_repositories/flutter_course_app/lib/components
|
mirrored_repositories/flutter_course_app/lib/components/cards/course_sections_card.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_course_app/constants.dart';
import 'package:flutter_course_app/model/course.dart';
class CourseSectionCard extends StatelessWidget {
final Course course;
CourseSectionCard({super.key, required this.course});
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 20.0),
child: Container(
height: 120,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(41),
gradient: course.background,
boxShadow: [
BoxShadow(
color: course.background.colors[0].withOpacity(0.3),
blurRadius: 30,
offset: Offset(0, 20),
),
BoxShadow(
color: course.background.colors[1].withOpacity(0.3),
blurRadius: 30,
offset: Offset(0, 20),
),
]
),
child: ClipRRect(
borderRadius: BorderRadius.circular(41),
child: Padding(padding: EdgeInsets.only(left: 32),
child: Stack(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Image.asset('asset/illustrations/${course.illustration}', fit: BoxFit.cover,),
],
),
Row(
children: [
Expanded(child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(course.courseSubtitle, style: kCardSubtitleStyle,),
SizedBox(height: 6,),
Text(course.courseTitle, style: kCardTitleStyle,),
],
),
),
Spacer()
],
)
],
),),
),
),
);
}
}
| 0
|
mirrored_repositories/flutter_course_app/lib/components
|
mirrored_repositories/flutter_course_app/lib/components/lists/completed_courses_list.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_course_app/components/completed_courses_card.dart';
import 'package:flutter_course_app/model/course.dart';
class CompletedCoursesList extends StatefulWidget {
@override
_CompletedCoursesListState createState() => _CompletedCoursesListState();
}
class _CompletedCoursesListState extends State<CompletedCoursesList> {
List<Container> indicators = [];
int currentPage = 0;
Widget updateIndicators() {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: completedCourses.map((course) {
var index = completedCourses.indexOf(course);
return Container(
width: 7.0,
height: 7.0,
margin: EdgeInsets.symmetric(horizontal: 6.0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color:
currentPage == index ? Color(0xFF0971FE) : Color(0xFFA6AEBD)),
);
}).toList(),
);
}
@override
Widget build(BuildContext context) {
return Column(
children: [
Container(
height: 200.0,
width: double.infinity,
child: PageView.builder(
itemBuilder: (context, index) {
return Opacity(
opacity: currentPage == index ? 1.0 : 0.5,
child: CompletedCoursesCard(
course: completedCourses[index],
));
},
itemCount: completedCourses.length,
onPageChanged: (index) {
setState(() {
currentPage = index;
});
},
controller: PageController(initialPage: 0, viewportFraction: 0.75),
),
),
updateIndicators(),
],
);
}
}
| 0
|
mirrored_repositories/flutter_course_app/lib/components
|
mirrored_repositories/flutter_course_app/lib/components/lists/explore_course_list.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_course_app/components/cards/explore_course_card.dart';
import 'package:flutter_course_app/model/course.dart';
class ExploreCourseList extends StatelessWidget {
const ExploreCourseList ({super.key});
@override
Widget build(BuildContext context) {
return Container(
height: 120,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
padding: EdgeInsets.only(left: 20),
physics: BouncingScrollPhysics(),
itemCount: exploreCourses.length,
itemBuilder: (context, index){
return ExploreCourseCard(course:exploreCourses[index],);
},
),
);
}
}
| 0
|
mirrored_repositories/flutter_course_app/lib/components
|
mirrored_repositories/flutter_course_app/lib/components/lists/continue_watching_list.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_course_app/components/cards/continue_watching_card.dart';
import 'package:flutter_course_app/model/course.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
class ContinueWatchingList extends StatefulWidget {
const ContinueWatchingList({super.key});
@override
State<ContinueWatchingList> createState() => _ContinueWatchingListState();
}
class _ContinueWatchingListState extends State<ContinueWatchingList> {
final PageController _pageController = PageController(
initialPage: 0,
);
@override
Widget build(BuildContext context) {
return Column(
children: [
Container(
height: 200,
width: double.infinity,
child: PageView.builder(
controller: _pageController,
itemCount: continueWatchingCourses.length,
itemBuilder: (context, index){
return ContinueWatchingCard(course: continueWatchingCourses[index]);
}
),
),
SizedBox(height: 20,),
SmoothPageIndicator(
effect: JumpingDotEffect(activeDotColor: Colors.blueAccent),
controller: _pageController,
count: recentCourses.length,
),
],
);
}
}
| 0
|
mirrored_repositories/flutter_course_app/lib/components
|
mirrored_repositories/flutter_course_app/lib/components/lists/course_sections_list.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_course_app/components/cards/course_sections_card.dart';
import 'package:flutter_course_app/constants.dart';
import 'package:flutter_course_app/model/course.dart';
class CourseSectionList extends StatelessWidget {
List<Widget> courseSectionsWidgets(){
List<Widget> cards = [];
for (var course in courseSections){
cards.add(
Padding(padding: EdgeInsets.only(bottom: 20),
child: CourseSectionCard(course: course),
)
);
}
cards.add(
Padding(padding: EdgeInsets.only(top: 12, bottom: 20),
child: Text("No more Sections to view", style: kSubtitleStyle, textAlign: TextAlign.center,),
)
);
return cards;
}
const CourseSectionList({super.key});
@override
Widget build(BuildContext context) {
return Expanded(child: ListView(
children: courseSectionsWidgets(),
));
}
}
| 0
|
mirrored_repositories/flutter_course_app/lib/components
|
mirrored_repositories/flutter_course_app/lib/components/lists/recent_coruse_list.dart
|
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_course_app/components/cards/recent_course_card.dart';
import 'package:flutter_course_app/model/course.dart';
import 'package:flutter_course_app/screeens/course_screen.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
class RecentCourseList extends StatefulWidget {
const RecentCourseList({super.key});
@override
State<RecentCourseList> createState() => _RecentCourseListState();
}
class _RecentCourseListState extends State<RecentCourseList> {
final PageController _pageController = PageController(
viewportFraction: 0.65,
initialPage: 0,
);
@override
Widget build(BuildContext context) {
return Column(
children: [
Container(
height: 320,
width: double.infinity,
child: PageView.builder(
itemBuilder: (context, index){
return GestureDetector(
onTap: (){
Navigator.push(context, MaterialPageRoute(
fullscreenDialog: true,
builder: (context) => CourseScreen(course: recentCourses[index],)));
},
child: RecentCourseCard(course: recentCourses[index]));
},
itemCount: recentCourses.length,
controller: _pageController,
),
),
SmoothPageIndicator(
effect: JumpingDotEffect(activeDotColor: Colors.blueAccent),
controller: _pageController,
count: recentCourses.length,
),
],
);
}
}
| 0
|
mirrored_repositories/flutter_course_app/lib
|
mirrored_repositories/flutter_course_app/lib/model/course.dart
|
import 'package:flutter/material.dart';
class Course {
Course({
required this.courseTitle,
required this.courseSubtitle,
required this.background,
required this.illustration,
required this.logo,
});
String courseTitle;
String courseSubtitle;
LinearGradient background;
String illustration;
String logo;
}
// Recent Courses
var recentCourses = [
Course(
courseTitle: "Flutter for Designers",
courseSubtitle: "12 sections",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFF00AEFF),
Color(0xFF0076FF),
],
),
illustration: 'illustration-01.png',
logo: 'flutter-logo.png',
),
Course(
courseTitle: "Prototyping with ProtoPie",
courseSubtitle: "10 sections",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFFFD504F),
Color(0xFFFF8181),
],
),
illustration: 'illustration-02.png',
logo: 'protopie-logo.png',
),
Course(
courseTitle: "Build an app with SwiftUI",
courseSubtitle: "22 sections",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFF00E1EE),
Color(0xFF001392),
],
),
illustration: 'illustration-03.png',
logo: 'swift-logo.png',
),
];
// Explore Courses
var exploreCourses = [
Course(
logo: 'swift-logo.png',
courseTitle: "Build an app with SwiftUI",
courseSubtitle: "22 sections",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFF5BCEA6),
Color(0xFF1997AB),
],
),
illustration: 'illustration-04.png',
),
Course(
logo: 'swift-logo.png',
courseTitle: "Build an app with SwiftUI",
courseSubtitle: "22 sections",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFFA931E5),
Color(0xFF4B02FE),
],
),
illustration: 'illustration-05.png',
),
Course(
logo: 'swift-logo.png',
courseTitle: "Build an app with SwiftUI",
courseSubtitle: "22 sections",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFF5BCEA6),
Color(0xFF1997AB),
],
),
illustration: 'illustration-04.png',
),
Course(
logo: 'swift-logo.png',
courseTitle: "Build an app with SwiftUI",
courseSubtitle: "22 sections",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFFA931E5),
Color(0xFF4B02FE),
],
),
illustration: 'illustration-05.png',
),
];
// Continue Watching Courses
var continueWatchingCourses = [
Course(
logo: 'swift-logo.png',
courseTitle: "React for Designers",
courseSubtitle: "SVG Animations",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFF4E62CC),
Color(0xFF202A78),
],
),
illustration: 'illustration-06.png',
),
Course(
logo: 'swift-logo.png',
courseTitle: "Animating in Principle",
courseSubtitle: "Multiple Scrolling",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFFFA7D75),
Color(0xFFC23D61),
],
),
illustration: 'illustration-07.png',
),
Course(
logo: 'swift-logo.png',
courseTitle: "Animating in Principle",
courseSubtitle: "Multiple Scrolling",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFFFA7D75),
Color(0xFFC23D61),
],
),
illustration: 'illustration-07.png',
),
];
// Course Sections
var courseSections = [
Course(
logo: 'swift-logo.png',
courseTitle: "Build an app with SwiftUI",
courseSubtitle: "01 Section",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFF00AEFF),
Color(0xFF0076FF),
],
),
illustration: 'illustration-01.png',
),
Course(
logo: 'swift-logo.png',
courseTitle: "Flutter for Designers",
courseSubtitle: "02 Section",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFFE477AE),
Color(0xFFC54284),
],
),
illustration: 'illustration-08.png',
),
Course(
logo: 'swift-logo.png',
courseTitle: "ProtoPie Prototyping",
courseSubtitle: "03 Section",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFFEA7E58),
Color(0xFFCE4E27),
],
),
illustration: 'illustration-09.png',
),
Course(
logo: 'swift-logo.png',
courseTitle: "UI Design Course",
courseSubtitle: "04 Section",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFF72CFD4),
Color(0xFF42A0C2),
],
),
illustration: 'illustration-10.png',
),
Course(
logo: 'swift-logo.png',
courseTitle: "React for Designers",
courseSubtitle: "05 Section",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFFFF2E56),
Color(0xFFCB012B),
],
),
illustration: 'illustration-11.png',
),
];
// Completed Courses
var completedCourses = [
Course(
logo: 'swift-logo.png',
courseTitle: "Build an ARKit 2 App",
courseSubtitle: "Certified",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFFFF6B94),
Color(0xFF6B2E98),
],
),
illustration: 'illustration-12.png',
),
Course(
logo: 'swift-logo.png',
courseTitle: "Swift Advanced",
courseSubtitle: "Yet to be Certified",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFFDEC8FA),
Color(0xFF4A1B6D),
],
),
illustration: 'illustration-13.png',
),
];
| 0
|
mirrored_repositories/flutter_course_app/lib
|
mirrored_repositories/flutter_course_app/lib/model/sidebar.dart
|
import 'package:flutter/material.dart';
class SidebarItem {
SidebarItem({required this.title, required this.background, required this.icon});
String title;
LinearGradient background;
Icon icon;
}
var sidebarItem = [
SidebarItem(
title: "Home" ,
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFF00AEFF),
Color(0xFF0076FF),
],
),
icon: const Icon(
Icons.home,
color: Colors.white,
),
),
SidebarItem(
title: "Courses",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Color(0xFFFA7d75), Color(0xFFC23D61)]),
icon: const Icon(
Icons.library_books ,
color: Colors.white,
),
),
SidebarItem(
title: "Billing",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Color(0xFFFAD64A), Color(0xFFEA880F)]),
icon: const Icon(
Icons.credit_card,
color: Colors.white,
),
),
SidebarItem(
title: "Settings",
background: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Color(0xFF4E62CC), Color(0xFF202A78)],
),
icon: const Icon(
Icons.settings ,
color: Colors.white,
),
),
];
| 0
|
mirrored_repositories/flutter_course_app
|
mirrored_repositories/flutter_course_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:flutter_course_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/birdbrain
|
mirrored_repositories/birdbrain/lib/login.dart
|
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'main.dart';
class LoginPage extends StatefulWidget {
@override
_LoginPageState createState() => new _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
@override
Widget build(BuildContext context) {
final logo = Hero(
tag: 'hero',
child: CircleAvatar(
backgroundColor: Colors.transparent,
radius: 60.0,
child: Image.asset('assets/picture.png'),
),
);
final email = TextFormField(
keyboardType: TextInputType.emailAddress,
autofocus: false,
decoration: InputDecoration(
hintText: 'Email',
contentPadding: EdgeInsets.fromLTRB(25.0, 10.0, 10.0, 20.0),
border:
OutlineInputBorder(borderRadius: BorderRadius.circular(23.0))),
);
final password = TextFormField(
autofocus: false,
obscureText: true,
decoration: InputDecoration(
hintText: 'Password',
contentPadding: EdgeInsets.fromLTRB(25.0, 10.0, 10.0, 20.0),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(23.0)),
),
);
final loginButton = new RaisedButton(
onPressed: () {
Navigator
.of(context)
.push(new MaterialPageRoute(builder: (context) => new HomePage()));
},
padding: EdgeInsets.symmetric(vertical: 16.0),
elevation: 2.0,
color: const Color.fromRGBO(224, 130, 132, 1.0),
shape: new RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(23.0)),
child: new Text(
'Sign In',
style: new TextStyle(
color: Colors.white,
fontSize: 15.0,
// fontFamily: ,
fontWeight: FontWeight.w600,
letterSpacing: 0.5,
),
),
);
final forgotLabel = FlatButton(
child: Text(
'Forgot Password?',
style: TextStyle(color: Colors.black54),
),
padding: EdgeInsets.only(top: 13.0, bottom: 10.0),
onPressed: () {},
);
final or = new Container(
alignment: FractionalOffset.center,
padding: const EdgeInsets.all(20.0),
child: new Text(
"- or sign in with - ",
style: TextStyle(color: Colors.black54),
),
);
// Widget facebook = new MaterialButton(
// height: 10.0,
// minWidth: 10.0,
// child: const Text('Connect with Facebook'),
// color: Theme.of(context).accentColor,
// elevation: 4.0,
// splashColor: Colors.blue,
// onPressed: () {},
// );
Widget google = new IconButton(
iconSize: 70.0,
icon: new Image.asset('assets/google.png'),
splashColor: Colors.white,
onPressed: () {},
);
Widget buildButton(IconData icon) {
final Color tintColor = Color.fromRGBO(224, 130, 132, 1.0);
return new Column(
children: <Widget>[
new Icon(icon, color: tintColor),
// new Container(
// decoration: new BoxDecoration(
// border: new Border.all(color: Color.fromRGBO(224, 130, 132, 1.0))
// ),
// )
],
);
}
Widget googlefacebook = new Container(
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[buildButton(Icons.favorite), google],
),
);
final register = FlatButton(
child: Text(
'Don\'t have an account? Sign Up',
style: TextStyle(color: Colors.black54),
),
padding: EdgeInsets.only(top: 10.0),
onPressed: () {},
);
return Scaffold(
backgroundColor: Colors.white,
body: Center(
child: ListView(
shrinkWrap: true,
padding: EdgeInsets.only(left: 24.0, right: 24.0),
children: <Widget>[
SizedBox(height: 40.0),
logo,
SizedBox(height: 40.0),
email,
SizedBox(height: 10.0),
password,
SizedBox(height: 25.0),
loginButton,
forgotLabel,
or,
SizedBox(height: 5.0),
googlefacebook,
register
],
),
),
);
}
}
| 0
|
mirrored_repositories/birdbrain
|
mirrored_repositories/birdbrain/lib/main.dart
|
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:quiz/home/homepagebody.dart';
import 'package:quiz/more/more.dart';
import 'package:quiz/settings/settingsbody.dart';
import 'login.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
return MaterialApp(
title: 'BirdBrain',
theme: ThemeData(
primaryColor: Color(0xFFE08284),
fontFamily: 'Numito',
),
home: LoginPage(),
);
}
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int currentTab = 0;
Home home;
Settings settings;
More more;
List<Widget> pages;
Widget currentPage;
@override
void initState() {
home = Home();
settings = Settings();
more = More();
pages = [home, settings, more];
currentPage = home;
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: currentPage,
bottomNavigationBar: BottomNavigationBar(
currentIndex: currentTab,
onTap: (int index) {
setState(() {
currentTab = index;
currentPage = pages[index];
});
},
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text("Home"),
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
title: Text("Account"),
),
BottomNavigationBarItem(
icon: Icon(Icons.attach_money),
title: Text("More"),
),
]),
);
}
}
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Column(
children: <Widget>[new HomePageBody()],
),
);
}
}
class Settings extends StatefulWidget {
@override
_SettingsState createState() => _SettingsState();
}
class _SettingsState extends State<Settings> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: new Column(
children: <Widget>[new SettingsBody()],
),
);
}
}
class More extends StatefulWidget {
@override
MoreState createState() => MoreState();
}
class MoreState extends State<More> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: new Column(
children: <Widget>[new MoreBody()],
),
);
}
}
| 0
|
mirrored_repositories/birdbrain/lib
|
mirrored_repositories/birdbrain/lib/question/dialog.dart
|
import 'package:flutter/material.dart';
import 'package:quiz/question/fastMoney/questionpage.dart';
import 'package:quiz/question/normalMode/questionscreen.dart';
class PopUp extends StatelessWidget {
@override
Widget build(BuildContext context) {
Widget normalmode = new FlatButton(
padding:
EdgeInsets.only(top: 50.0, bottom: 16.0, left: 20.0, right: 20.0),
child: Material(
borderRadius: BorderRadius.circular(17.0),
shadowColor: Color.fromRGBO(50, 50, 50, 0.2),
elevation: 10.0,
child: MaterialButton(
color: Colors.white,
minWidth: 300.0,
height: 80.0,
onPressed: () {
Navigator.of(context).push(new MaterialPageRoute(
builder: (context) => new QuestionPage()));
},
child: new Text("Normal Mode",
style: TextStyle(
color: Color(0xFFE08284),
fontWeight: FontWeight.w600,
fontSize: 25.0)),
),
),
);
Widget normaltext = new Container(
padding:
EdgeInsets.only(top: 10.0, bottom: 10.0, left: 40.0, right: 40.0),
child: new Text(
"Go through the question bank and answer as many questions as you like",
style: TextStyle(
letterSpacing: 1.0,
color: Colors.black54,
fontWeight: FontWeight.w600,
fontSize: 15.0),
),
);
final or = new Container(
alignment: FractionalOffset.center,
padding: const EdgeInsets.all(20.0),
child: new Text(
" or ",
style: TextStyle(color: Colors.black54),
),
);
Widget fastmoney = new FlatButton(
padding:
EdgeInsets.only(top: 16.0, bottom: 16.0, left: 20.0, right: 20.0),
child: Material(
borderRadius: BorderRadius.circular(17.0),
shadowColor: Color.fromRGBO(50, 50, 50, 0.2),
elevation: 10.0,
child: MaterialButton(
color: Colors.white,
minWidth: 300.0,
height: 80.0,
onPressed: () {
Navigator.of(context).push(new MaterialPageRoute(
builder: (context) => new FastQuestionPage()));
},
child: new Text("Fast Money",
style: TextStyle(
color: Color(0xFFE08284),
fontWeight: FontWeight.w600,
fontSize: 25.0)),
),
),
);
Widget fasttext = new Container(
padding:
EdgeInsets.only(top: 10.0, bottom: 10.0, left: 40.0, right: 40.0),
child: new Text(
"Race against time and see how many questions you can answer in 20 seconds",
style: TextStyle(
letterSpacing: 1.0,
color: Colors.black54,
fontWeight: FontWeight.w600,
fontSize: 15.0),
),
);
return new Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('Pick a Mode'),
elevation: 0.0,
),
body: new Container(
alignment: FractionalOffset.center,
child: new ListView(
scrollDirection: Axis.vertical,
children: <Widget>[normalmode, normaltext, or, fastmoney, fasttext],
),
),
);
}
}
| 0
|
mirrored_repositories/birdbrain/lib/question
|
mirrored_repositories/birdbrain/lib/question/normalMode/questionscreen.dart
|
import 'package:flutter/material.dart';
class QuestionPage extends StatefulWidget {
@override
_QuestionPageWidgetState createState() => _QuestionPageWidgetState();
}
class _QuestionPageWidgetState extends State<QuestionPage> {
int submit = 0;
int chosenAnswer;
@override
Widget build(BuildContext context) {
Widget nextQuestion = new RaisedButton(
padding: const EdgeInsets.all(10.0),
textColor: submit == 0 ? Colors.black12 : Colors.black,
child: const Text('Next Question'),
color: submit == 0 ? Color(0xFFE9E9E9) : Color(0xFFE08284),
elevation: submit == 0 ? 0.0 : 5.0,
onPressed: () {
Navigator.of(context).push(
new MaterialPageRoute(builder: (context) => new QuestionPage()));
submit = 0;
},
);
Widget submitAnswer = new RaisedButton(
padding: const EdgeInsets.all(10.0),
textColor: submit == 0 ? Colors.black : Colors.black12,
child: const Text('Submit Answer'),
color: submit == 0 ? Color(0xFFE08284) : Color(0xFFE9E9E9),
elevation: submit == 0 ? 5.0 : 0.0,
onPressed: () {
setState(() {
submit = 1;
});
},
);
return Scaffold(
body: new CustomScrollView(
slivers: <Widget>[
SliverAppBar(
centerTitle: true,
title: const Text('SUBJECT HERE'),
elevation: 0.0,
leading: new IconButton(
icon: new Icon(Icons.arrow_back, color: Colors.white),
onPressed: () => Navigator.popUntil(context, ModalRoute.withName('/'))
),
),
new SliverPadding(
padding: new EdgeInsets.all(0.0),
sliver: new SliverList(
delegate: new SliverChildListDelegate([
new Container(
height: 250.0,
padding: EdgeInsets.all(40.0),
decoration: new BoxDecoration(
borderRadius: new BorderRadius.only(
bottomLeft: const Radius.elliptical(200.0, 35.0),
bottomRight: const Radius.elliptical(200.0, 35.0)),
gradient: new LinearGradient(
colors: [
const Color(0xFFE08284),
const Color(0xFFF1BFB9),
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
stops: [0.0, 0.6],
tileMode: TileMode.clamp),
),
child: Text("QUESTION GOES HERE",
softWrap: true,
textAlign: TextAlign.center,
style: TextStyle(
color: Color(0xFFFFFFFF),
fontWeight: FontWeight.w600,
fontSize: 22.0)),
),
new Column(
children: <Widget>[
new FlatButton(
padding: EdgeInsets.only(
top: 40.0, bottom: 10.0, left: 20.0, right: 20.0),
child: Material(
borderRadius: BorderRadius.circular(17.0),
shadowColor: Color.fromRGBO(50, 50, 50, 0.2),
elevation: chosenAnswer == 1? 0.0: 1.0,
child: MaterialButton(
color: chosenAnswer == 1? Color(0xFFF1BFB9) : Colors.white,
minWidth: 300.0,
height: 70.0,
onPressed: () {
setState(() {
chosenAnswer = 1;
});
},
child: new Text("Answer 1",
style: TextStyle(
color: Color(0xFFE08284),
fontWeight: FontWeight.w600,
fontSize: 25.0)),
),
),
),
new FlatButton(
padding: EdgeInsets.only(
top: 10.0, bottom: 10.0, left: 20.0, right: 20.0),
child: Material(
borderRadius: BorderRadius.circular(17.0),
shadowColor: Color.fromRGBO(50, 50, 50, 0.2),
elevation: chosenAnswer == 2? 0.0: 1.0,
child: MaterialButton(
color: chosenAnswer == 2? Color(0xFFF1BFB9) : Colors.white,
minWidth: 300.0,
height: 70.0,
onPressed: () {
setState(() {
chosenAnswer = 2;
});
},
child: new Text("Answer 2",
style: TextStyle(
color: Color(0xFFE08284),
fontWeight: FontWeight.w600,
fontSize: 25.0)),
),
),
),
new FlatButton(
padding: EdgeInsets.only(
top: 10.0, bottom: 10.0, left: 20.0, right: 20.0),
child: Material(
borderRadius: BorderRadius.circular(17.0),
shadowColor: Color.fromRGBO(50, 50, 50, 0.2),
elevation: chosenAnswer == 3? 0.0: 1.0,
child: MaterialButton(
color: chosenAnswer == 3? Color(0xFFF1BFB9) : Colors.white,
minWidth: 300.0,
height: 70.0,
onPressed: () {
setState(() {
chosenAnswer = 3;
});
},
child: new Text("Answer 3",
style: TextStyle(
color: Color(0xFFE08284),
fontWeight: FontWeight.w600,
fontSize: 25.0)),
),
),
),
new FlatButton(
padding: EdgeInsets.only(
top: 10.0, bottom: 40.0, left: 20.0, right: 20.0),
child: Material(
borderRadius: BorderRadius.circular(17.0),
shadowColor: Color.fromRGBO(50, 50, 50, 0.2),
elevation: chosenAnswer == 4? 0.0: 1.0,
child: MaterialButton(
color: chosenAnswer == 4? Color(0xFFF1BFB9) : Colors.white,
minWidth: 300.0,
height: 70.0,
onPressed: () {
setState(() {
chosenAnswer = 4;
});
},
child: new Text("Answer 4",
style: TextStyle(
color: Color(0xFFE08284),
fontWeight: FontWeight.w600,
fontSize: 25.0)),
),
),
),
],
),
new Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisSize: MainAxisSize.min,
children: <Widget>[nextQuestion, submitAnswer]),
new SizedBox(height: 50.0),
submit == 1
? new Column(children: <Widget>[
new Container(
padding:
const EdgeInsets.only(top: 20.0, bottom: 20.0),
color: Color(0xFFF1BFB9),
child: new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text("Your Result",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 20.0)),
new SizedBox(height: 5.0),
new Text("Incorrect",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.w600,
fontSize: 17.0)),
new SizedBox(height: 20.0),
new Text("Your Pace",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 20.0)),
new SizedBox(height: 5.0),
new Text("2:09",
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.w600,
fontSize: 17.0)),
],
),
),
new Container(
padding: const EdgeInsets.only(
top: 40.0,
bottom: 40.0,
left: 30.0,
right: 30.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text("Explanation",
style: TextStyle(
color: Color(0xFFE08284),
fontWeight: FontWeight.w600,
fontSize: 25.0)),
new SizedBox(height: 20.0),
new Text(
"The heart is located at the center of the chest. Here, there is more information.",
textAlign: TextAlign.start,
style: TextStyle(
color: Color(0xFFE08284),
letterSpacing: 0.3,
fontWeight: FontWeight.w300,
fontSize: 17.0)),
]))
])
: new Container()
]),
),
),
],
),
);
}
}
| 0
|
mirrored_repositories/birdbrain/lib/question
|
mirrored_repositories/birdbrain/lib/question/fastMoney/questionpage.dart
|
import 'package:flutter/material.dart';
class FastQuestionPage extends StatefulWidget {
@override
_FastQuestionPageWidgetState createState() => _FastQuestionPageWidgetState();
}
class _FastQuestionPageWidgetState extends State<FastQuestionPage> {
int fastChosenAnswer;
@override
Widget build(BuildContext context) {
Widget nextQuestion = new RaisedButton(
padding: const EdgeInsets.all(10.0),
textColor: Colors.black,
child: const Text('Next Question'),
color: Color(0xFFE08284),
elevation: 5.0,
onPressed: () {
Navigator.of(context).push(new MaterialPageRoute(
builder: (context) => new FastQuestionPage()));
},
);
return Scaffold(
body: new CustomScrollView(
slivers: <Widget>[
SliverAppBar(
centerTitle: true,
title: const Text('SUBJECT HERE'),
elevation: 0.0,
leading: new IconButton(
icon: new Icon(Icons.arrow_back, color: Colors.white),
onPressed: () =>
Navigator.popUntil(context, ModalRoute.withName('/'))),
),
new SliverPadding(
padding: new EdgeInsets.all(0.0),
sliver: new SliverList(
delegate: new SliverChildListDelegate([
new Container(
height: 250.0,
padding: EdgeInsets.all(40.0),
decoration: new BoxDecoration(
borderRadius: new BorderRadius.only(
bottomLeft: const Radius.elliptical(200.0, 35.0),
bottomRight: const Radius.elliptical(200.0, 35.0)),
gradient: new LinearGradient(
colors: [
const Color(0xFFE08284),
const Color(0xFFF1BFB9),
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
stops: [0.0, 0.6],
tileMode: TileMode.clamp),
),
child: Text("QUESTION GOES HERE",
softWrap: true,
textAlign: TextAlign.center,
style: TextStyle(
color: Color(0xFFFFFFFF),
fontWeight: FontWeight.w600,
fontSize: 22.0)),
),
new Column(
children: <Widget>[
new FlatButton(
padding: EdgeInsets.only(
top: 40.0, bottom: 10.0, left: 20.0, right: 20.0),
child: Material(
borderRadius: BorderRadius.circular(17.0),
shadowColor: Color.fromRGBO(50, 50, 50, 0.2),
elevation: fastChosenAnswer == 1? 0.0: 1.0,
child: MaterialButton(
color: fastChosenAnswer == 1? Color(0xFFF1BFB9) : Colors.white,
minWidth: 300.0,
height: 70.0,
onPressed: () {
setState(() {
fastChosenAnswer = 1;
});
},
child: new Text("Answer 1",
style: TextStyle(
color: Color(0xFFE08284),
fontWeight: FontWeight.w600,
fontSize: 25.0)),
),
),
),
new FlatButton(
padding: EdgeInsets.only(
top: 10.0, bottom: 10.0, left: 20.0, right: 20.0),
child: Material(
borderRadius: BorderRadius.circular(17.0),
shadowColor: Color.fromRGBO(50, 50, 50, 0.2),
elevation: fastChosenAnswer == 2? 0.0: 1.0,
child: MaterialButton(
color: fastChosenAnswer == 2? Color(0xFFF1BFB9) : Colors.white,
minWidth: 300.0,
height: 70.0,
onPressed: () {
setState(() {
fastChosenAnswer = 2;
});
},
child: new Text("Answer 2",
style: TextStyle(
color: Color(0xFFE08284),
fontWeight: FontWeight.w600,
fontSize: 25.0)),
),
),
),
new FlatButton(
padding: EdgeInsets.only(
top: 10.0, bottom: 10.0, left: 20.0, right: 20.0),
child: Material(
borderRadius: BorderRadius.circular(17.0),
shadowColor: Color.fromRGBO(50, 50, 50, 0.2),
elevation: fastChosenAnswer == 3? 0.0: 1.0,
child: MaterialButton(
color: fastChosenAnswer == 3? Color(0xFFF1BFB9) : Colors.white,
minWidth: 300.0,
height: 70.0,
onPressed: () {
setState(() {
fastChosenAnswer = 3;
});
},
child: new Text("Answer 3",
style: TextStyle(
color: Color(0xFFE08284),
fontWeight: FontWeight.w600,
fontSize: 25.0)),
),
),
),
new FlatButton(
padding: EdgeInsets.only(
top: 10.0, bottom: 40.0, left: 20.0, right: 20.0),
child: Material(
borderRadius: BorderRadius.circular(17.0),
shadowColor: Color.fromRGBO(50, 50, 50, 0.2),
elevation: fastChosenAnswer == 4? 0.0: 1.0,
child: MaterialButton(
color: fastChosenAnswer == 4? Color(0xFFF1BFB9) : Colors.white,
minWidth: 300.0,
height: 70.0,
onPressed: () {
setState(() {
fastChosenAnswer = 4;
});
},
child: new Text("Answer 4",
style: TextStyle(
color: Color(0xFFE08284),
fontWeight: FontWeight.w600,
fontSize: 25.0)),
),
),
),
nextQuestion,
new SizedBox(height: 50.0),
],
),
]),
),
),
],
),
);
}
}
| 0
|
mirrored_repositories/birdbrain/lib
|
mirrored_repositories/birdbrain/lib/more/more.dart
|
import 'package:flutter/material.dart';
class MoreBody extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Expanded(
child: Scaffold(
appBar: AppBar(
title: new Text("More",
style: TextStyle(
color: Color(0xFFFFFFFF),
fontWeight: FontWeight.w500,
letterSpacing: 2.0,
fontSize: 20.0)),
leading: new Container(),
centerTitle: true,
elevation: 0.0,
),
body: GridView.count(
scrollDirection: Axis.vertical,
padding: EdgeInsets.all(20.0),
mainAxisSpacing: 20.0,
crossAxisCount: 1,
children: <Widget>[
new Card(color: Colors.red),
new Card(color: Colors.blue),
new Card(color: Colors.pink),
new Card(color: Colors.yellow)
],
),
),
);
}
}
| 0
|
mirrored_repositories/birdbrain/lib
|
mirrored_repositories/birdbrain/lib/home/coursebox.dart
|
import 'package:flutter/material.dart';
import 'package:quiz/home/courses.dart';
import 'package:quiz/question/dialog.dart';
class CourseBox extends StatelessWidget {
final Course course;
final bool horizontal;
CourseBox(this.course, {this.horizontal = true});
@override
Widget build(BuildContext context) {
final courseCard = new Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
new Image(
image: new AssetImage(course.image),
height: 80.0,
width: 80.0,
),
new SizedBox(height: 15.0),
new Text(
course.name,
textAlign: TextAlign.center,
style: new TextStyle(
letterSpacing: 1.0,
fontWeight: FontWeight.w700,
fontSize: 15.0,
color: Colors.black54,
),
),
],
),
);
return new GestureDetector(
onTap: horizontal
? () => Navigator.of(context).push(
new PageRouteBuilder(
pageBuilder: (_, __, ___) => new PopUp(),
transitionsBuilder:
(context, animation, secondaryAnimation, child) =>
new FadeTransition(opacity: animation, child: child),
),
)
: null,
child: new Container(
margin: const EdgeInsets.symmetric(
vertical: 16.0,
horizontal: 24.0,
),
child: new Stack(
children: <Widget>[
courseCard,
],
),
),
);
}
}
| 0
|
mirrored_repositories/birdbrain/lib
|
mirrored_repositories/birdbrain/lib/home/appbar.dart
|
import 'package:flutter/material.dart';
class GradientAppBar extends StatelessWidget {
final title = 'BirdBrain';
final double barHeight = 80.0;
@override
Widget build(BuildContext context) {
final double statusBarHeight = MediaQuery.of(context).padding.top;
return new Container(
padding: new EdgeInsets.only(top: statusBarHeight),
height: statusBarHeight + barHeight,
child: new Center(
child: new Text(title,
style: const TextStyle(
color: Color(0xFFFFFFFF),
// fontFamily:
fontWeight: FontWeight.w600,
fontSize: 36.0)),
),
decoration: new BoxDecoration(
gradient: new LinearGradient(
colors: [
const Color(0xFFF1BFB9),
const Color(0xFFE08284),
],
begin: const FractionalOffset(0.0, 0.0),
end: const FractionalOffset(1.0, 0.0),
stops: [0.0, 0.6],
tileMode: TileMode.clamp),
),
);
}
}
| 0
|
mirrored_repositories/birdbrain/lib
|
mirrored_repositories/birdbrain/lib/home/homepagebody.dart
|
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:quiz/home/bjccourses.dart';
import 'package:quiz/home/bjccoursebox.dart';
import 'package:quiz/home/coursebox.dart';
import 'package:quiz/home/courses.dart';
class HomePageBody extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Expanded(
child: new Container(
child: new CustomScrollView(
scrollDirection: Axis.vertical,
shrinkWrap: false,
slivers: <Widget>[
new SliverAppBar(
leading: new Container(),
pinned: true,
centerTitle: true,
title: new Text("Bird Brain",
style: TextStyle(
color: Color(0xFFFFFFFF),
fontWeight: FontWeight.w600,
fontSize: 30.0)),
),
new SliverGrid(
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
),
delegate: new SliverChildBuilderDelegate(
(context, int index) => new CourseBox(courses[index]),
childCount: courses.length,
),
),
new SliverGrid(
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
),
delegate: new SliverChildBuilderDelegate(
(context, int index) => new BJCCourseBox(bjccourses[index]),
childCount: bjccourses.length,
),
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/birdbrain/lib
|
mirrored_repositories/birdbrain/lib/home/bjccourses.dart
|
class BJCCourse {
final String id;
final String name;
final String image;
const BJCCourse({this.id, this.name, this.image});
}
List<BJCCourse> bjccourses = [
const BJCCourse(
id: "bjc_math",
name: "Mathematics",
image: "assets/picture.png"
),
const BJCCourse(
id: "bjc_healthscience",
name: "Health Science",
image: "assets/picture.png"
),
const BJCCourse(
id: "bjc_generalscience",
name: "General Science",
image: "assets/picture.png"
),
const BJCCourse(
id: "bjc_socialstudies",
name: "Social Studies",
image: "assets/picture.png"
),
];
| 0
|
mirrored_repositories/birdbrain/lib
|
mirrored_repositories/birdbrain/lib/home/courses.dart
|
class Course {
final String id;
final String name;
final String image;
const Course({this.id, this.name, this.image});
}
List<Course> courses = [
const Course(
id: "bgcse_math",
name: "Mathematics",
image: "assets/picture.png"
),
const Course(
id: "bgcse_physics",
name: "Physics",
image: "assets/picture.png"
),
const Course(
id: "bgcse_biology",
name: "Biology",
image: "assets/picture.png"
),
const Course(
id: "bgcse_chemistry",
name: "Chemistry",
image: "assets/picture.png"
),
const Course(
id: "bgcse_combinedscience",
name: "Combined Sciences",
image: "assets/picture.png"
),
const Course(
id: "bgcse_history",
name: "History",
image: "assets/picture.png"
),
const Course(
id: "bgcse_geography",
name: "Geography",
image: "assets/picture.png"
),
const Course(
id: "bgcse_officeprocedures",
name: "Office Procedures",
image: "assets/picture.png"
),
const Course(
id: "bgcse_economics",
name: "Economics",
image: "assets/picture.png"
),
];
| 0
|
mirrored_repositories/birdbrain/lib
|
mirrored_repositories/birdbrain/lib/home/pickmode.dart
|
import 'package:flutter/material.dart';
class PopUp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Stack(
alignment: const Alignment(0.0, 0.0),
children: <Widget>[
new Container(
child: new Text(
'Pick a Mode',
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: new TextStyle(fontWeight: FontWeight.bold),
),
),
new Container (
padding: const EdgeInsets.all(5.0),
decoration: new BoxDecoration(
color: new Color.fromARGB(150, 71, 150, 236)
),
child: new Text(
'Normal mode',
style: new TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 20.0)
),
),
new Container (
padding: const EdgeInsets.all(5.0),
decoration: new BoxDecoration(
color: new Color.fromARGB(150, 71, 150, 236)
),
child: new Text(
'Head to Head',
style: new TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 20.0)
),
),
],
);
}
}
| 0
|
mirrored_repositories/birdbrain/lib
|
mirrored_repositories/birdbrain/lib/home/bjccoursebox.dart
|
import 'package:flutter/material.dart';
import 'package:quiz/home/bjccourses.dart';
import 'package:quiz/question/dialog.dart';
class BJCCourseBox extends StatelessWidget {
final BJCCourse bjccourse;
final bool horizontal;
BJCCourseBox(this.bjccourse, {this.horizontal = true});
@override
Widget build(BuildContext context) {
final courseCard = new Container(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
new Image(
image: new AssetImage(bjccourse.image),
height: 80.0,
width: 80.0,
),
new SizedBox(height: 15.0),
new Text(
bjccourse.name,
textAlign: TextAlign.center,
style: new TextStyle(
letterSpacing: 1.0,
fontWeight: FontWeight.w700,
fontSize: 15.0,
color: Colors.black54,
),
),
],
),
);
return new GestureDetector(
onTap: horizontal
? () => Navigator.of(context).push(
new PageRouteBuilder(
pageBuilder: (_, __, ___) => new PopUp(),
transitionsBuilder:
(context, animation, secondaryAnimation, child) =>
new FadeTransition(opacity: animation, child: child),
),
)
: null,
child: new Container(
margin: const EdgeInsets.symmetric(
vertical: 16.0,
horizontal: 24.0,
),
child: new Stack(
children: <Widget>[
courseCard,
],
),
),
);
}
}
| 0
|
mirrored_repositories/birdbrain/lib
|
mirrored_repositories/birdbrain/lib/home/dialog.dart
|
import 'package:flutter/material.dart';
class PopUp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Stack(
alignment: const Alignment(0.0, 0.0),
children: <Widget>[
new Container(
child: new Text(
'Pick a Mode',
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: new TextStyle(fontWeight: FontWeight.bold),
),
),
new Container (
padding: const EdgeInsets.all(5.0),
decoration: new BoxDecoration(
color: new Color.fromARGB(150, 71, 150, 236)
),
child: new Text(
'Normal mode',
style: new TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 20.0)
),
),
new Container (
padding: const EdgeInsets.all(5.0),
decoration: new BoxDecoration(
color: new Color.fromARGB(150, 71, 150, 236)
),
child: new Text(
'Head to Head',
style: new TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 20.0)
),
),
],
);
}
}
| 0
|
mirrored_repositories/birdbrain/lib
|
mirrored_repositories/birdbrain/lib/settings/settingsbody.dart
|
import 'package:flutter/material.dart';
import 'package:quiz/settings/aboutus.dart';
import 'package:url_launcher/url_launcher.dart';
class SettingsBody extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Expanded(
child: Center(
child: ListView(
shrinkWrap: false,
scrollDirection: Axis.vertical,
children: <Widget>[
new Container(
height: 250.0,
padding: EdgeInsets.only(top: 15.0, bottom: 30.0),
decoration: new BoxDecoration(
borderRadius: new BorderRadius.only(
bottomLeft: const Radius.elliptical(150.0, 35.0),
bottomRight: const Radius.elliptical(150.0, 35.0)),
gradient: new LinearGradient(
colors: [
const Color(0xFFF1BFB9),
const Color(0xFFE08284),
],
begin: Alignment.topCenter,
end: Alignment.bottomRight,
stops: [0.0, 0.6],
tileMode: TileMode.clamp),
),
margin: new EdgeInsets.only(bottom: 20.0),
child: new Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
new CircleAvatar(
radius: 60.0,
backgroundColor: Colors.white,
backgroundImage: AssetImage('assets/face.jpg'),
),
new SizedBox(height: 20.0),
new Text("Sowmya Thottambeti",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 23.0)),
new SizedBox(height: 10.0),
new Text("Points : 2,400",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w300,
fontSize: 17.0)),
],
),
),
SizedBox(height: 20.0),
new Row(
children: <Widget>[
new SizedBox(width: 30.0),
new Text(
"ACCOUNT",
style: TextStyle(
letterSpacing: 1.0,
color: Colors.black54,
fontWeight: FontWeight.w700,
fontSize: 15.0),
),
],
),
new FlatButton(
padding: EdgeInsets.only(
top: 16.0, bottom: 16.0, left: 20.0, right: 20.0),
child: Material(
borderRadius: BorderRadius.circular(17.0),
shadowColor: Color.fromRGBO(50, 50, 50, 0.2),
elevation: 0.5,
child: MaterialButton(
color: Colors.white,
minWidth: 300.0,
height: 70.0,
onPressed: () {
// Navigator.of(context).pushNamed(HomePage.tag);
},
child: new Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
new Image(
alignment: FractionalOffset.centerLeft,
image: new AssetImage('assets/picture.png'),
height: 40.0,
width: 50.0),
new Container(
child: SizedBox(width: 10.0),
),
new Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
new Text("Update Email Address",
style: TextStyle(
color: Color(0xFFE08284),
fontWeight: FontWeight.w600,
fontSize: 15.0)),
new Container(
child: SizedBox(height: 5.0),
),
new Text("sowmya6598@gmail.com",
style: TextStyle(
color: Color(0xFFF1BFB9),
fontWeight: FontWeight.w400,
fontSize: 13.0)),
],
),
new Expanded(
child: new Container(),
flex: 1,
),
new Icon(Icons.navigate_next, color: Colors.black38),
],
),
),
),
),
new FlatButton(
padding: EdgeInsets.only(
top: 16.0, bottom: 16.0, left: 20.0, right: 20.0),
child: Material(
borderRadius: BorderRadius.circular(17.0),
shadowColor: Color.fromRGBO(50, 50, 50, 0.2),
elevation: 0.5,
child: MaterialButton(
color: Colors.white,
minWidth: 300.0,
height: 70.0,
// onPressed: () {
// Navigator.of(context).pushNamed(HomePage.tag);
// },
child: new Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
new Image(
alignment: FractionalOffset.centerLeft,
image: new AssetImage('assets/picture.png'),
height: 40.0,
width: 50.0),
new Container(
child: SizedBox(width: 10.0),
),
new Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
new Text("Change Password",
style: TextStyle(
color: Color(0xFFE08284),
fontWeight: FontWeight.w600,
fontSize: 15.0)),
new Container(
child: SizedBox(height: 5.0),
),
new Text("last changed 13 days ago",
style: TextStyle(
color: Color(0xFFF1BFB9),
fontWeight: FontWeight.w400,
fontSize: 13.0)),
],
),
new Expanded(
child: new Container(),
flex: 1,
),
new Icon(Icons.navigate_next, color: Colors.black38),
],
),
),
),
),
new FlatButton(
padding: EdgeInsets.only(
top: 16.0, bottom: 16.0, left: 20.0, right: 20.0),
child: Material(
borderRadius: BorderRadius.circular(17.0),
shadowColor: Color.fromRGBO(50, 50, 50, 0.2),
elevation: 0.5,
child: MaterialButton(
color: Colors.white,
minWidth: 400.0,
height: 70.0,
// onPressed: () {
// Navigator.of(context).pushNamed(HomePage.tag);
// },
child: Text("Log out",
style: TextStyle(
color: Color(0xFFE08284),
fontWeight: FontWeight.w600,
fontSize: 15.0)),
),
),
),
SizedBox(height: 25.0),
new Row(
children: <Widget>[
new SizedBox(width: 30.0),
new Text(
"OTHER",
style: TextStyle(
letterSpacing: 1.0,
color: Colors.black54,
fontWeight: FontWeight.w700,
fontSize: 15.0),
),
],
),
new FlatButton(
padding: EdgeInsets.only(
top: 16.0, bottom: 16.0, left: 20.0, right: 20.0),
child: Material(
borderRadius: BorderRadius.circular(17.0),
shadowColor: Color.fromRGBO(50, 50, 50, 0.2),
elevation: 0.5,
child: MaterialButton(
color: Colors.white,
minWidth: 300.0,
height: 70.0,
onPressed: () {
Navigator.of(context).push(new MaterialPageRoute(
builder: (context) => new AboutUs()));
},
child: new Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
new Image(
alignment: FractionalOffset.centerLeft,
image: new AssetImage('assets/picture.png'),
height: 40.0,
width: 50.0),
new Container(
child: SizedBox(width: 10.0),
),
new Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
new Text("About Us",
style: TextStyle(
color: Color(0xFFE08284),
fontWeight: FontWeight.w600,
fontSize: 15.0)),
new Container(
child: SizedBox(height: 5.0),
),
new Text("BTS Birdbrain",
style: TextStyle(
color: Color(0xFFF1BFB9),
fontWeight: FontWeight.w400,
fontSize: 13.0)),
],
),
new Expanded(
child: new Container(),
flex: 1,
),
new Icon(Icons.navigate_next, color: Colors.black38),
],
),
),
),
),
new FlatButton(
padding: EdgeInsets.only(
top: 16.0, bottom: 16.0, left: 20.0, right: 20.0),
child: Material(
borderRadius: BorderRadius.circular(17.0),
shadowColor: Color.fromRGBO(50, 50, 50, 0.2),
elevation: 0.5,
child: MaterialButton(
color: Colors.white,
minWidth: 300.0,
height: 70.0,
onPressed: () => _launchURL('birdbrainbs@gmail.com'),
child: new Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
new Image(
alignment: FractionalOffset.centerLeft,
image: new AssetImage('assets/picture.png'),
height: 40.0,
width: 50.0),
new Container(
child: SizedBox(width: 10.0),
),
new Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
new Text("Contact Us",
style: TextStyle(
color: Color(0xFFE08284),
fontWeight: FontWeight.w600,
fontSize: 15.0)),
new Container(
child: SizedBox(height: 5.0),
),
new Text("We want to hear from you!",
style: TextStyle(
color: Color(0xFFF1BFB9),
fontWeight: FontWeight.w400,
fontSize: 13.0)),
],
),
new Expanded(
child: new Container(),
flex: 1,
),
new Icon(Icons.navigate_next, color: Colors.black38),
],
),
),
),
)
],
),
),
);
}
_launchURL(String toMailId) async {
var url = 'mailto:$toMailId';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
}
| 0
|
mirrored_repositories/birdbrain/lib
|
mirrored_repositories/birdbrain/lib/settings/aboutus.dart
|
import 'package:flutter/material.dart';
class AboutUs extends StatelessWidget {
@override
Widget build(BuildContext context) {
final alucard = Hero(
tag: 'hero',
child: Padding(
padding: EdgeInsets.all(16.0),
child: CircleAvatar(
radius: 72.0,
backgroundColor: Colors.transparent,
backgroundImage: AssetImage('assets/alucard.jpg'),
),
),
);
final welcome = Padding(
padding: EdgeInsets.only(bottom: 20.0),
child: Text(
'About Us',
style: TextStyle(fontSize: 40.0, color: Colors.white),
),
);
final lorem = Padding(
padding: EdgeInsets.all(20.0),
child: Text(
' Sowmya Thottambeti',
style: TextStyle(fontSize: 25.0, color: Colors.white),
),
);
final body = Container(
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.all(10.0),
decoration: BoxDecoration(
gradient: LinearGradient(colors: [
const Color(0xFFF1BFB9),
const Color(0xFFE08284),
]),
),
child: Column(
children: <Widget>[alucard, welcome, lorem],
),
);
return Scaffold(
body: body,
);
}
}
| 0
|
mirrored_repositories/birdbrain
|
mirrored_repositories/birdbrain/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:quiz/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(new MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0
|
mirrored_repositories/flutter_spacexopedia
|
mirrored_repositories/flutter_spacexopedia/lib/app.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_spacexopedia/bloc/launches/bloc.dart';
import 'package:flutter_spacexopedia/bloc/navigation/navigation_bloc.dart';
import 'package:flutter_spacexopedia/resources/repository/launch_repository.dart';
import 'package:flutter_spacexopedia/ui/theme/custom_theme.dart';
import 'package:get_it/get_it.dart';
import 'package:google_fonts/google_fonts.dart';
class SpaceApp extends StatefulWidget {
final Widget home;
const SpaceApp({
Key key,
@required this.home,
}) : super(key: key);
static void setLocale(BuildContext context, Locale newLocale) {
_AppState state = context.findAncestorStateOfType<_AppState>();
state.setLocale(newLocale);
}
@override
_AppState createState() => _AppState();
}
class _AppState extends State<SpaceApp> {
// final _key = ErrorHandlerKey();
final _navigatorKey = GlobalKey<NavigatorState>();
// final _bloc = ErrorsBloc();
@override
void initState() {
super.initState();
// GetIt.instance<ErrorsProducer>().registerErrorHandler(
// _key,
// (error, stackTrace) {
// log(error, stackTrace:stackTrace,name: "KirajApp");
// _bloc.add(OnError(error, stackTrace));
// _navigatorKey.currentState.push(ErrorPageRoute());
// return false;
// },
// );
}
@override
void dispose() {
// GetIt.instance<ErrorsProducer>().unregisterErrorHandler(_key);
// _bloc.close();
super.dispose();
}
Locale _locale;
setLocale(Locale locale) {
setState(() {
_locale = locale;
});
}
@override
void didChangeDependencies() {
// getLocale().then((locale) {
// setState(() {
// this._locale = locale;
// });
// });
super.didChangeDependencies();
}
@override
Widget build(BuildContext context) {
// SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
// statusBarColor: Colors.transparent, //top bar color
// statusBarIconBrightness: Brightness.dark, //top bar icons
// ));
return MaterialApp(
debugShowCheckedModeBanner: false,
navigatorKey: _navigatorKey,
onGenerateTitle: (BuildContext context) => "",
locale: _locale,
supportedLocales: [
const Locale('en'),
const Locale('ar'),
],
theme: CustomTheme.of(context).copyWith(
textTheme: GoogleFonts.montserratTextTheme()
),
// home: widget.home,
home: MultiBlocProvider(
providers: [
BlocProvider<NavigationBloc>(
create: (BuildContext context) => NavigationBloc(),
),
BlocProvider<LaunchBloc>(
create: (BuildContext context) =>
LaunchBloc(GetIt.instance<LaunchRepository>())
..add(LaunchInitial()),
),
],
child: widget.home,
),
);
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia
|
mirrored_repositories/flutter_spacexopedia/lib/app_delegate.dart
|
import 'package:flutter/foundation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class AppBlocDelegate extends BlocDelegate {
@override
void onEvent(Bloc bloc, dynamic event) {
super.onEvent(bloc, event);
// debugPrint("[Trigger Event] $event");
if(event.props != null){
event.props.forEach((x){
print(x);
});
}
}
@override
void onTransition(Bloc bloc, Transition transition) {
super.onTransition(bloc, transition);
debugPrint(transition.toString());
}
@override
void onError(Bloc bloc, Object error, StackTrace stacktrace) {
super.onError(bloc, error, stacktrace);
// GetIt.instance<ErrorsProducer>().pushError(error, stacktrace);
debugPrint(error.toString());
debugPrint(stacktrace.toString());
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia
|
mirrored_repositories/flutter_spacexopedia/lib/locator.dart
|
import 'package:dio/dio.dart';
import 'package:flutter_spacexopedia/helper/config.dart';
import 'package:flutter_spacexopedia/resources/dio_client.dart';
import 'package:flutter_spacexopedia/resources/repository/launch_repository.dart';
import 'package:flutter_spacexopedia/resources/service/api_gatway.dart';
import 'package:flutter_spacexopedia/resources/service/api_gatway_impl.dart';
import 'package:get_it/get_it.dart';
void setUpDependency() {
final serviceLocator = GetIt.instance;
serviceLocator.registerLazySingleton<ApiGateway>(
() => ApiGatewayImpl(
DioClient(
Dio(),
baseEndpoint: Config.apiBaseUrl,
logging: true
),
),
);
GetIt.instance.registerSingleton<LaunchRepository>(LaunchRepository(
apiGateway: GetIt.instance<ApiGateway>()
));
}
| 0
|
mirrored_repositories/flutter_spacexopedia
|
mirrored_repositories/flutter_spacexopedia/lib/main.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_spacexopedia/app.dart';
import 'package:flutter_spacexopedia/app_delegate.dart';
import 'package:flutter_spacexopedia/locator.dart';
import 'package:flutter_spacexopedia/ui/pages/home_page.dart';
import 'package:flutter_spacexopedia/ui/theme/custom_theme.dart';
import 'package:flutter_spacexopedia/ui/theme/theme.dart';
void main() {
BlocSupervisor.delegate = AppBlocDelegate();
setUpDependency();
final app = SpaceApp(home: HomePage());
runApp(
CustomTheme(
initialThemeKey: ThemeType.DARK,
child: app,
),
);
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib
|
mirrored_repositories/flutter_spacexopedia/lib/resources/dio_client.dart
|
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_spacexopedia/exceptions/exceptions.dart';
class DioClient {
final Dio _dio;
final String baseEndpoint;
final bool logging;
DioClient(
this._dio, {
this.baseEndpoint,
this.logging = false,
}) : assert(baseEndpoint != null),
assert(logging != null) {
if (logging) {
_dio.interceptors.add(
LogInterceptor(
requestHeader: true,
responseHeader: true,
requestBody: true,
responseBody: true,
),
);
}
}
Future<Response<T>> get<T>(
String endpoint, {
Options options,
queryParameters,
}) async {
try {
var isconnected = await hasInternetConnection();
if(!isconnected){
throw SocketException("Please check your internet connection");
}
return await _dio.get(
'$baseEndpoint$endpoint',
// options: _createOptions(options, session),
queryParameters: queryParameters,
);
} on DioError catch (e) {
throw _handleError(e);
}
}
Future<Response<T>> post<T>(
String endpoint, {
data,
Options options,
}) async {
try {
return await _dio.post(
'$baseEndpoint$endpoint',
data: data,
);
} on DioError catch (e) {
throw _handleError(e);
}
}
Map<String, dynamic> getJsonBody<T>(Response<T> response) {
try {
return response.data as Map<String, dynamic>;
} on Exception catch (e, stackTrace) {
debugPrint(stackTrace.toString());
throw Exception('Bad body format');
}
}
List<dynamic> getJsonBodyList<T>(Response<T> response) {
try {
return response.data as List<dynamic>;
} on Exception catch (e, stackTrace) {
debugPrint(stackTrace.toString());
throw SchemeConsistencyException('Bad body format');
}
}
Exception _handleError(DioError e) {
switch (e.response.statusCode) {
case 404:
return ApiDataNotFoundException();
case 500:
return ApiInternalServerException();
case 400:
throw BadRequestException("Bad request : ${e.response.statusCode}");
case 401:
case 403:
throw UnauthorisedException("Unauthorised request : ${e.response.statusCode}");
case 404:
throw ResourceNotFoundException("Resource not found : ${e.response.statusCode}");
case 500:
default:
throw FetchDataException(
'Error occurred while communicating with server : ${e.response.statusCode}');
}
}
Future<bool> hasInternetConnection() async {
try {
final result = await InternetAddress.lookup('google.com');
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
return true;
} else {
return false;
}
} on SocketException catch (_) {
return false;
}
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/resources
|
mirrored_repositories/flutter_spacexopedia/lib/resources/repository/launch_repository.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_spacexopedia/bloc/launches/launch_model.dart';
import 'package:flutter_spacexopedia/resources/service/api_gatway.dart';
class LaunchRepository {
final ApiGateway apiGateway;
LaunchRepository({
@required this.apiGateway
}) : assert( apiGateway != null);
Future<List<Launch>> fetchAllLaunch(){
return apiGateway.fetchAllLaunch();
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/resources
|
mirrored_repositories/flutter_spacexopedia/lib/resources/repository/core_repository.dart
|
import 'package:flutter/foundation.dart';
import 'package:flutter_spacexopedia/bloc/core/core_model.dart';
import 'package:flutter_spacexopedia/resources/service/api_gatway.dart';
class CoreRepository {
final ApiGateway apiGateway;
CoreRepository({
@required this.apiGateway
}) : assert( apiGateway != null);
Future<List<CoreModel>> fetchAllCores(){
return apiGateway.fetchAllCores();
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/resources
|
mirrored_repositories/flutter_spacexopedia/lib/resources/repository/dragon_repository.dart
|
import 'package:flutter/foundation.dart';
import 'package:flutter_spacexopedia/bloc/dragon/dragon_model.dart';
import 'package:flutter_spacexopedia/resources/service/api_gatway.dart';
class DragonRepository {
final ApiGateway apiGateway;
DragonRepository({
@required this.apiGateway
}) : assert( apiGateway != null);
Future<List<DragonModel>> fetchAllLaunch(){
return apiGateway.fetchAllDragon();
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/resources
|
mirrored_repositories/flutter_spacexopedia/lib/resources/repository/roadster_repository.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_spacexopedia/bloc/roadster/roadster_model.dart';
import 'package:flutter_spacexopedia/resources/service/api_gatway.dart';
class RoadsterRepository{
final ApiGateway apiGateway;
RoadsterRepository({
@required this.apiGateway
}) : assert( apiGateway != null);
Future<RoadsterModel> fetchAllLaunch(){
return apiGateway.fetchRoadster();
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/resources
|
mirrored_repositories/flutter_spacexopedia/lib/resources/repository/rocket_repository.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_spacexopedia/bloc/rocket/rocket_model.dart';
import 'package:flutter_spacexopedia/resources/service/api_gatway.dart';
class RocketRepository{
final ApiGateway apiGateway;
RocketRepository({
@required this.apiGateway
}) : assert( apiGateway != null);
Future<List<RocketModel>> fetchAllRocket(){
return apiGateway.fetchAllRocket();
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/resources
|
mirrored_repositories/flutter_spacexopedia/lib/resources/service/api_gatway.dart
|
import 'package:flutter_spacexopedia/bloc/core/core_model.dart';
import 'package:flutter_spacexopedia/bloc/dragon/dragon_model.dart';
import 'package:flutter_spacexopedia/bloc/launches/launch_model.dart';
import 'package:flutter_spacexopedia/bloc/roadster/roadster_model.dart';
import 'package:flutter_spacexopedia/bloc/rocket/rocket_model.dart';
abstract class ApiGateway {
Future<List<Launch>> fetchAllLaunch();
Future<RoadsterModel> fetchRoadster();
Future<List<RocketModel>> fetchAllRocket();
Future<List<DragonModel>> fetchAllDragon();
Future<List<CoreModel>> fetchAllCores();
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/resources
|
mirrored_repositories/flutter_spacexopedia/lib/resources/service/api_gatway_impl.dart
|
import 'package:dio/dio.dart';
import 'package:flutter_spacexopedia/bloc/core/core_model.dart';
import 'package:flutter_spacexopedia/bloc/dragon/dragon_model.dart';
import 'package:flutter_spacexopedia/bloc/launches/launch_model.dart';
import 'package:flutter_spacexopedia/bloc/roadster/roadster_model.dart';
import 'package:flutter_spacexopedia/bloc/rocket/rocket_model.dart';
import 'package:flutter_spacexopedia/exceptions/exceptions.dart';
import 'package:flutter_spacexopedia/helper/config.dart';
import 'package:flutter_spacexopedia/resources/dio_client.dart';
import 'package:flutter_spacexopedia/resources/service/api_gatway.dart';
class ApiGatewayImpl implements ApiGateway {
final DioClient _dioClient;
ApiGatewayImpl(this._dioClient);
@override
Future<List<Launch>> fetchAllLaunch() async {
try {
var response = await _dioClient.get(Config.launchAll);
List<Launch> launch = List<Launch>();
bool isSuccess = _isSuccessOrThrow(response);
if (isSuccess) {
print("Api get data sucess");
launch = _dioClient.getJsonBodyList(response).map((value) {
return Launch.fromJson(value);
}).toList();
} else {
print("Error");
}
return launch;
} catch (error) {
throw error;
}
}
@override
Future<RoadsterModel> fetchRoadster() async {
try {
var response = await _dioClient.get(Config.roadster);
bool isSuccess = _isSuccessOrThrow(response);
if (isSuccess) {
return RoadsterModel.fromJson(_dioClient.getJsonBody(response));
} else {
return null;
}
} catch (error) {
throw error;
}
}
@override
Future<List<RocketModel>> fetchAllRocket() async {
try {
var response = await _dioClient.get(Config.allRockets);
List<RocketModel> rockets = List<RocketModel>();
bool isSuccess = _isSuccessOrThrow(response);
if (isSuccess) {
print("Api get data sucess");
rockets = _dioClient.getJsonBodyList(response).map((value) {
return RocketModel.fromJson(value);
}).toList();
} else {
print("Error");
}
return rockets;
} catch (error) {
throw error;
}
}
@override
Future<List<DragonModel>> fetchAllDragon() async {
try {
var response = await _dioClient.get(Config.allDragons);
List<DragonModel> rockets = List<DragonModel>();
bool isSuccess = _isSuccessOrThrow(response);
if (isSuccess) {
print("Api get data sucess");
rockets = _dioClient.getJsonBodyList(response).map((value) {
return DragonModel.fromJson(value);
}).toList();
} else {
print("Error");
}
return rockets;
} catch (error) {
throw error;
}
}
@override
Future<List<CoreModel>> fetchAllCores() async {
try {
var response = await _dioClient.get(Config.allCores);
List<CoreModel> cores = List<CoreModel>();
bool isSuccess = _isSuccessOrThrow(response);
if (isSuccess) {
print("Api get data sucess");
cores = _dioClient.getJsonBodyList(response).map((value) {
return CoreModel.fromJson(value);
}).toList();
} else {
print("Error");
}
return cores;
} catch (error) {
throw error;
}
}
bool _isSuccessOrThrow(Response response) {
print("ApiGateway isSuccess");
switch (response.statusCode) {
case 200:
return true;
case 201:
return true;
case 400:
throw BadRequestException("Bad request");
case 401:
case 403:
throw UnauthorisedException("Session expired");
case 404:
throw ResourceNotFoundException(response.statusMessage.toString());
case 500:
default:
throw FetchDataException(
'Error occurred while communicating with server : ${response.statusCode}');
}
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/dragon/dragon_event.dart
|
import 'dart:async';
import 'dart:developer' as developer;
import 'package:equatable/equatable.dart';
import 'package:flutter_spacexopedia/bloc/dragon/index.dart';
import 'package:flutter_spacexopedia/resources/repository/dragon_repository.dart';
import 'package:flutter_spacexopedia/resources/service/api_gatway.dart';
import 'package:get_it/get_it.dart';
import 'package:meta/meta.dart';
@immutable
abstract class DragonEvent extends Equatable {
@override
List<Object> get props => [];
Stream<DragonState> loadAsync({DragonState currentState, DragonBloc bloc});
final DragonRepository _dragonRepository =
DragonRepository(apiGateway: GetIt.instance<ApiGateway>());
}
class LaunchInitial extends DragonEvent {
@override
String toString() => 'LoadDragonEvent';
LaunchInitial();
@override
Stream<DragonState> loadAsync(
{DragonState currentState, DragonBloc bloc}) async* {
if (currentState is LoadedState) {
return;
}
try {
yield LoadingDragons();
await Future.delayed(Duration(seconds: 1));
final list = await _dragonRepository.fetchAllLaunch();
yield LoadedState(list);
} catch (_, stackTrace) {
developer.log('$_',
name: 'LoadDragonEvent', error: _, stackTrace: stackTrace);
yield ErrorDragonState(0, _?.toString());
}
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/dragon/dragon_bloc.dart
|
import 'dart:async';
import 'dart:developer' as developer;
import 'dart:io';
import 'package:bloc/bloc.dart';
import 'package:flutter_spacexopedia/bloc/dragon/index.dart';
class DragonBloc extends Bloc<DragonEvent, DragonState> {
// todo: check singleton for logic in project
static final DragonBloc _dragonBlocSingleton = DragonBloc._internal();
factory DragonBloc() {
return _dragonBlocSingleton;
}
DragonBloc._internal();
@override
Future<void> close() async {
// dispose objects
await super.close();
}
@override
DragonState get initialState => LoadingDragons();
@override
Stream<DragonState> mapEventToState(
DragonEvent event,
) async* {
try {
if (event is LaunchInitial) {
yield* event.loadAsync(currentState: state, bloc: this);
}
} on SocketException catch (_, stackTrace) {
developer.log('$_', name: 'DragonBloc', error: _, stackTrace: stackTrace);
yield NoConnectionDragonState(_.message);
} catch (_, stackTrace) {
developer.log('$_', name: 'DragonBloc', error: _, stackTrace: stackTrace);
yield state;
}
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/dragon/index.dart
|
export 'dragon_bloc.dart';
export 'dragon_event.dart';
export 'dragon_state.dart';
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/dragon/dragon_model.dart
|
// To parse this JSON data, do
//
// final dragonModel = dragonModelFromJson(jsonString);
import 'dart:convert';
class DragonModel {
DragonModel({
this.id,
this.name,
this.type,
this.active,
this.crewCapacity,
this.sidewallAngleDeg,
this.orbitDurationYr,
this.dryMassKg,
this.dryMassLb,
this.firstFlight,
this.heatShield,
this.thrusters,
this.launchPayloadMass,
this.launchPayloadVol,
this.returnPayloadMass,
this.returnPayloadVol,
this.pressurizedCapsule,
this.trunk,
this.heightWTrunk,
this.diameter,
this.flickrImages,
this.wikipedia,
this.description,
});
String id;
String name;
String type;
bool active;
int crewCapacity;
int sidewallAngleDeg;
int orbitDurationYr;
int dryMassKg;
int dryMassLb;
DateTime firstFlight;
HeatShield heatShield;
List<Thruster> thrusters;
PayloadMass launchPayloadMass;
LaunchPayloadVol launchPayloadVol;
PayloadMass returnPayloadMass;
LaunchPayloadVol returnPayloadVol;
PressurizedCapsule pressurizedCapsule;
Trunk trunk;
Diameter heightWTrunk;
Diameter diameter;
List<String> flickrImages;
String wikipedia;
String description;
factory DragonModel.fromRawJson(String str) => DragonModel.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory DragonModel.fromJson(Map<String, dynamic> json) => DragonModel(
id: json["id"] == null ? null : json["id"],
name: json["name"] == null ? null : json["name"],
type: json["type"] == null ? null : json["type"],
active: json["active"] == null ? null : json["active"],
crewCapacity: json["crew_capacity"] == null ? null : json["crew_capacity"],
sidewallAngleDeg: json["sidewall_angle_deg"] == null ? null : json["sidewall_angle_deg"],
orbitDurationYr: json["orbit_duration_yr"] == null ? null : json["orbit_duration_yr"],
dryMassKg: json["dry_mass_kg"] == null ? null : json["dry_mass_kg"],
dryMassLb: json["dry_mass_lb"] == null ? null : json["dry_mass_lb"],
firstFlight: json["first_flight"] == null ? null : DateTime.parse(json["first_flight"]),
heatShield: json["heat_shield"] == null ? null : HeatShield.fromJson(json["heat_shield"]),
thrusters: json["thrusters"] == null ? null : List<Thruster>.from(json["thrusters"].map((x) => Thruster.fromJson(x))),
launchPayloadMass: json["launch_payload_mass"] == null ? null : PayloadMass.fromJson(json["launch_payload_mass"]),
launchPayloadVol: json["launch_payload_vol"] == null ? null : LaunchPayloadVol.fromJson(json["launch_payload_vol"]),
returnPayloadMass: json["return_payload_mass"] == null ? null : PayloadMass.fromJson(json["return_payload_mass"]),
returnPayloadVol: json["return_payload_vol"] == null ? null : LaunchPayloadVol.fromJson(json["return_payload_vol"]),
pressurizedCapsule: json["pressurized_capsule"] == null ? null : PressurizedCapsule.fromJson(json["pressurized_capsule"]),
trunk: json["trunk"] == null ? null : Trunk.fromJson(json["trunk"]),
heightWTrunk: json["height_w_trunk"] == null ? null : Diameter.fromJson(json["height_w_trunk"]),
diameter: json["diameter"] == null ? null : Diameter.fromJson(json["diameter"]),
flickrImages: json["flickr_images"] == null ? null : List<String>.from(json["flickr_images"].map((x) => x)),
wikipedia: json["wikipedia"] == null ? null : json["wikipedia"],
description: json["description"] == null ? null : json["description"],
);
Map<String, dynamic> toJson() => {
"id": id == null ? null : id,
"name": name == null ? null : name,
"type": type == null ? null : type,
"active": active == null ? null : active,
"crew_capacity": crewCapacity == null ? null : crewCapacity,
"sidewall_angle_deg": sidewallAngleDeg == null ? null : sidewallAngleDeg,
"orbit_duration_yr": orbitDurationYr == null ? null : orbitDurationYr,
"dry_mass_kg": dryMassKg == null ? null : dryMassKg,
"dry_mass_lb": dryMassLb == null ? null : dryMassLb,
"first_flight": firstFlight == null ? null : "${firstFlight.year.toString().padLeft(4, '0')}-${firstFlight.month.toString().padLeft(2, '0')}-${firstFlight.day.toString().padLeft(2, '0')}",
"heat_shield": heatShield == null ? null : heatShield.toJson(),
"thrusters": thrusters == null ? null : List<dynamic>.from(thrusters.map((x) => x.toJson())),
"launch_payload_mass": launchPayloadMass == null ? null : launchPayloadMass.toJson(),
"launch_payload_vol": launchPayloadVol == null ? null : launchPayloadVol.toJson(),
"return_payload_mass": returnPayloadMass == null ? null : returnPayloadMass.toJson(),
"return_payload_vol": returnPayloadVol == null ? null : returnPayloadVol.toJson(),
"pressurized_capsule": pressurizedCapsule == null ? null : pressurizedCapsule.toJson(),
"trunk": trunk == null ? null : trunk.toJson(),
"height_w_trunk": heightWTrunk == null ? null : heightWTrunk.toJson(),
"diameter": diameter == null ? null : diameter.toJson(),
"flickr_images": flickrImages == null ? null : List<dynamic>.from(flickrImages.map((x) => x)),
"wikipedia": wikipedia == null ? null : wikipedia,
"description": description == null ? null : description,
};
}
class Diameter {
Diameter({
this.meters,
this.feet,
});
double meters;
double feet;
factory Diameter.fromRawJson(String str) => Diameter.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Diameter.fromJson(Map<String, dynamic> json) => Diameter(
meters: json["meters"] == null ? null : json["meters"].toDouble(),
feet: json["feet"] == null ? null : json["feet"].toDouble(),
);
Map<String, dynamic> toJson() => {
"meters": meters == null ? null : meters,
"feet": feet == null ? null : feet,
};
}
class HeatShield {
HeatShield({
this.material,
this.sizeMeters,
this.tempDegrees,
this.devPartner,
});
String material;
double sizeMeters;
int tempDegrees;
String devPartner;
factory HeatShield.fromRawJson(String str) => HeatShield.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory HeatShield.fromJson(Map<String, dynamic> json) => HeatShield(
material: json["material"] == null ? null : json["material"],
sizeMeters: json["size_meters"] == null ? null : json["size_meters"].toDouble(),
tempDegrees: json["temp_degrees"] == null ? null : json["temp_degrees"],
devPartner: json["dev_partner"] == null ? null : json["dev_partner"],
);
Map<String, dynamic> toJson() => {
"material": material == null ? null : material,
"size_meters": sizeMeters == null ? null : sizeMeters,
"temp_degrees": tempDegrees == null ? null : tempDegrees,
"dev_partner": devPartner == null ? null : devPartner,
};
}
class PayloadMass {
PayloadMass({
this.kg,
this.lb,
});
int kg;
int lb;
factory PayloadMass.fromRawJson(String str) => PayloadMass.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory PayloadMass.fromJson(Map<String, dynamic> json) => PayloadMass(
kg: json["kg"] == null ? null : json["kg"],
lb: json["lb"] == null ? null : json["lb"],
);
Map<String, dynamic> toJson() => {
"kg": kg == null ? null : kg,
"lb": lb == null ? null : lb,
};
}
class LaunchPayloadVol {
LaunchPayloadVol({
this.cubicMeters,
this.cubicFeet,
});
int cubicMeters;
int cubicFeet;
factory LaunchPayloadVol.fromRawJson(String str) => LaunchPayloadVol.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory LaunchPayloadVol.fromJson(Map<String, dynamic> json) => LaunchPayloadVol(
cubicMeters: json["cubic_meters"] == null ? null : json["cubic_meters"],
cubicFeet: json["cubic_feet"] == null ? null : json["cubic_feet"],
);
Map<String, dynamic> toJson() => {
"cubic_meters": cubicMeters == null ? null : cubicMeters,
"cubic_feet": cubicFeet == null ? null : cubicFeet,
};
}
class PressurizedCapsule {
PressurizedCapsule({
this.payloadVolume,
});
LaunchPayloadVol payloadVolume;
factory PressurizedCapsule.fromRawJson(String str) => PressurizedCapsule.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory PressurizedCapsule.fromJson(Map<String, dynamic> json) => PressurizedCapsule(
payloadVolume: json["payload_volume"] == null ? null : LaunchPayloadVol.fromJson(json["payload_volume"]),
);
Map<String, dynamic> toJson() => {
"payload_volume": payloadVolume == null ? null : payloadVolume.toJson(),
};
}
class Thruster {
Thruster({
this.type,
this.amount,
this.pods,
this.fuel1,
this.fuel2,
this.isp,
this.thrust,
});
String type;
int amount;
int pods;
String fuel1;
String fuel2;
int isp;
Thrust thrust;
factory Thruster.fromRawJson(String str) => Thruster.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Thruster.fromJson(Map<String, dynamic> json) => Thruster(
type: json["type"] == null ? null : json["type"],
amount: json["amount"] == null ? null : json["amount"],
pods: json["pods"] == null ? null : json["pods"],
fuel1: json["fuel_1"] == null ? null : json["fuel_1"],
fuel2: json["fuel_2"] == null ? null : json["fuel_2"],
isp: json["isp"] == null ? null : json["isp"],
thrust: json["thrust"] == null ? null : Thrust.fromJson(json["thrust"]),
);
Map<String, dynamic> toJson() => {
"type": type == null ? null : type,
"amount": amount == null ? null : amount,
"pods": pods == null ? null : pods,
"fuel_1": fuel1 == null ? null : fuel1,
"fuel_2": fuel2 == null ? null : fuel2,
"isp": isp == null ? null : isp,
"thrust": thrust == null ? null : thrust.toJson(),
};
}
class Thrust {
Thrust({
this.kN,
this.lbf,
});
double kN;
int lbf;
factory Thrust.fromRawJson(String str) => Thrust.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Thrust.fromJson(Map<String, dynamic> json) => Thrust(
kN: json["kN"] == null ? null : json["kN"].toDouble(),
lbf: json["lbf"] == null ? null : json["lbf"],
);
Map<String, dynamic> toJson() => {
"kN": kN == null ? null : kN,
"lbf": lbf == null ? null : lbf,
};
}
class Trunk {
Trunk({
this.trunkVolume,
this.cargo,
});
LaunchPayloadVol trunkVolume;
Cargo cargo;
factory Trunk.fromRawJson(String str) => Trunk.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Trunk.fromJson(Map<String, dynamic> json) => Trunk(
trunkVolume: json["trunk_volume"] == null ? null : LaunchPayloadVol.fromJson(json["trunk_volume"]),
cargo: json["cargo"] == null ? null : Cargo.fromJson(json["cargo"]),
);
Map<String, dynamic> toJson() => {
"trunk_volume": trunkVolume == null ? null : trunkVolume.toJson(),
"cargo": cargo == null ? null : cargo.toJson(),
};
}
class Cargo {
Cargo({
this.solarArray,
this.unpressurizedCargo,
});
int solarArray;
bool unpressurizedCargo;
factory Cargo.fromRawJson(String str) => Cargo.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Cargo.fromJson(Map<String, dynamic> json) => Cargo(
solarArray: json["solar_array"] == null ? null : json["solar_array"],
unpressurizedCargo: json["unpressurized_cargo"] == null ? null : json["unpressurized_cargo"],
);
Map<String, dynamic> toJson() => {
"solar_array": solarArray == null ? null : solarArray,
"unpressurized_cargo": unpressurizedCargo == null ? null : unpressurizedCargo,
};
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/dragon/dragon_state.dart
|
import 'package:equatable/equatable.dart';
import 'package:flutter_spacexopedia/bloc/dragon/dragon_model.dart';
abstract class DragonState extends Equatable {
@override
List<Object> get props => ([]);
}
class LoadingDragons extends DragonState {}
class LoadedState extends DragonState {
final List<DragonModel> list;
LoadedState(this.list);
@override
List<Object> get props => [];
}
class ErrorDragonState extends DragonState {
final String errorMessage;
ErrorDragonState(int version, this.errorMessage);
@override
String toString() => 'ErrorDragonState';
}
class NoConnectionDragonState extends DragonState {
final String errorMessage;
NoConnectionDragonState(this.errorMessage);
@override
String toString() => 'ErrorLaunchState';
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/core/core_event.dart
|
import 'dart:async';
import 'dart:developer' as developer;
import 'package:equatable/equatable.dart';
import 'package:flutter_spacexopedia/bloc/core/index.dart';
import 'package:flutter_spacexopedia/resources/repository/core_repository.dart';
import 'package:flutter_spacexopedia/resources/service/api_gatway.dart';
import 'package:get_it/get_it.dart';
import 'package:meta/meta.dart';
@immutable
abstract class CoreEvent extends Equatable {
@override
List<Object> get props => [];
Stream<CoreState> loadAsync(
{CoreState currentState, CoreBloc bloc});
final CoreRepository _coreRepository = CoreRepository(apiGateway: GetIt.instance<ApiGateway>());
}
class LaunchInitial extends CoreEvent {
@override
String toString() => 'LoadCoreEvent';
LaunchInitial();
@override
Stream<CoreState> loadAsync(
{CoreState currentState, CoreBloc bloc}) async* {
try {
if(currentState is LoadedState){
return;
}
yield LoadingCore();
await Future.delayed(Duration(seconds: 1));
final list = await _coreRepository.fetchAllCores();
yield LoadedState(list);
} catch (_, stackTrace) {
developer.log('$_', name: 'LoadCoreEvent', error: _, stackTrace: stackTrace);
yield ErrorCoreState(0, _?.toString());
}
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/core/core_bloc.dart
|
import 'dart:async';
import 'dart:developer' as developer;
import 'dart:io';
import 'package:bloc/bloc.dart';
import 'package:flutter_spacexopedia/bloc/core/index.dart';
class CoreBloc extends Bloc<CoreEvent, CoreState> {
// todo: check singleton for logic in project
static final CoreBloc _coreBlocSingleton = CoreBloc._internal();
factory CoreBloc() {
return _coreBlocSingleton;
}
CoreBloc._internal();
@override
Future<void> close() async {
// dispose objects
await super.close();
}
@override
CoreState get initialState => LoadingCore();
@override
Stream<CoreState> mapEventToState(
CoreEvent event,
) async* {
try {
if (event is LaunchInitial) {
yield* event.loadAsync(currentState: state, bloc: this);
}
} on SocketException catch (_, stackTrace) {
developer.log('$_', name: 'CorehBloc', error: _, stackTrace: stackTrace);
yield NoConnectionDragonState(_.message);
} catch (_, stackTrace) {
developer.log('$_', name: 'CoreBloc', error: _, stackTrace: stackTrace);
yield state;
}
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/core/core_model.dart
|
import 'dart:convert';
class CoreModel {
CoreModel({
this.coreSerial,
this.block,
this.status,
this.originalLaunch,
this.originalLaunchUnix,
this.missions,
this.reuseCount,
this.rtlsAttempts,
this.rtlsLandings,
this.asdsAttempts,
this.asdsLandings,
this.waterLanding,
this.details,
});
String coreSerial;
int block;
Status status;
DateTime originalLaunch;
int originalLaunchUnix;
List<Mission> missions;
int reuseCount;
int rtlsAttempts;
int rtlsLandings;
int asdsAttempts;
int asdsLandings;
bool waterLanding;
String details;
factory CoreModel.fromRawJson(String str) => CoreModel.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory CoreModel.fromJson(Map<String, dynamic> json) => CoreModel(
coreSerial: json["core_serial"] == null ? null : json["core_serial"],
block: json["block"] == null ? null : json["block"],
status: json["status"] == null ? null : statusValues.map[json["status"]],
originalLaunch: json["original_launch"] == null ? null : DateTime.parse(json["original_launch"]),
originalLaunchUnix: json["original_launch_unix"] == null ? null : json["original_launch_unix"],
missions: json["missions"] == null ? null : List<Mission>.from(json["missions"].map((x) => Mission.fromJson(x))),
reuseCount: json["reuse_count"] == null ? null : json["reuse_count"],
rtlsAttempts: json["rtls_attempts"] == null ? null : json["rtls_attempts"],
rtlsLandings: json["rtls_landings"] == null ? null : json["rtls_landings"],
asdsAttempts: json["asds_attempts"] == null ? null : json["asds_attempts"],
asdsLandings: json["asds_landings"] == null ? null : json["asds_landings"],
waterLanding: json["water_landing"] == null ? null : json["water_landing"],
details: json["details"] == null ? null : json["details"],
);
Map<String, dynamic> toJson() => {
"core_serial": coreSerial == null ? null : coreSerial,
"block": block == null ? null : block,
"status": status == null ? null : statusValues.reverse[status],
"original_launch": originalLaunch == null ? null : originalLaunch.toIso8601String(),
"original_launch_unix": originalLaunchUnix == null ? null : originalLaunchUnix,
"missions": missions == null ? null : List<dynamic>.from(missions.map((x) => x.toJson())),
"reuse_count": reuseCount == null ? null : reuseCount,
"rtls_attempts": rtlsAttempts == null ? null : rtlsAttempts,
"rtls_landings": rtlsLandings == null ? null : rtlsLandings,
"asds_attempts": asdsAttempts == null ? null : asdsAttempts,
"asds_landings": asdsLandings == null ? null : asdsLandings,
"water_landing": waterLanding == null ? null : waterLanding,
"details": details == null ? null : details,
};
String getStatus(){
switch (status) {
case Status.ACTIVE: return "Active";
case Status.INACTIVE: return "InActive";
case Status.LOST: return "Lost";
case Status.UNKNOWN: return "Unknown";
default:return "Unknown";
}
}
}
class Mission {
Mission({
this.name,
this.flight,
});
String name;
int flight;
factory Mission.fromRawJson(String str) => Mission.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Mission.fromJson(Map<String, dynamic> json) => Mission(
name: json["name"] == null ? null : json["name"],
flight: json["flight"] == null ? null : json["flight"],
);
Map<String, dynamic> toJson() => {
"name": name == null ? null : name,
"flight": flight == null ? null : flight,
};
}
enum Status { LOST, INACTIVE, UNKNOWN, ACTIVE }
final statusValues = EnumValues({
"active": Status.ACTIVE,
"inactive": Status.INACTIVE,
"lost": Status.LOST,
"unknown": Status.UNKNOWN
});
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/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/core/index.dart
|
export 'core_bloc.dart';
export 'core_event.dart';
export 'core_state.dart';
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/core/core_state.dart
|
import 'package:equatable/equatable.dart';
import 'package:flutter_spacexopedia/bloc/core/core_model.dart';
abstract class CoreState extends Equatable {
@override
List<Object> get props => ([]);
}
class LoadingCore extends CoreState {}
class LoadedState extends CoreState {
final List<CoreModel> list;
LoadedState(this.list);
@override
List<Object> get props => [];
}
class ErrorCoreState extends CoreState {
final String errorMessage;
ErrorCoreState(int version, this.errorMessage);
@override
String toString() => 'ErrorCoreState';
}
class NoConnectionDragonState extends CoreState {
final String errorMessage;
NoConnectionDragonState(this.errorMessage);
@override
String toString() => 'ErrorLaunchState';
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/launches/launch_model.dart
|
import 'dart:convert';
class Launch {
Launch({
this.flightNumber,
this.missionName,
this.missionId,
this.upcoming,
this.launchYear,
this.launchDateUnix,
this.launchDateUtc,
this.launchDateLocal,
this.isTentative,
this.tentativeMaxPrecision,
this.tbd,
this.launchWindow,
this.rocket,
this.ships,
this.telemetry,
this.launchSite,
this.launchSuccess,
this.launchFailureDetails,
this.links,
this.details,
this.staticFireDateUtc,
this.staticFireDateUnix,
this.timeline,
this.crew,
this.lastDateUpdate,
this.lastLlLaunchDate,
this.lastLlUpdate,
this.lastWikiLaunchDate,
this.lastWikiRevision,
this.lastWikiUpdate,
this.launchDateSource,
});
int flightNumber;
String missionName;
List<String> missionId;
bool upcoming;
String launchYear;
int launchDateUnix;
DateTime launchDateUtc;
DateTime launchDateLocal;
bool isTentative;
TentativeMaxPrecision tentativeMaxPrecision;
bool tbd;
int launchWindow;
Rocket rocket;
List<String> ships;
Telemetry telemetry;
LaunchSite launchSite;
bool launchSuccess;
LaunchFailureDetails launchFailureDetails;
Links links;
String details;
DateTime staticFireDateUtc;
int staticFireDateUnix;
Map<String, int> timeline;
List<dynamic> crew;
DateTime lastDateUpdate;
DateTime lastLlLaunchDate;
DateTime lastLlUpdate;
DateTime lastWikiLaunchDate;
String lastWikiRevision;
DateTime lastWikiUpdate;
LaunchDateSource launchDateSource;
factory Launch.fromRawJson(String str) => Launch.fromJson(json.decode(str));
factory Launch.fromJson(Map<String, dynamic> json) => Launch(
flightNumber: json["flight_number"] == null ? null : json["flight_number"],
missionName: json["mission_name"] == null ? null : json["mission_name"],
missionId: json["mission_id"] == null ? null : List<String>.from(json["mission_id"].map((x) => x)),
upcoming: json["upcoming"] == null ? null : json["upcoming"],
launchYear: json["launch_year"] == null ? null : json["launch_year"],
launchDateUnix: json["launch_date_unix"] == null ? null : json["launch_date_unix"],
launchDateUtc: json["launch_date_utc"] == null ? null : DateTime.parse(json["launch_date_utc"]),
launchDateLocal: json["launch_date_local"] == null ? null : DateTime.parse(json["launch_date_local"]),
isTentative: json["is_tentative"] == null ? null : json["is_tentative"],
tentativeMaxPrecision: json["tentative_max_precision"] == null ? null : tentativeMaxPrecisionValues.map[json["tentative_max_precision"]],
tbd: json["tbd"] == null ? null : json["tbd"],
launchWindow: json["launch_window"] == null ? null : json["launch_window"],
rocket: json["rocket"] == null ? null : Rocket.fromJson(json["rocket"]),
ships: json["ships"] == null ? null : List<String>.from(json["ships"].map((x) => x)),
telemetry: json["telemetry"] == null ? null : Telemetry.fromJson(json["telemetry"]),
launchSite: json["launch_site"] == null ? null : LaunchSite.fromJson(json["launch_site"]),
launchSuccess: json["launch_success"] == null ? null : json["launch_success"],
launchFailureDetails: json["launch_failure_details"] == null ? null : LaunchFailureDetails.fromJson(json["launch_failure_details"]),
links: json["links"] == null ? null : Links.fromJson(json["links"]),
details: json["details"] == null ? null : json["details"],
staticFireDateUtc: json["static_fire_date_utc"] == null ? null : DateTime.parse(json["static_fire_date_utc"]),
staticFireDateUnix: json["static_fire_date_unix"] == null ? null : json["static_fire_date_unix"],
timeline: json["timeline"] == null ? null : Map.from(json["timeline"]).map((k, v) => MapEntry<String, int>(k, v == null ? null : v)),
crew: json["crew"] == null ? null : List<dynamic>.from(json["crew"].map((x) => x)),
lastDateUpdate: json["last_date_update"] == null ? null : DateTime.parse(json["last_date_update"]),
lastLlLaunchDate: json["last_ll_launch_date"] == null ? null : DateTime.parse(json["last_ll_launch_date"]),
lastLlUpdate: json["last_ll_update"] == null ? null : DateTime.parse(json["last_ll_update"]),
lastWikiLaunchDate: json["last_wiki_launch_date"] == null ? null : DateTime.parse(json["last_wiki_launch_date"]),
lastWikiRevision: json["last_wiki_revision"] == null ? null : json["last_wiki_revision"],
lastWikiUpdate: json["last_wiki_update"] == null ? null : DateTime.parse(json["last_wiki_update"]),
launchDateSource: json["launch_date_source"] == null ? null : launchDateSourceValues.map[json["launch_date_source"]],
);
}
enum LaunchDateSource { WIKI, LAUNCH_LIBRARY }
final launchDateSourceValues = EnumValues({
"launch_library": LaunchDateSource.LAUNCH_LIBRARY,
"wiki": LaunchDateSource.WIKI
});
class LaunchFailureDetails {
LaunchFailureDetails({
this.time,
this.altitude,
this.reason,
});
int time;
int altitude;
String reason;
factory LaunchFailureDetails.fromRawJson(String str) => LaunchFailureDetails.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory LaunchFailureDetails.fromJson(Map<String, dynamic> json) => LaunchFailureDetails(
time: json["time"] == null ? null : json["time"],
altitude: json["altitude"] == null ? null : json["altitude"],
reason: json["reason"] == null ? null : json["reason"],
);
Map<String, dynamic> toJson() => {
"time": time == null ? null : time,
"altitude": altitude == null ? null : altitude,
"reason": reason == null ? null : reason,
};
}
class LaunchSite {
LaunchSite({
this.siteId,
this.siteName,
this.siteNameLong,
});
String siteId;
String siteName;
String siteNameLong;
factory LaunchSite.fromRawJson(String str) => LaunchSite.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory LaunchSite.fromJson(Map<String, dynamic> json) => LaunchSite(
siteId: json["site_id"] == null ? null : json["site_id"],
siteName: json["site_name"] == null ? null : json["site_name"],
siteNameLong: json["site_name_long"] == null ? null : json["site_name_long"],
);
Map<String, dynamic> toJson() => {
"site_id": siteId == null ? null : siteId,
"site_name": siteName == null ? null : siteName,
"site_name_long": siteNameLong == null ? null : siteNameLong,
};
}
class Links {
Links({
this.missionPatch,
this.missionPatchSmall,
this.redditCampaign,
this.redditLaunch,
this.redditRecovery,
this.redditMedia,
this.presskit,
this.articleLink,
this.wikipedia,
this.videoLink,
this.youtubeId,
this.flickrImages,
});
String missionPatch;
String missionPatchSmall;
String redditCampaign;
String redditLaunch;
String redditRecovery;
String redditMedia;
String presskit;
String articleLink;
String wikipedia;
String videoLink;
String youtubeId;
List<String> flickrImages;
factory Links.fromRawJson(String str) => Links.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Links.fromJson(Map<String, dynamic> json) => Links(
missionPatch: json["mission_patch"] == null ? null : json["mission_patch"],
missionPatchSmall: json["mission_patch_small"] == null ? null : json["mission_patch_small"],
redditCampaign: json["reddit_campaign"] == null ? null : json["reddit_campaign"],
redditLaunch: json["reddit_launch"] == null ? null : json["reddit_launch"],
redditRecovery: json["reddit_recovery"] == null ? null : json["reddit_recovery"],
redditMedia: json["reddit_media"] == null ? null : json["reddit_media"],
presskit: json["presskit"] == null ? null : json["presskit"],
articleLink: json["article_link"] == null ? null : json["article_link"],
wikipedia: json["wikipedia"] == null ? null : json["wikipedia"],
videoLink: json["video_link"] == null ? null : json["video_link"],
youtubeId: json["youtube_id"] == null ? null : json["youtube_id"],
flickrImages: json["flickr_images"] == null ? null : List<String>.from(json["flickr_images"].map((x) => x)),
);
Map<String, dynamic> toJson() => {
"mission_patch": missionPatch == null ? null : missionPatch,
"mission_patch_small": missionPatchSmall == null ? null : missionPatchSmall,
"reddit_campaign": redditCampaign == null ? null : redditCampaign,
"reddit_launch": redditLaunch == null ? null : redditLaunch,
"reddit_recovery": redditRecovery == null ? null : redditRecovery,
"reddit_media": redditMedia == null ? null : redditMedia,
"presskit": presskit == null ? null : presskit,
"article_link": articleLink == null ? null : articleLink,
"wikipedia": wikipedia == null ? null : wikipedia,
"video_link": videoLink == null ? null : videoLink,
"youtube_id": youtubeId == null ? null : youtubeId,
"flickr_images": flickrImages == null ? null : List<dynamic>.from(flickrImages.map((x) => x)),
};
}
class Rocket {
Rocket({
this.rocketId,
this.rocketName,
this.rocketType,
this.firstStage,
this.secondStage,
this.fairings,
});
String rocketId;
String rocketName;
String rocketType;
FirstStage firstStage;
SecondStage secondStage;
Fairings fairings;
factory Rocket.fromRawJson(String str) => Rocket.fromJson(json.decode(str));
factory Rocket.fromJson(Map<String, dynamic> json) => Rocket(
rocketId: json["rocket_id"] == null ? null : json["rocket_id"],
rocketName: json["rocket_name"] == null ? null : json["rocket_name"],
rocketType: json["rocket_type"] == null ? null : json["rocket_type"],
firstStage: json["first_stage"] == null ? null : FirstStage.fromJson(json["first_stage"]),
secondStage: json["second_stage"] == null ? null : SecondStage.fromJson(json["second_stage"]),
fairings: json["fairings"] == null ? null : Fairings.fromJson(json["fairings"]),
);
}
class Fairings {
Fairings({
this.reused,
this.recoveryAttempt,
this.recovered,
this.ship,
});
bool reused;
bool recoveryAttempt;
bool recovered;
Ship ship;
factory Fairings.fromRawJson(String str) => Fairings.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Fairings.fromJson(Map<String, dynamic> json) => Fairings(
reused: json["reused"] == null ? null : json["reused"],
recoveryAttempt: json["recovery_attempt"] == null ? null : json["recovery_attempt"],
recovered: json["recovered"] == null ? null : json["recovered"],
ship: json["ship"] == null ? null : shipValues.map[json["ship"]],
);
Map<String, dynamic> toJson() => {
"reused": reused == null ? null : reused,
"recovery_attempt": recoveryAttempt == null ? null : recoveryAttempt,
"recovered": recovered == null ? null : recovered,
"ship": ship == null ? null : shipValues.reverse[ship],
};
}
enum Ship { GOMSTREE, GOSEARCHER }
final shipValues = EnumValues({
"GOMSTREE": Ship.GOMSTREE,
"GOSEARCHER": Ship.GOSEARCHER
});
class FirstStage {
FirstStage({
this.cores,
});
List<Core> cores;
factory FirstStage.fromRawJson(String str) => FirstStage.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory FirstStage.fromJson(Map<String, dynamic> json) => FirstStage(
cores: json["cores"] == null ? null : List<Core>.from(json["cores"].map((x) => Core.fromJson(x))),
);
Map<String, dynamic> toJson() => {
"cores": cores == null ? null : List<dynamic>.from(cores.map((x) => x.toJson())),
};
}
class Core {
Core({
this.coreSerial,
this.flight,
this.block,
this.gridfins,
this.legs,
this.reused,
this.landSuccess,
this.landingIntent,
this.landingType,
this.landingVehicle,
});
String coreSerial;
int flight;
int block;
bool gridfins;
bool legs;
bool reused;
bool landSuccess;
bool landingIntent;
String landingType;
String landingVehicle;
factory Core.fromRawJson(String str) => Core.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Core.fromJson(Map<String, dynamic> json) => Core(
coreSerial: json["core_serial"] == null ? null : json["core_serial"],
flight: json["flight"] == null ? null : json["flight"],
block: json["block"] == null ? null : json["block"],
gridfins: json["gridfins"] == null ? null : json["gridfins"],
legs: json["legs"] == null ? null : json["legs"],
reused: json["reused"] == null ? null : json["reused"],
landSuccess: json["land_success"] == null ? null : json["land_success"],
landingIntent: json["landing_intent"] == null ? null : json["landing_intent"],
landingType: json["landing_type"] == null ? null : json["landing_type"],
landingVehicle: json["landing_vehicle"] == null ? null : json["landing_vehicle"],
);
Map<String, dynamic> toJson() => {
"core_serial": coreSerial == null ? null : coreSerial,
"flight": flight == null ? null : flight,
"block": block == null ? null : block,
"gridfins": gridfins == null ? null : gridfins,
"legs": legs == null ? null : legs,
"reused": reused == null ? null : reused,
"land_success": landSuccess == null ? null : landSuccess,
"landing_intent": landingIntent == null ? null : landingIntent,
"landing_type": landingType == null ? null : landingType,
"landing_vehicle": landingVehicle == null ? null : landingVehicle,
};
}
//
class SecondStage {
SecondStage({
this.block,
this.payloads,
});
int block;
List<Payload> payloads;
factory SecondStage.fromRawJson(String str) => SecondStage.fromJson(json.decode(str));
factory SecondStage.fromJson(Map<String, dynamic> json) => SecondStage(
block: json["block"] == null ? null : json["block"],
payloads: json["payloads"] == null ? null : List<Payload>.from(json["payloads"].map((x) => Payload.fromJson(x))),
);
}
class Payload {
Payload({
this.payloadId,
this.noradId,
this.reused,
this.customers,
this.nationality,
this.manufacturer,
this.payloadType,
this.payloadMassKg,
this.payloadMassLbs,
this.orbit,
this.orbitParams,
this.capSerial,
this.massReturnedKg,
this.massReturnedLbs,
this.flightTimeSec,
this.cargoManifest,
this.uid,
});
String payloadId;
List<int> noradId;
bool reused;
List<String> customers;
String nationality;
String manufacturer;
PayloadType payloadType;
double payloadMassKg;
double payloadMassLbs;
String orbit;
OrbitParams orbitParams;
String capSerial;
double massReturnedKg;
double massReturnedLbs;
int flightTimeSec;
String cargoManifest;
String uid;
factory Payload.fromRawJson(String str) => Payload.fromJson(json.decode(str));
factory Payload.fromJson(Map<String, dynamic> json) => Payload(
payloadId: json["payload_id"] == null ? null : json["payload_id"],
noradId: json["norad_id"] == null ? null : List<int>.from(json["norad_id"].map((x) => x)),
reused: json["reused"] == null ? null : json["reused"],
customers: json["customers"] == null ? null : List<String>.from(json["customers"].map((x) => x)),
nationality: json["nationality"] == null ? null : json["nationality"],
manufacturer: json["manufacturer"] == null ? null : json["manufacturer"],
payloadType: json["payload_type"] == null ? null : payloadTypeValues.map[json["payload_type"]],
payloadMassKg: json["payload_mass_kg"] == null ? null : json["payload_mass_kg"].toDouble(),
payloadMassLbs: json["payload_mass_lbs"] == null ? null : json["payload_mass_lbs"].toDouble(),
orbit: json["orbit"] == null ? null : json["orbit"],
orbitParams: json["orbit_params"] == null ? null : OrbitParams.fromJson(json["orbit_params"]),
capSerial: json["cap_serial"] == null ? null : json["cap_serial"],
massReturnedKg: json["mass_returned_kg"] == null ? null : json["mass_returned_kg"].toDouble(),
massReturnedLbs: json["mass_returned_lbs"] == null ? null : json["mass_returned_lbs"].toDouble(),
flightTimeSec: json["flight_time_sec"] == null ? null : json["flight_time_sec"],
cargoManifest: json["cargo_manifest"] == null ? null : json["cargo_manifest"],
uid: json["uid"] == null ? null : json["uid"],
);
}
class OrbitParams {
OrbitParams({
this.referenceSystem,
this.regime,
this.longitude,
this.semiMajorAxisKm,
this.eccentricity,
this.periapsisKm,
this.apoapsisKm,
this.inclinationDeg,
this.periodMin,
this.lifespanYears,
this.epoch,
this.meanMotion,
this.raan,
this.argOfPericenter,
this.meanAnomaly,
});
String referenceSystem;
String regime;
double longitude;
double semiMajorAxisKm;
double eccentricity;
double periapsisKm;
double apoapsisKm;
double inclinationDeg;
double periodMin;
double lifespanYears;
DateTime epoch;
double meanMotion;
double raan;
double argOfPericenter;
double meanAnomaly;
factory OrbitParams.fromRawJson(String str) => OrbitParams.fromJson(json.decode(str));
factory OrbitParams.fromJson(Map<String, dynamic> json) => OrbitParams(
referenceSystem: json["reference_system"] == null ? null : json["reference_system"],
regime: json["regime"] == null ? null : json["regime"],
longitude: json["longitude"] == null ? null : json["longitude"].toDouble(),
semiMajorAxisKm: json["semi_major_axis_km"] == null ? null : json["semi_major_axis_km"].toDouble(),
eccentricity: json["eccentricity"] == null ? null : json["eccentricity"].toDouble(),
periapsisKm: json["periapsis_km"] == null ? null : json["periapsis_km"].toDouble(),
apoapsisKm: json["apoapsis_km"] == null ? null : json["apoapsis_km"].toDouble(),
inclinationDeg: json["inclination_deg"] == null ? null : json["inclination_deg"].toDouble(),
periodMin: json["period_min"] == null ? null : json["period_min"].toDouble(),
lifespanYears: json["lifespan_years"] == null ? null : json["lifespan_years"].toDouble(),
epoch: json["epoch"] == null ? null : DateTime.parse(json["epoch"]),
meanMotion: json["mean_motion"] == null ? null : json["mean_motion"].toDouble(),
raan: json["raan"] == null ? null : json["raan"].toDouble(),
argOfPericenter: json["arg_of_pericenter"] == null ? null : json["arg_of_pericenter"].toDouble(),
meanAnomaly: json["mean_anomaly"] == null ? null : json["mean_anomaly"].toDouble(),
);
}
// enum ReferenceSystem { GEOCENTRIC, HELIOCENTRIC, HIGHLY_ELLIPTICAL }
// final referenceSystemValues = EnumValues({
// "geocentric": ReferenceSystem.GEOCENTRIC,
// "heliocentric": ReferenceSystem.HELIOCENTRIC,
// "highly-elliptical": ReferenceSystem.HIGHLY_ELLIPTICAL
// });
// enum Regime { LOW_EARTH, GEOSTATIONARY, L1_POINT, GEOSYNCHRONOUS, SUN_SYNCHRONOUS, HIGH_EARTH, SEMI_SYNCHRONOUS, HIGHLY_ELLIPTICAL, VERY_LOW_EARTH, MEDIUM_EARTH, SUB_ORBITAL }
// final regimeValues = EnumValues({
// "geostationary": Regime.GEOSTATIONARY,
// "geosynchronous": Regime.GEOSYNCHRONOUS,
// "highly-elliptical": Regime.HIGHLY_ELLIPTICAL,
// "high-earth": Regime.HIGH_EARTH,
// "L1-point": Regime.L1_POINT,
// "low-earth": Regime.LOW_EARTH,
// "medium-earth": Regime.MEDIUM_EARTH,
// "semi-synchronous": Regime.SEMI_SYNCHRONOUS,
// "sub-orbital": Regime.SUB_ORBITAL,
// "sun-synchronous": Regime.SUN_SYNCHRONOUS,
// "very-low-earth": Regime.VERY_LOW_EARTH
// });
enum PayloadType { SATELLITE, DRAGON_BOILERPLATE, DRAGON_10, DRAGON_11, LANDER, CREW_DRAGON }
final payloadTypeValues = EnumValues({
"Crew Dragon": PayloadType.CREW_DRAGON,
"Dragon 1.0": PayloadType.DRAGON_10,
"Dragon 1.1": PayloadType.DRAGON_11,
"Dragon Boilerplate": PayloadType.DRAGON_BOILERPLATE,
"Lander": PayloadType.LANDER,
"Satellite": PayloadType.SATELLITE
});
class Telemetry {
Telemetry({
this.flightClub,
});
String flightClub;
factory Telemetry.fromRawJson(String str) => Telemetry.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Telemetry.fromJson(Map<String, dynamic> json) => Telemetry(
flightClub: json["flight_club"] == null ? null : json["flight_club"],
);
Map<String, dynamic> toJson() => {
"flight_club": flightClub == null ? null : flightClub,
};
}
enum TentativeMaxPrecision { HOUR, MONTH, DAY, YEAR, QUARTER }
final tentativeMaxPrecisionValues = EnumValues({
"day": TentativeMaxPrecision.DAY,
"hour": TentativeMaxPrecision.HOUR,
"month": TentativeMaxPrecision.MONTH,
"quarter": TentativeMaxPrecision.QUARTER,
"year": TentativeMaxPrecision.YEAR
});
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/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/launches/bloc.dart
|
export 'launch_bloc.dart';
export 'launch_state.dart';
export 'launch_event.dart';
export 'launch_model.dart';
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/launches/launch_bloc.dart
|
import 'dart:async';
import 'dart:io';
import 'package:bloc/bloc.dart';
import 'dart:developer' as developer;
import 'package:flutter_spacexopedia/bloc/launches/bloc.dart';
import 'package:flutter_spacexopedia/resources/repository/launch_repository.dart';
class LaunchBloc extends Bloc<LaunchEvent, LaunchState> {
final LaunchRepository repository;
LaunchBloc(this.repository);
LaunchState get initialState => Loading();
@override
Stream<LaunchState> mapEventToState(LaunchEvent event) async* {
try {
if (event is LaunchInitial) {
yield Loading();
final launchs = await repository.fetchAllLaunch();
launchs.sort((x,y) => y.launchDateUtc.compareTo(x.launchDateUtc));
if (launchs != null) {
yield LoadedState(launchs);
}
} else {
throw UnsupportedError('Unsupported event $event');
}
} on SocketException catch (_,stackTrace){
developer.log('$_', name: 'LaunchBloc', error: _, stackTrace: stackTrace);
yield NoConnectionDragonState(_.message);
}
catch (_, stackTrace) {
developer.log('$_.', name: 'LaunchBloc', error: _, stackTrace: stackTrace);
yield state;
}
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/launches/launch_state.dart
|
import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';
import 'launch_model.dart';
@immutable
abstract class LaunchState extends Equatable {
@override
List<Object> get props => [];
}
class Loading extends LaunchState {}
class LoadedState extends LaunchState {
final List<Launch> allLaunch;
LoadedState(this.allLaunch);
@override
List<Object> get props => ["Total launch ${allLaunch.length}"];
}
class ErrorDragonState extends LaunchState {
final String errorMessage;
ErrorDragonState(this.errorMessage);
@override
String toString() => 'ErrorLaunchState';
}
class NoConnectionDragonState extends LaunchState {
final String errorMessage;
NoConnectionDragonState(this.errorMessage);
@override
String toString() => 'ErrorLaunchState';
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/launches/launch_event.dart
|
import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';
@immutable
abstract class LaunchEvent extends Equatable {
@override
List<Object> get props => [];
}
class LaunchInitial extends LaunchEvent {}
class SelectedLaunch extends LaunchEvent{
final int flightNumber;
SelectedLaunch(this.flightNumber);
@override
List<Object> get props => ["Select flight: $flightNumber"];
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/roadster/roadster_bloc.dart
|
import 'dart:async';
import 'dart:developer' as developer;
import 'dart:io';
import 'package:bloc/bloc.dart';
import 'package:flutter_spacexopedia/bloc/roadster/index.dart';
class RoadsterBloc extends Bloc<RoadsterEvent, RoadsterState> {
// todo: check singleton for logic in project
static final RoadsterBloc _roadsterBlocSingleton = RoadsterBloc._internal();
factory RoadsterBloc() {
return _roadsterBlocSingleton;
}
RoadsterBloc._internal();
@override
Future<void> close() async {
// dispose objects
await super.close();
}
@override
RoadsterState get initialState => LoadingRoadster();
@override
Stream<RoadsterState> mapEventToState(
RoadsterEvent event,
) async* {
try {
if (event is LaunchInitial) {
yield* event.loadAsync(currentState: state, bloc: this);
}
} on SocketException catch (_, stackTrace) {
developer.log('$_', name: 'LaunchBloc', error: _, stackTrace: stackTrace);
yield NoConnectionDragonState(_.message);
} catch (_, stackTrace) {
developer.log('$_',
name: 'RoadsterBloc', error: _, stackTrace: stackTrace);
yield state;
}
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/roadster/roadster_model.dart
|
import 'dart:convert';
class RoadsterModel {
RoadsterModel({
this.name,
this.launchDateUtc,
this.launchDateUnix,
this.launchMassKg,
this.launchMassLbs,
this.noradId,
this.epochJd,
this.orbitType,
this.apoapsisAu,
this.periapsisAu,
this.semiMajorAxisAu,
this.eccentricity,
this.inclination,
this.longitude,
this.periapsisArg,
this.periodDays,
this.speedKph,
this.speedMph,
this.earthDistanceKm,
this.earthDistanceMi,
this.marsDistanceKm,
this.marsDistanceMi,
this.flickrImages,
this.wikipedia,
this.video,
this.details,
});
String name;
DateTime launchDateUtc;
int launchDateUnix;
int launchMassKg;
int launchMassLbs;
int noradId;
double epochJd;
String orbitType;
double apoapsisAu;
double periapsisAu;
double semiMajorAxisAu;
double eccentricity;
double inclination;
double longitude;
double periapsisArg;
double periodDays;
double speedKph;
double speedMph;
double earthDistanceKm;
double earthDistanceMi;
double marsDistanceKm;
double marsDistanceMi;
List<String> flickrImages;
String wikipedia;
String video;
String details;
factory RoadsterModel.fromRawJson(String str) => RoadsterModel.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory RoadsterModel.fromJson(Map<String, dynamic> json) => RoadsterModel(
name: json["name"] == null ? null : json["name"],
launchDateUtc: json["launch_date_utc"] == null ? null : DateTime.parse(json["launch_date_utc"]),
launchDateUnix: json["launch_date_unix"] == null ? null : json["launch_date_unix"],
launchMassKg: json["launch_mass_kg"] == null ? null : json["launch_mass_kg"],
launchMassLbs: json["launch_mass_lbs"] == null ? null : json["launch_mass_lbs"],
noradId: json["norad_id"] == null ? null : json["norad_id"],
epochJd: json["epoch_jd"] == null ? null : json["epoch_jd"].toDouble(),
orbitType: json["orbit_type"] == null ? null : json["orbit_type"],
apoapsisAu: json["apoapsis_au"] == null ? null : json["apoapsis_au"].toDouble(),
periapsisAu: json["periapsis_au"] == null ? null : json["periapsis_au"].toDouble(),
semiMajorAxisAu: json["semi_major_axis_au"] == null ? null : json["semi_major_axis_au"].toDouble(),
eccentricity: json["eccentricity"] == null ? null : json["eccentricity"].toDouble(),
inclination: json["inclination"] == null ? null : json["inclination"].toDouble(),
longitude: json["longitude"] == null ? null : json["longitude"].toDouble(),
periapsisArg: json["periapsis_arg"] == null ? null : json["periapsis_arg"].toDouble(),
periodDays: json["period_days"] == null ? null : json["period_days"].toDouble(),
speedKph: json["speed_kph"] == null ? null : json["speed_kph"].toDouble(),
speedMph: json["speed_mph"] == null ? null : json["speed_mph"].toDouble(),
earthDistanceKm: json["earth_distance_km"] == null ? null : json["earth_distance_km"].toDouble(),
earthDistanceMi: json["earth_distance_mi"] == null ? null : json["earth_distance_mi"].toDouble(),
marsDistanceKm: json["mars_distance_km"] == null ? null : json["mars_distance_km"].toDouble(),
marsDistanceMi: json["mars_distance_mi"] == null ? null : json["mars_distance_mi"].toDouble(),
flickrImages: json["flickr_images"] == null ? null : List<String>.from(json["flickr_images"].map((x) => x)),
wikipedia: json["wikipedia"] == null ? null : json["wikipedia"],
video: json["video"] == null ? null : json["video"],
details: json["details"] == null ? null : json["details"],
);
Map<String, dynamic> toJson() => {
"name": name == null ? null : name,
"launch_date_utc": launchDateUtc == null ? null : launchDateUtc.toIso8601String(),
"launch_date_unix": launchDateUnix == null ? null : launchDateUnix,
"launch_mass_kg": launchMassKg == null ? null : launchMassKg,
"launch_mass_lbs": launchMassLbs == null ? null : launchMassLbs,
"norad_id": noradId == null ? null : noradId,
"epoch_jd": epochJd == null ? null : epochJd,
"orbit_type": orbitType == null ? null : orbitType,
"apoapsis_au": apoapsisAu == null ? null : apoapsisAu,
"periapsis_au": periapsisAu == null ? null : periapsisAu,
"semi_major_axis_au": semiMajorAxisAu == null ? null : semiMajorAxisAu,
"eccentricity": eccentricity == null ? null : eccentricity,
"inclination": inclination == null ? null : inclination,
"longitude": longitude == null ? null : longitude,
"periapsis_arg": periapsisArg == null ? null : periapsisArg,
"period_days": periodDays == null ? null : periodDays,
"speed_kph": speedKph == null ? null : speedKph,
"speed_mph": speedMph == null ? null : speedMph,
"earth_distance_km": earthDistanceKm == null ? null : earthDistanceKm,
"earth_distance_mi": earthDistanceMi == null ? null : earthDistanceMi,
"mars_distance_km": marsDistanceKm == null ? null : marsDistanceKm,
"mars_distance_mi": marsDistanceMi == null ? null : marsDistanceMi,
"flickr_images": flickrImages == null ? null : List<dynamic>.from(flickrImages.map((x) => x)),
"wikipedia": wikipedia == null ? null : wikipedia,
"video": video == null ? null : video,
"details": details == null ? null : details,
};
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/roadster/roadster_state.dart
|
import 'package:equatable/equatable.dart';
import 'package:flutter_spacexopedia/bloc/roadster/roadster_model.dart';
abstract class RoadsterState extends Equatable {
@override
List<Object> get props => ([]);
}
class LoadingRoadster extends RoadsterState {}
class LoadedState extends RoadsterState {
final RoadsterModel model;
LoadedState(this.model);
@override
List<Object> get props => [];
}
class ErrorRoadsterState extends RoadsterState {
final String error;
ErrorRoadsterState(this.error);
}
class NoConnectionDragonState extends RoadsterState {
final String errorMessage;
NoConnectionDragonState(this.errorMessage);
@override
String toString() => 'ErrorLaunchState';
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/roadster/roadster_event.dart
|
import 'dart:async';
import 'dart:developer' as developer;
import 'package:equatable/equatable.dart';
import 'package:flutter_spacexopedia/bloc/roadster/index.dart';
import 'package:flutter_spacexopedia/resources/repository/roadster_repository.dart';
import 'package:flutter_spacexopedia/resources/service/api_gatway.dart';
import 'package:get_it/get_it.dart';
import 'package:meta/meta.dart';
@immutable
abstract class RoadsterEvent extends Equatable{
@override
List<Object> get props => [];
Stream<RoadsterState> loadAsync(
{RoadsterState currentState, RoadsterBloc bloc});
final RoadsterRepository _roadsterRepository = RoadsterRepository(apiGateway: GetIt.instance<ApiGateway>());
}
class LaunchInitial extends RoadsterEvent {
@override
String toString() => 'LoadRoadsterEvent';
LaunchInitial();
@override
Stream<RoadsterState> loadAsync(
{RoadsterState currentState, RoadsterBloc bloc}) async* {
try {
if(currentState is LoadedState){
return;
}
yield LoadingRoadster();
await Future.delayed(Duration(seconds: 1));
final model = await _roadsterRepository.fetchAllLaunch();
yield LoadedState(model);
} catch (_, stackTrace) {
developer.log('$_', name: 'LoadRoadsterEvent', error: _, stackTrace: stackTrace);
yield ErrorRoadsterState(_?.toString());
}
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/roadster/index.dart
|
export 'roadster_bloc.dart';
export 'roadster_event.dart';
export 'roadster_state.dart';
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/rocket/rocket_state.dart
|
import 'package:equatable/equatable.dart';
import 'package:flutter_spacexopedia/bloc/rocket/rocket_model.dart';
abstract class RocketState extends Equatable {
final List propss;
RocketState([this.propss]);
@override
List<Object> get props => (propss ?? []);
}
class LoadingRockets extends RocketState {}
/// Initialized
class LoadedRocketState extends RocketState {
final List<RocketModel> list;
LoadedRocketState(this.list) : super([list]);
@override
List<Object> get props => [];
}
class ErrorRocketState extends RocketState {
final String errorMessage;
ErrorRocketState(this.errorMessage) : super([errorMessage]);
@override
String toString() => 'ErrorRocketState';
}
class NoConnectionDragonState extends RocketState {
final String errorMessage;
NoConnectionDragonState(this.errorMessage);
@override
String toString() => 'ErrorLaunchState';
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/rocket/rocket_event.dart
|
import 'dart:async';
import 'dart:developer' as developer;
import 'package:equatable/equatable.dart';
import 'package:flutter_spacexopedia/bloc/rocket/index.dart';
import 'package:flutter_spacexopedia/resources/repository/rocket_repository.dart';
import 'package:flutter_spacexopedia/resources/service/api_gatway.dart';
import 'package:get_it/get_it.dart';
import 'package:meta/meta.dart';
@immutable
abstract class RocketEvent extends Equatable {
@override
List<Object> get props => [];
Stream<RocketState> loadAsync({RocketState currentState, RocketBloc bloc});
final RocketRepository _roadsterRepository =
RocketRepository(apiGateway: GetIt.instance<ApiGateway>());
}
class LaunchInitial extends RocketEvent {
@override
Stream<RocketState> loadAsync(
{RocketState currentState, RocketBloc bloc}) async* {
try {
if (currentState is LoadedRocketState) {
return;
}
yield LoadingRockets();
final rockets = await _roadsterRepository.fetchAllRocket();
yield LoadedRocketState(rockets);
} catch (_, stackTrace) {
developer.log('$_',
name: 'LoadRocketEvent', error: _, stackTrace: stackTrace);
yield ErrorRocketState(_?.toString());
}
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/rocket/rocket_bloc.dart
|
import 'dart:async';
import 'dart:developer' as developer;
import 'dart:io';
import 'package:bloc/bloc.dart';
import 'package:flutter_spacexopedia/bloc/rocket/index.dart';
class RocketBloc extends Bloc<RocketEvent, RocketState> {
static final RocketBloc _roadsterBlocSingleton = RocketBloc._internal();
factory RocketBloc() {
return _roadsterBlocSingleton;
}
RocketBloc._internal();
@override
Future<void> close() async{
// dispose objects
await super.close();
}
@override
RocketState get initialState => LoadingRockets();
@override
Stream<RocketState> mapEventToState(
RocketEvent event,
) async* {
try {
if (event is LaunchInitial) {
yield* event.loadAsync(currentState: state, bloc: this);
}
} on SocketException catch (_,stackTrace){
developer.log('$_', name: 'LaunchBloc', error: _, stackTrace: stackTrace);
yield NoConnectionDragonState(_.message);
}catch (_, stackTrace) {
developer.log('$_', name: 'RocketBloc', error: _, stackTrace: stackTrace);
yield state;
}
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/rocket/index.dart
|
export 'rocket_bloc.dart';
export 'rocket_event.dart';
export 'rocket_state.dart';
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/rocket/rocket_model.dart
|
import 'dart:convert';
class RocketModel {
RocketModel({
this.id,
this.active,
this.stages,
this.boosters,
this.costPerLaunch,
this.successRatePct,
this.firstFlight,
this.country,
this.company,
this.height,
this.diameter,
this.mass,
this.payloadWeights,
this.firstStage,
this.secondStage,
this.engines,
this.landingLegs,
this.flickrImages,
this.wikipedia,
this.description,
this.rocketId,
this.rocketName,
this.rocketType,
});
int id;
bool active;
int stages;
int boosters;
int costPerLaunch;
int successRatePct;
DateTime firstFlight;
String country;
String company;
Diameter height;
Diameter diameter;
Mass mass;
List<PayloadWeight> payloadWeights;
FirstStage firstStage;
SecondStage secondStage;
Engines engines;
LandingLegs landingLegs;
List<String> flickrImages;
String wikipedia;
String description;
String rocketId;
String rocketName;
String rocketType;
factory RocketModel.fromRawJson(String str) => RocketModel.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory RocketModel.fromJson(Map<String, dynamic> json) => RocketModel(
id: json["id"] == null ? null : json["id"],
active: json["active"] == null ? null : json["active"],
stages: json["stages"] == null ? null : json["stages"],
boosters: json["boosters"] == null ? null : json["boosters"],
costPerLaunch: json["cost_per_launch"] == null ? null : json["cost_per_launch"],
successRatePct: json["success_rate_pct"] == null ? null : json["success_rate_pct"],
firstFlight: json["first_flight"] == null ? null : DateTime.parse(json["first_flight"]),
country: json["country"] == null ? null : json["country"],
company: json["company"] == null ? null : json["company"],
height: json["height"] == null ? null : Diameter.fromJson(json["height"]),
diameter: json["diameter"] == null ? null : Diameter.fromJson(json["diameter"]),
mass: json["mass"] == null ? null : Mass.fromJson(json["mass"]),
payloadWeights: json["payload_weights"] == null ? null : List<PayloadWeight>.from(json["payload_weights"].map((x) => PayloadWeight.fromJson(x))),
firstStage: json["first_stage"] == null ? null : FirstStage.fromJson(json["first_stage"]),
secondStage: json["second_stage"] == null ? null : SecondStage.fromJson(json["second_stage"]),
engines: json["engines"] == null ? null : Engines.fromJson(json["engines"]),
landingLegs: json["landing_legs"] == null ? null : LandingLegs.fromJson(json["landing_legs"]),
flickrImages: json["flickr_images"] == null ? null : List<String>.from(json["flickr_images"].map((x) => x)),
wikipedia: json["wikipedia"] == null ? null : json["wikipedia"],
description: json["description"] == null ? null : json["description"],
rocketId: json["rocket_id"] == null ? null : json["rocket_id"],
rocketName: json["rocket_name"] == null ? null : json["rocket_name"],
rocketType: json["rocket_type"] == null ? null : json["rocket_type"],
);
Map<String, dynamic> toJson() => {
"id": id == null ? null : id,
"active": active == null ? null : active,
"stages": stages == null ? null : stages,
"boosters": boosters == null ? null : boosters,
"cost_per_launch": costPerLaunch == null ? null : costPerLaunch,
"success_rate_pct": successRatePct == null ? null : successRatePct,
"first_flight": firstFlight == null ? null : "${firstFlight.year.toString().padLeft(4, '0')}-${firstFlight.month.toString().padLeft(2, '0')}-${firstFlight.day.toString().padLeft(2, '0')}",
"country": country == null ? null : country,
"company": company == null ? null : company,
"height": height == null ? null : height.toJson(),
"diameter": diameter == null ? null : diameter.toJson(),
"mass": mass == null ? null : mass.toJson(),
"payload_weights": payloadWeights == null ? null : List<dynamic>.from(payloadWeights.map((x) => x.toJson())),
"first_stage": firstStage == null ? null : firstStage.toJson(),
"second_stage": secondStage == null ? null : secondStage.toJson(),
"engines": engines == null ? null : engines.toJson(),
"landing_legs": landingLegs == null ? null : landingLegs.toJson(),
"flickr_images": flickrImages == null ? null : List<dynamic>.from(flickrImages.map((x) => x)),
"wikipedia": wikipedia == null ? null : wikipedia,
"description": description == null ? null : description,
"rocket_id": rocketId == null ? null : rocketId,
"rocket_name": rocketName == null ? null : rocketName,
"rocket_type": rocketType == null ? null : rocketType,
};
}
class Diameter {
Diameter({
this.meters,
this.feet,
});
double meters;
double feet;
factory Diameter.fromRawJson(String str) => Diameter.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Diameter.fromJson(Map<String, dynamic> json) => Diameter(
meters: json["meters"] == null ? null : json["meters"].toDouble(),
feet: json["feet"] == null ? null : json["feet"].toDouble(),
);
Map<String, dynamic> toJson() => {
"meters": meters == null ? null : meters,
"feet": feet == null ? null : feet,
};
}
class Engines {
Engines({
this.number,
this.type,
this.version,
this.layout,
this.isp,
this.engineLossMax,
this.propellant1,
this.propellant2,
this.thrustSeaLevel,
this.thrustVacuum,
this.thrustToWeight,
});
int number;
String type;
String version;
String layout;
Isp isp;
int engineLossMax;
String propellant1;
String propellant2;
Thrust thrustSeaLevel;
Thrust thrustVacuum;
double thrustToWeight;
factory Engines.fromRawJson(String str) => Engines.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Engines.fromJson(Map<String, dynamic> json) => Engines(
number: json["number"] == null ? null : json["number"],
type: json["type"] == null ? null : json["type"],
version: json["version"] == null ? null : json["version"],
layout: json["layout"] == null ? null : json["layout"],
isp: json["isp"] == null ? null : Isp.fromJson(json["isp"]),
engineLossMax: json["engine_loss_max"] == null ? null : json["engine_loss_max"],
propellant1: json["propellant_1"] == null ? null : json["propellant_1"],
propellant2: json["propellant_2"] == null ? null : json["propellant_2"],
thrustSeaLevel: json["thrust_sea_level"] == null ? null : Thrust.fromJson(json["thrust_sea_level"]),
thrustVacuum: json["thrust_vacuum"] == null ? null : Thrust.fromJson(json["thrust_vacuum"]),
thrustToWeight: json["thrust_to_weight"] == null ? null : json["thrust_to_weight"].toDouble(),
);
Map<String, dynamic> toJson() => {
"number": number == null ? null : number,
"type": type == null ? null : type,
"version": version == null ? null : version,
"layout": layout == null ? null : layout,
"isp": isp == null ? null : isp.toJson(),
"engine_loss_max": engineLossMax == null ? null : engineLossMax,
"propellant_1": propellant1 == null ? null : propellant1,
"propellant_2": propellant2 == null ? null : propellant2,
"thrust_sea_level": thrustSeaLevel == null ? null : thrustSeaLevel.toJson(),
"thrust_vacuum": thrustVacuum == null ? null : thrustVacuum.toJson(),
"thrust_to_weight": thrustToWeight == null ? null : thrustToWeight,
};
}
class Isp {
Isp({
this.seaLevel,
this.vacuum,
});
int seaLevel;
int vacuum;
factory Isp.fromRawJson(String str) => Isp.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Isp.fromJson(Map<String, dynamic> json) => Isp(
seaLevel: json["sea_level"] == null ? null : json["sea_level"],
vacuum: json["vacuum"] == null ? null : json["vacuum"],
);
Map<String, dynamic> toJson() => {
"sea_level": seaLevel == null ? null : seaLevel,
"vacuum": vacuum == null ? null : vacuum,
};
}
class Thrust {
Thrust({
this.kN,
this.lbf,
});
int kN;
int lbf;
factory Thrust.fromRawJson(String str) => Thrust.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Thrust.fromJson(Map<String, dynamic> json) => Thrust(
kN: json["kN"] == null ? null : json["kN"],
lbf: json["lbf"] == null ? null : json["lbf"],
);
Map<String, dynamic> toJson() => {
"kN": kN == null ? null : kN,
"lbf": lbf == null ? null : lbf,
};
}
class FirstStage {
FirstStage({
this.reusable,
this.engines,
this.fuelAmountTons,
this.burnTimeSec,
this.thrustSeaLevel,
this.thrustVacuum,
this.cores,
});
bool reusable;
int engines;
double fuelAmountTons;
int burnTimeSec;
Thrust thrustSeaLevel;
Thrust thrustVacuum;
int cores;
factory FirstStage.fromRawJson(String str) => FirstStage.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory FirstStage.fromJson(Map<String, dynamic> json) => FirstStage(
reusable: json["reusable"] == null ? null : json["reusable"],
engines: json["engines"] == null ? null : json["engines"],
fuelAmountTons: json["fuel_amount_tons"] == null ? null : json["fuel_amount_tons"].toDouble(),
burnTimeSec: json["burn_time_sec"] == null ? null : json["burn_time_sec"],
thrustSeaLevel: json["thrust_sea_level"] == null ? null : Thrust.fromJson(json["thrust_sea_level"]),
thrustVacuum: json["thrust_vacuum"] == null ? null : Thrust.fromJson(json["thrust_vacuum"]),
cores: json["cores"] == null ? null : json["cores"],
);
Map<String, dynamic> toJson() => {
"reusable": reusable == null ? null : reusable,
"engines": engines == null ? null : engines,
"fuel_amount_tons": fuelAmountTons == null ? null : fuelAmountTons,
"burn_time_sec": burnTimeSec == null ? null : burnTimeSec,
"thrust_sea_level": thrustSeaLevel == null ? null : thrustSeaLevel.toJson(),
"thrust_vacuum": thrustVacuum == null ? null : thrustVacuum.toJson(),
"cores": cores == null ? null : cores,
};
}
class LandingLegs {
LandingLegs({
this.number,
this.material,
});
int number;
String material;
factory LandingLegs.fromRawJson(String str) => LandingLegs.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory LandingLegs.fromJson(Map<String, dynamic> json) => LandingLegs(
number: json["number"] == null ? null : json["number"],
material: json["material"] == null ? null : json["material"],
);
Map<String, dynamic> toJson() => {
"number": number == null ? null : number,
"material": material == null ? null : material,
};
}
class Mass {
Mass({
this.kg,
this.lb,
});
int kg;
int lb;
factory Mass.fromRawJson(String str) => Mass.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Mass.fromJson(Map<String, dynamic> json) => Mass(
kg: json["kg"] == null ? null : json["kg"],
lb: json["lb"] == null ? null : json["lb"],
);
Map<String, dynamic> toJson() => {
"kg": kg == null ? null : kg,
"lb": lb == null ? null : lb,
};
}
class PayloadWeight {
PayloadWeight({
this.id,
this.name,
this.kg,
this.lb,
});
String id;
String name;
int kg;
int lb;
factory PayloadWeight.fromRawJson(String str) => PayloadWeight.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory PayloadWeight.fromJson(Map<String, dynamic> json) => PayloadWeight(
id: json["id"] == null ? null : json["id"],
name: json["name"] == null ? null : json["name"],
kg: json["kg"] == null ? null : json["kg"],
lb: json["lb"] == null ? null : json["lb"],
);
Map<String, dynamic> toJson() => {
"id": id == null ? null : id,
"name": name == null ? null : name,
"kg": kg == null ? null : kg,
"lb": lb == null ? null : lb,
};
}
class SecondStage {
SecondStage({
this.reusable,
this.engines,
this.fuelAmountTons,
this.burnTimeSec,
this.thrust,
this.payloads,
});
bool reusable;
int engines;
double fuelAmountTons;
int burnTimeSec;
Thrust thrust;
Payloads payloads;
factory SecondStage.fromRawJson(String str) => SecondStage.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory SecondStage.fromJson(Map<String, dynamic> json) => SecondStage(
reusable: json["reusable"] == null ? null : json["reusable"],
engines: json["engines"] == null ? null : json["engines"],
fuelAmountTons: json["fuel_amount_tons"] == null ? null : json["fuel_amount_tons"].toDouble(),
burnTimeSec: json["burn_time_sec"] == null ? null : json["burn_time_sec"],
thrust: json["thrust"] == null ? null : Thrust.fromJson(json["thrust"]),
payloads: json["payloads"] == null ? null : Payloads.fromJson(json["payloads"]),
);
Map<String, dynamic> toJson() => {
"reusable": reusable == null ? null : reusable,
"engines": engines == null ? null : engines,
"fuel_amount_tons": fuelAmountTons == null ? null : fuelAmountTons,
"burn_time_sec": burnTimeSec == null ? null : burnTimeSec,
"thrust": thrust == null ? null : thrust.toJson(),
"payloads": payloads == null ? null : payloads.toJson(),
};
}
class Payloads {
Payloads({
this.option1,
this.compositeFairing,
this.option2,
});
String option1;
CompositeFairing compositeFairing;
String option2;
factory Payloads.fromRawJson(String str) => Payloads.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Payloads.fromJson(Map<String, dynamic> json) => Payloads(
option1: json["option_1"] == null ? null : json["option_1"],
compositeFairing: json["composite_fairing"] == null ? null : CompositeFairing.fromJson(json["composite_fairing"]),
option2: json["option_2"] == null ? null : json["option_2"],
);
Map<String, dynamic> toJson() => {
"option_1": option1 == null ? null : option1,
"composite_fairing": compositeFairing == null ? null : compositeFairing.toJson(),
"option_2": option2 == null ? null : option2,
};
}
class CompositeFairing {
CompositeFairing({
this.height,
this.diameter,
});
Diameter height;
Diameter diameter;
factory CompositeFairing.fromRawJson(String str) => CompositeFairing.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory CompositeFairing.fromJson(Map<String, dynamic> json) => CompositeFairing(
height: json["height"] == null ? null : Diameter.fromJson(json["height"]),
diameter: json["diameter"] == null ? null : Diameter.fromJson(json["diameter"]),
);
Map<String, dynamic> toJson() => {
"height": height == null ? null : height.toJson(),
"diameter": diameter == null ? null : diameter.toJson(),
};
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/navigation/bloc.dart
|
export 'navigation_bloc.dart';
export 'navigationState.dart';
export 'navigationEvent.dart';
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/navigation/navigationState.dart
|
import 'package:equatable/equatable.dart';
import 'package:flutter_spacexopedia/ui/theme/theme.dart';
import 'package:meta/meta.dart';
@immutable
abstract class NavigationState extends Equatable {}
class SelectPageIndex extends NavigationState {
final int index;
SelectPageIndex(this.index);
@override
List<Object> get props => ["Selected page: $index"];
}
class SelectTheme extends SelectPageIndex {
final ThemeType type;
final int index;
SelectTheme(this.index,this.type) : super(index);
@override
List<Object> get props => ["Select $type theme"];
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/navigation/navigation_bloc.dart
|
import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:flutter_spacexopedia/bloc/navigation/navigationEvent.dart';
import 'package:flutter_spacexopedia/bloc/navigation/navigationState.dart';
class NavigationBloc extends Bloc<NavigationEvent, NavigationState> {
@override
NavigationState get initialState => SelectPageIndex(0);
@override
Stream<NavigationState> mapEventToState(NavigationEvent event) async* {
if (event is IndexSelected) {
yield SelectPageIndex(event.index);
} else if (event is ThemeSelected){
final currentState = state as SelectPageIndex;
yield SelectTheme(currentState.index, event.type,);
}
else {
throw UnsupportedError('Unsupported event $event');
}
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/bloc
|
mirrored_repositories/flutter_spacexopedia/lib/bloc/navigation/navigationEvent.dart
|
import 'package:equatable/equatable.dart';
import 'package:flutter_spacexopedia/ui/theme/theme.dart';
import 'package:meta/meta.dart';
@immutable
abstract class NavigationEvent extends Equatable {}
class IndexSelected extends NavigationEvent {
final int index;
IndexSelected(this.index);
@override
List<Object> get props => ["Select page index: $index"];
}
class ThemeSelected extends NavigationEvent {
final ThemeType type;
ThemeSelected(this.type);
@override
List<Object> get props => ["$type theme selected"];
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib
|
mirrored_repositories/flutter_spacexopedia/lib/helper/app_font.dart
|
import 'package:flutter/material.dart';
class AppFont {
static String _fontFamily = "AppIcons";
static IconData moon = IconData(0xf185, fontFamily: _fontFamily);
static IconData sun = IconData(0xf186, fontFamily: _fontFamily);
static IconData launch = IconData(0xe800, fontFamily: _fontFamily);
static IconData roadster = IconData(0xF1B9, fontFamily: _fontFamily);
static IconData rocket = IconData(0xf197, fontFamily: _fontFamily);
static IconData rocket2 = IconData(0xf388, fontFamily: _fontFamily);
static IconData rocketdragon = IconData(0xf3ec, fontFamily: _fontFamily);
static IconData core = IconData(0xf512, fontFamily: _fontFamily);
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib
|
mirrored_repositories/flutter_spacexopedia/lib/helper/config.dart
|
class Config{
static const String appName = "SpaceXopedia";
static const String apiBaseUrl = "https://api.spacexdata.com/v3/";
static const String launchAll = "launches";
static const String launchspaefic = "launches/";
static const String launchPast = "launches/past";
static const String launchUpcoming = "launches/upcoming";
static const String launchLatest = "/launches/latest";
static const String launchNext = "/launches/next";
static const String roadster = "roadster";
static const String allRockets = "rockets";
static const String rocketSpecefic = "rockets/";
static const String allDragons = "dragons";
static const String dragonsSpecific = "dragons/";
static const String allCores = "cores";
static const String coresSpecific = "cores/";
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib
|
mirrored_repositories/flutter_spacexopedia/lib/helper/utils.dart
|
import 'package:intl/intl.dart';
import 'package:url_launcher/url_launcher.dart';
class Utils{
static String toformattedDate(DateTime date){
return DateFormat('dd MMM yyyy').format(date);
}
static String toformattedDate2(DateTime date){
return DateFormat('dd-MMM-yyyy hh:mm a').format(date);
}
static launchTo(String link)async{
final isOK = await canLaunch(link);
if(isOK){
launch(link);
}
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib
|
mirrored_repositories/flutter_spacexopedia/lib/exceptions/exceptions.dart
|
class SchemeConsistencyException implements Exception {
final String message;
SchemeConsistencyException([this.message = 'Schemes consistency error']);
String toString() {
if (message == null) return '$SchemeConsistencyException';
return '$SchemeConsistencyException: $message';
}
}
abstract class DiagnosticMessageException implements Exception {
String get diagnosticMessage;
}
class ApiException implements Exception {
final String message;
ApiException(this.message);
}
class ApiInternalServerException extends ApiException {
ApiInternalServerException()
: super(
'Internal Server Error');
}
class ApiDataNotFoundException extends ApiException {
ApiDataNotFoundException()
: super('Data Not Found Error');
}
class HttpException implements Exception {
final _message;
HttpException(this._message);
String toString() {
return "$_message";
}
}
class FetchDataException extends HttpException {
FetchDataException(String message)
: super("Error During Communication: $message");
}
class BadRequestException extends HttpException {
BadRequestException(String message) : super("Invalid Request: $message");
}
class BadUrlException extends HttpException {
BadUrlException(String message) : super("Bad URL: $message");
}
class UnauthorisedException extends HttpException {
UnauthorisedException(String message) : super("Unauthorised: $message");
}
class ResourceNotFoundException extends HttpException {
ResourceNotFoundException(String message) : super("Not found: $message");
}
class InvalidInputException extends HttpException {
InvalidInputException(String message) : super("Invalid Input: $message");
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui
|
mirrored_repositories/flutter_spacexopedia/lib/ui/widgets/customWidgets.dart
|
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
Widget customNetworkImage(String path,{BoxFit fit = BoxFit.contain, Widget placeholder}){
assert(path!=null);
return CachedNetworkImage(
fit: fit,
imageUrl: path,
placeholderFadeInDuration: Duration(milliseconds: 500),
placeholder: (context, url) => Container(
color: Color(0xffeeeeee),
),
errorWidget: (context, url, error) => placeholder != null ? placeholder : Icon(Icons.error),
);
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui
|
mirrored_repositories/flutter_spacexopedia/lib/ui/widgets/custom_heading_tile.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_spacexopedia/ui/theme/theme.dart';
import 'package:flutter_spacexopedia/ui/widgets/title_text.dart';
class SHeadingTile extends StatelessWidget {
const SHeadingTile(this.title,{Key key}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.bottomLeft,
padding: EdgeInsets.only(bottom: 8, left: 16),
height: 50,
width: AppTheme.fullWidth(context),
color: Theme.of(context).colorScheme.primary.withAlpha(30),
child: TitleText(title, fontSize: 16),
);
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui
|
mirrored_repositories/flutter_spacexopedia/lib/ui/widgets/title_value.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_spacexopedia/ui/widgets/title_text.dart';
class TitleValue extends StatelessWidget {
const TitleValue({Key key, this.title, this.value})
: super(key: key);
final String title, value;
@override
Widget build(BuildContext context) {
return Row(
children: <Widget>[
TitleText(title, fontSize: 14,fontWeight: FontWeight.w500,),
SizedBox(
width: 5,
),
TitleText(value, fontSize: 14,fontWeight: FontWeight.w400,),
],
);
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui
|
mirrored_repositories/flutter_spacexopedia/lib/ui/widgets/bottom_navigation_bar.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_spacexopedia/bloc/navigation/bloc.dart';
import 'package:flutter_spacexopedia/helper/app_font.dart';
import 'package:google_fonts/google_fonts.dart';
class SBottomNavigationBar extends StatelessWidget {
const SBottomNavigationBar({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
var pageindex = 0;
final NavigationBloc bloc = BlocProvider.of<NavigationBloc>(context);
final theme = Theme.of(context);
return BlocBuilder<NavigationBloc, NavigationState>(
builder: (context, state) {
if (state is SelectPageIndex) {
pageindex = state.index;
}
return BottomNavigationBar(
elevation: 10,
unselectedIconTheme:
IconThemeData(color: theme.colorScheme.onPrimary),
type: BottomNavigationBarType.fixed,
unselectedLabelStyle:
TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
onTap: (index) {
bloc.add(IndexSelected(index));
},
showUnselectedLabels: false,
showSelectedLabels: true,
currentIndex: pageindex,
items: [
BottomNavigationBarItem(
icon: Icon(AppFont.launch), title: Text("Launch")),
BottomNavigationBarItem(
icon: Icon(AppFont.roadster), title: Text("Roadster")),
BottomNavigationBarItem(
icon: Icon(AppFont.rocket), title: Text("Rocket")),
BottomNavigationBarItem(
icon: Icon(AppFont.rocketdragon), title: Text("Dragon")),
BottomNavigationBarItem(
icon: Icon(AppFont.core), title: Text("Core")),
],
);
},
);
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui
|
mirrored_repositories/flutter_spacexopedia/lib/ui/widgets/list_card.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_spacexopedia/ui/widgets/customWidgets.dart';
import 'package:flutter_spacexopedia/ui/theme/extentions.dart';
class ListCard extends StatelessWidget {
const ListCard({
Key key,
this.bodyContent,
this.imagePath,
this.hideImage = false,
this.imagePadding = const EdgeInsets.all(0),
this.onPressed,
}) : super(key: key);
final Widget bodyContent;
final String imagePath;
final bool hideImage;
final Function onPressed;
final EdgeInsetsGeometry imagePadding;
Widget _image(context) {
if (imagePath == null) {
return _noImage(context);
}
return Padding(
padding: imagePadding,
child: ClipRRect(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(8),
topLeft: Radius.circular(8),
),
child: customNetworkImage(
imagePath,
fit: BoxFit.cover,
placeholder: _noImage(context),
),
),
);
}
Widget _noImage(context) {
final theme = Theme.of(context);
return ClipRRect(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(8),
topLeft: Radius.circular(8),
),
child: Container(
// color: theme.colorScheme.background.withAlpha(80),
padding: EdgeInsets.all(8),
child: Stack(
children: <Widget>[
Image.asset(
"assets/rocket_lauch.png",
height: 100,
),
CircleAvatar(
radius: 50,
backgroundColor: theme.colorScheme.background.withAlpha(180),
)
],
),
),
);
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Container(
margin: EdgeInsets.symmetric(vertical: 8, horizontal: 16),
decoration: BoxDecoration(
color: theme.cardColor.withOpacity(.4),
borderRadius: BorderRadius.all(Radius.circular(10)),
),
height: 128,
child: Row(
children: <Widget>[
if (!hideImage)
AspectRatio(
aspectRatio: 1,
child: _image(context),
),
if (!hideImage)
SizedBox(
width: 16,
),
Expanded(flex: 3, child: bodyContent)
],
).ripple(onPressed, borderRadius: BorderRadius.all(Radius.circular(10))),
);
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui
|
mirrored_repositories/flutter_spacexopedia/lib/ui/widgets/title_text.dart
|
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class TitleText extends StatelessWidget {
final String text;
final double fontSize;
final Color color;
final FontWeight fontWeight;
final TextAlign textAlign;
final TextOverflow overflow;
const TitleText(
this.text, {
Key key,
this.fontSize = 18,
this.color ,
this.fontWeight = FontWeight.w500,
this.textAlign = TextAlign.left,
this.overflow = TextOverflow.visible,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Text(
text,
style: GoogleFonts.montserrat(
fontSize: fontSize,
fontWeight: fontWeight,
color: color ?? Theme.of(context).colorScheme.onSurface,
),
textAlign: textAlign,
overflow: overflow,
);
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui
|
mirrored_repositories/flutter_spacexopedia/lib/ui/widgets/custom_list_tile.dart
|
import 'package:flutter/material.dart';
class SListTile extends StatelessWidget {
const SListTile(this.title, this.value, {Key key, this.onPressed})
: super(key: key);
final String title;
final String value;
final Function onPressed;
Widget _rowTile(String title, String value,
{Function onPressed, ThemeData theme}) {
if (value == null) {
value = "N/A";
}
return ListTile(
contentPadding: EdgeInsets.only(
left: 16, top: 4, bottom: 4, right: onPressed == null ? 16 : 0),
title: Row(
children: <Widget>[
Text(title,
style: theme.textTheme.headline6
.copyWith(fontSize: 14, color: theme.colorScheme.onSurface)),
Spacer(),
Text(value,
style: theme.textTheme.headline4
.copyWith(fontSize: 14, color: theme.colorScheme.onSurface)),
onPressed != null
? IconButton(
icon: Icon(Icons.keyboard_arrow_right),
onPressed: onPressed,
)
: SizedBox()
],
),
);
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return _rowTile(title, value, onPressed: onPressed, theme: theme);
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui
|
mirrored_repositories/flutter_spacexopedia/lib/ui/widgets/image_slider.dart
|
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'dart:math';
import 'package:flutter_spacexopedia/ui/widgets/dot_indicator.dart';
class PhotoPageView extends StatefulWidget {
final List<String> imageList;
const PhotoPageView({@required this.imageList});
@override
_MyPageState createState() => _MyPageState();
}
class _MyPageState extends State<PhotoPageView> {
PageController controller = PageController();
@override
Widget build(BuildContext context) {
// Return empty widget if imageList has no pictures
if (widget.imageList == null || widget.imageList.length < 1) {
return SizedBox();
}
return AspectRatio(
aspectRatio: 4 / 3,
child: Stack(
children: <Widget>[
PageView.builder(
controller: controller,
itemBuilder: (context, position) {
return InkWell(
onTap: () {},
child: SpacePicture(
imageUrl: widget.imageList[position],
heroTag: "${widget.imageList[position]}",
borderRadius: BorderRadius.all(Radius.circular(0)),
),
);
},
itemCount: widget.imageList.length, // Can be null
),
_controls(),
],
),
);
}
Widget _controls() {
if (widget.imageList.length == 1) {
return SizedBox();
}
return Align(
alignment: Alignment.bottomCenter,
child: Container(
height: 30,
child: DotsIndicator(
controller: controller,
itemCount: widget.imageList.length,
onPageSelected: (int page) {
controller.animateToPage(
page,
duration: Duration(milliseconds: 750),
curve: Curves.ease,
);
},
),
),
);
}
}
class SpacePicture extends StatelessWidget {
final String imageUrl;
final String heroTag;
final BorderRadius borderRadius;
SpacePicture(
{@required this.imageUrl, @required this.heroTag, this.borderRadius});
@override
Widget build(BuildContext context) {
return Material(
child: Hero(
tag: heroTag,
child: ClipRRect(
borderRadius: borderRadius ?? BorderRadius.circular(4),
child: CachedNetworkImage(
filterQuality: FilterQuality.low,
fit: BoxFit.cover,
imageUrl: imageUrl,
fadeInCurve: Curves.easeIn,
fadeOutCurve: Curves.easeOut,
placeholder: (context, url) => Container(color: Color(0xffeeeeee)),
),
),
),
);
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui
|
mirrored_repositories/flutter_spacexopedia/lib/ui/widgets/dot_indicator.dart
|
import 'dart:math';
import 'package:flutter/material.dart';
/// An indicator showing the currently selected page of a PageController
class DotsIndicator extends AnimatedWidget {
DotsIndicator({
this.controller,
this.itemCount,
this.onPageSelected,
this.color: Colors.white,
}) : super(listenable: controller);
/// The PageController that this DotsIndicator is representing.
final PageController controller;
/// The number of items managed by the PageController
final int itemCount;
/// Called when a dot is tapped
final ValueChanged<int> onPageSelected;
/// The color of the dots.
///
/// Defaults to `Colors.white`.
final Color color;
// The base size of the dots
static const double _kDotSize = 6.0;
// The increase in the size of the selected dot
static const double _kMaxZoom = 1.5;
// The distance between the center of each dot
static const double _kDotSpacing = 16.0;
Widget _buildDot(int index) {
double selectedness = Curves.easeOut.transform(
max(
0.0,
1.0 - ((controller.page ?? controller.initialPage) - index).abs(),
),
);
double zoom = 1.0 + (_kMaxZoom - 1.0) * selectedness;
return new Container(
width: _kDotSpacing,
child: new Center(
child: new Material(
color: color,
type: MaterialType.circle,
child: new Container(
width: _kDotSize * zoom,
height: _kDotSize * zoom,
child: new InkWell(
onTap: () => onPageSelected(index),
),
),
),
),
);
}
Widget build(BuildContext context) {
return new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: new List<Widget>.generate(itemCount, _buildDot),
);
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/home_page.dart
|
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_spacexopedia/bloc/navigation/bloc.dart';
import 'package:flutter_spacexopedia/helper/app_font.dart';
import 'package:flutter_spacexopedia/helper/utils.dart';
import 'package:flutter_spacexopedia/ui/pages/core/core_page.dart';
import 'package:flutter_spacexopedia/ui/pages/dragon/dragon_page.dart';
import 'package:flutter_spacexopedia/ui/pages/launch/all_launch.dart';
import 'package:flutter_spacexopedia/ui/pages/roadster/roadster_page.dart';
import 'package:flutter_spacexopedia/ui/pages/rockets/rocket_page.dart';
import 'package:flutter_spacexopedia/ui/theme/custom_theme.dart';
import 'package:flutter_spacexopedia/ui/theme/theme.dart';
import 'package:flutter_spacexopedia/ui/widgets/bottom_navigation_bar.dart';
class HomePage extends StatefulWidget {
HomePage({
Key key,
}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int pageindex = 0;
bool isDarkTheme = true;
Widget getPage(int index) {
switch (index) {
case 0:
return AllLaunch();
case 1:
return RoadsterPage();
case 2:
return RocketPage();
case 3:
return DragonPage();
case 4:
return CorePage();
default:
return Center(child: Text("Page $pageindex"));
}
}
void _changeTheme(BuildContext buildContext, ThemeType key) {
CustomTheme.instanceOf(buildContext).changeTheme(key);
isDarkTheme = key == ThemeType.DARK;
BlocProvider.of<NavigationBloc>(context).add(ThemeSelected(key));
}
String _getPageName(int index) {
switch (index) {
case 0:
return "Launch";
case 1:
return "Roadster";
case 2:
return "Rockets";
case 3:
return "Dragon";
case 4:
return "Cores";
default:
return "Empty";
}
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
backgroundColor: theme.backgroundColor,
appBar: AppBar(
title: BlocBuilder<NavigationBloc, NavigationState>(
builder: (context, state) {
if (state is SelectPageIndex) {
pageindex = state.index;
}
return Title(
color: theme.colorScheme.onSurface,
child: Text(_getPageName(pageindex)),
title: "Spacexopedia",
);
},
),
// iconTheme: ,
actions: <Widget>[
BlocBuilder<NavigationBloc, NavigationState>(
builder: (context, state) {
if (state is SelectTheme) {
isDarkTheme = state.type == ThemeType.DARK;
}
return IconButton(
icon: Icon(
isDarkTheme ? AppFont.sun : AppFont.moon,
),
onPressed: () {
_changeTheme(
context, isDarkTheme ? ThemeType.LIGHT : ThemeType.DARK);
},
);
},
),
PopupMenuButton<Choice>(
onSelected: (choice) async {
switch (choice.title) {
case "Share":
Utils.launchTo(
"https://play.google.com/store/apps/details?id=com.thealphamerc.flutter_spacexopedia");
break;
case "About":
break;
case "License":
showLicensePage(
context: context,
applicationName: "Spacexopedia",
applicationVersion: "1.0.0",
useRootNavigator: false,
applicationLegalese: "By TheAlphamerc");
break;
default:
}
},
itemBuilder: (BuildContext context) {
return choices.map((Choice choice) {
return PopupMenuItem<Choice>(
value: choice,
child: Text(choice.title),
);
}).toList();
},
),
],
),
bottomNavigationBar: SBottomNavigationBar(),
body: BlocBuilder<NavigationBloc, NavigationState>(
builder: (context, state) {
if (state is SelectPageIndex) {
pageindex = state.index;
}
return getPage(pageindex);
},
),
);
}
}
class Choice {
const Choice({this.title, this.icon});
final IconData icon;
final String title;
}
const List<Choice> choices = const <Choice>[
const Choice(title: 'Share', icon: Icons.directions_car),
const Choice(title: 'About', icon: Icons.directions_railway),
const Choice(title: 'License', icon: Icons.directions_railway),
];
class ChoiceCard extends StatelessWidget {
const ChoiceCard({Key key, this.choice}) : super(key: key);
final Choice choice;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Card(
color: Colors.white,
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
choice.title,
style:
TextStyle(fontSize: 20, color: theme.colorScheme.onSurface),
),
],
),
),
);
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/launch/launch_detail.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_spacexopedia/ui/widgets/custom_heading_tile.dart';
import 'package:flutter_spacexopedia/ui/widgets/custom_list_tile.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:flutter_spacexopedia/helper/utils.dart';
import 'package:flutter_spacexopedia/ui/theme/theme.dart';
import 'package:flutter_spacexopedia/bloc/launches/bloc.dart';
import 'package:flutter_spacexopedia/ui/theme/extentions.dart';
import 'package:flutter_spacexopedia/ui/pages/launch/widgets/youtube_player.dart';
import 'package:flutter_spacexopedia/ui/widgets/title_text.dart';
class LaunchDetail extends StatelessWidget {
const LaunchDetail({Key key, this.model}) : super(key: key);
final Launch model;
Widget _links(
String title,
String value,
int from,
int to,
) {
String url = value;
if (value != null) {
value = value.substring(from, to);
} else {
value = "N/A";
}
return SListTile(title, value, onPressed: () {
canLaunch(url).then((yes) {
if (yes) {
launch(url);
}
});
});
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
body: Column(
children: <Widget>[
Expanded(
child: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
title: Title(
color: theme.backgroundColor,
child: Text(model.missionName),
title: model.missionName,
),
floating: true,
),
SliverList(
delegate: SliverChildListDelegate(
[
YoutubeVideoPlayer(
youtubeId: model?.links?.youtubeId,
),
SizedBox(height: model.details == null ? 0 : 16),
model.details == null
? SizedBox.shrink()
: ListTile(
title: TitleText("Description", fontSize: 15),
subtitle: TitleText(
model.details ?? "",
fontSize: 14,
fontWeight: FontWeight.w400,
textAlign: TextAlign.justify,
).vP8,
),
// SizedBox(height: model.details == null ? 0 : 16),
Divider(height: 0),
SListTile("Flight no", "#${model.flightNumber}"),
Divider(height: 0),
SListTile(
"Launch date",
Utils.toformattedDate2(model.launchDateLocal),
),
Divider(height: 0),
SListTile(
"Success",
model.launchSuccess == null
? "N/A"
: model.launchSuccess ? "Yes" : "False",
),
Divider(height: 0),
SListTile("Location", model.launchSite.siteName),
Divider(height: 0),
SListTile("Rocket", model.rocket.rocketName),
Divider(height: 0),
/// Core
SHeadingTile("Core #1"),
SListTile(
"Serial",
model.rocket.firstStage.cores.first.coreSerial,
),
Divider(height: 0),
SListTile(
"Block",
model.rocket.firstStage.cores.first.block.toString(),
),
Divider(height: 0),
SListTile("Flight number", "#${model.flightNumber}"),
Divider(height: 0),
SListTile(
"Resued",
model.rocket.firstStage.cores.first.reused == null
? "N/A"
: model.rocket.firstStage.cores.first.reused
? "Yes"
: "No",
),
Divider(height: 0),
SListTile(
"Landing type",
model.rocket.firstStage.cores.first.landingType,
),
Divider(height: 0),
SListTile(
"Landing vehicle",
model.rocket.firstStage.cores.first.landingVehicle,
),
Divider(height: 0),
SListTile(
"Landing Sucess",
model.rocket.firstStage.cores.first.landSuccess == null
? "N/A"
: model.rocket.firstStage.cores.first.landSuccess
? "Yes"
: "No",
),
/// Payload
SHeadingTile(
"Payload: ${model.rocket.secondStage.payloads.first.payloadId}",
),
SListTile(
"Customers",
model.rocket.secondStage.payloads.first.customers.first,
),
Divider(height: 0),
SListTile(
"Nationality",
model.rocket.secondStage.payloads.first.nationality,
),
Divider(height: 0),
SListTile(
"Manufacturer",
model.rocket.secondStage.payloads.first.manufacturer,
),
Divider(height: 0),
SListTile(
"Mass",
model.rocket.secondStage.payloads.first.payloadMassKg ==
null
? "N/A"
: model.rocket.secondStage.payloads.first
.payloadMassKg
.toString() +
" Kg",
),
Divider(height: 0),
SListTile(
"Orbit",
model.rocket.secondStage.payloads.first.orbit,
),
Divider(height: 0),
/// Link
SHeadingTile("Links"),
_links("Mission patch", model.links.missionPatch, 0, 26),
Divider(height: 0),
_links(
"Reddit campaign", model.links.redditCampaign, 8, 22),
Divider(height: 0),
_links(
"Reddit launch", model.links.redditCampaign, 8, 22),
Divider(height: 0),
_links(
"Reddit recovery", model.links.redditCampaign, 8, 22),
Divider(height: 0),
_links("Reddit media", model.links.redditCampaign, 8, 22),
Divider(height: 0),
_links("Article link", model.links.articleLink, 0, 26),
Divider(height: 0),
_links("Wikipedia", model.links.wikipedia, 0, 24),
Divider(height: 0),
],
addAutomaticKeepAlives: true,
),
)
],
),
),
],
),
);
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/launch/all_launch.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_spacexopedia/bloc/launches/bloc.dart';
import 'package:flutter_spacexopedia/helper/app_font.dart';
import 'package:flutter_spacexopedia/helper/utils.dart';
import 'package:flutter_spacexopedia/ui/pages/common/no_connection.dart';
import 'package:flutter_spacexopedia/ui/pages/common/no_content.dart';
import 'package:flutter_spacexopedia/ui/pages/launch/launch_detail.dart';
import 'package:flutter_spacexopedia/ui/widgets/list_card.dart';
import 'package:flutter_spacexopedia/ui/widgets/title_text.dart';
import 'package:flutter_spacexopedia/ui/widgets/title_value.dart';
import 'package:google_fonts/google_fonts.dart';
class AllLaunch extends StatefulWidget {
AllLaunch({Key key}) : super(key: key);
@override
_AllLaunchState createState() => _AllLaunchState();
}
class _AllLaunchState extends State<AllLaunch>
with SingleTickerProviderStateMixin {
TabController _tabController;
@override
void initState() {
_tabController = TabController(length: 2, vsync: this);
super.initState();
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
backgroundColor: theme.backgroundColor,
body: Column(
children: <Widget>[
Card(
elevation: 3,
margin: EdgeInsets.all(0),
child: TabBar(
labelStyle: GoogleFonts.montserrat(
fontSize: 15,
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.onSurface,
),
controller: _tabController,
tabs: <Widget>[
Text("Upcomming"),
Text("Past"),
],
),
),
Expanded(
child: BlocBuilder<LaunchBloc, LaunchState>(
builder: (context, state) {
if (state is Loading) {
return Center(
child: CircularProgressIndicator(),
);
} else if (state is LoadedState) {
if (state.allLaunch == null) return NoContent();
return TabBarView(
controller: _tabController,
children: [
LaunchList(
list: state.allLaunch
.where((element) => element.upcoming)
.toList(),
),
LaunchList(
list: state.allLaunch
.where((element) => !element.upcoming)
.toList(),
)
],
);
} else if (state is NoConnectionDragonState) {
return NoInternetConnection(
message: state.errorMessage,
onReload: () {
BlocProvider.of<LaunchBloc>(context).add(LaunchInitial());
},
);
}
return Center(
child: CircularProgressIndicator(),
);
},
),
),
],
),
);
}
}
class LaunchList extends StatelessWidget {
const LaunchList({Key key, this.list}) : super(key: key);
final List<Launch> list;
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: list.length,
itemBuilder: (context, index) => LaunchCard(
model: list[index],
),
);
}
}
class LaunchCard extends StatelessWidget {
final Launch model;
const LaunchCard({Key key, this.model}) : super(key: key);
Widget _row(IconData icon, String value, ThemeData theme) {
if (value == null) {
value = "N/A";
}
return Row(
children: <Widget>[
Icon(icon,
size: 15, color: theme.colorScheme.onSurface.withOpacity(.8)),
SizedBox(width: 10),
Text(value, style: TextStyle(color: theme.colorScheme.onSurface))
],
);
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return ListCard(
imagePath: model.links?.missionPatchSmall,
imagePadding: EdgeInsets.all(10),
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => LaunchDetail(
model: model,
),
),
);
},
bodyContent: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
TitleText(model.missionName, fontSize:14),
TitleValue(title:"Flight no:", value:model.flightNumber.toString()),
_row(Icons.calendar_today,"${Utils.toformattedDate(model.launchDateLocal)}", theme),
_row(AppFont.rocket2,model.rocket.rocketName, theme),
_row(Icons.location_on, model.launchSite.siteName, theme),
],
),
);
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/launch
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/launch/widgets/youtube_player.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_spacexopedia/ui/theme/colors/dark_color.dart';
import 'package:flutter_spacexopedia/ui/theme/theme.dart';
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
class YoutubeVideoPlayer extends StatefulWidget {
YoutubeVideoPlayer({Key key, this.youtubeId}) : super(key: key);
final String youtubeId;
@override
_YoutubePlayerState createState() => _YoutubePlayerState();
}
class _YoutubePlayerState extends State<YoutubeVideoPlayer> {
YoutubePlayerController _controller;
@override
void initState() {
if (widget.youtubeId != null) {
_controller = YoutubePlayerController(
initialVideoId: widget.youtubeId,
flags: YoutubePlayerFlags(
autoPlay: false,
loop: false,
mute: true,
),
);
}
super.initState();
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return widget.youtubeId != null
? AspectRatio(
aspectRatio: 16 / 9,
child: YoutubePlayer(
controller: _controller,
showVideoProgressIndicator: true,
progressColors: ProgressBarColors(
playedColor: theme.primaryColor,
handleColor: theme.primaryColorLight,
),
),
)
: Container(
width: AppTheme.fullWidth(context),
height: 200,
color: theme.colorScheme.primary.withOpacity(.3),
child: Center(
child: Text(
"No Video Available".toUpperCase(),
style: theme.textTheme.subtitle1.copyWith(fontSize: 14)
),
),
);
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/dragon/dragon_page.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_spacexopedia/bloc/dragon/index.dart';
import 'package:flutter_spacexopedia/ui/pages/common/error_page.dart';
import 'package:flutter_spacexopedia/ui/pages/common/no_connection.dart';
import 'package:flutter_spacexopedia/ui/pages/common/no_content.dart';
import 'package:flutter_spacexopedia/ui/pages/dragon/dragon_screen.dart';
class DragonPage extends StatefulWidget {
@override
_DragonPageState createState() => _DragonPageState();
}
class _DragonPageState extends State<DragonPage> {
final _dragonBloc = DragonBloc();
@override
void initState() {
super.initState();
_load();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return BlocBuilder<DragonBloc, DragonState>(
bloc: _dragonBloc,
builder: (
BuildContext context,
DragonState currentState,
) {
if (currentState is LoadingDragons) {
return Center(
child: CircularProgressIndicator(),
);
} else if (currentState is ErrorDragonState) {
return ErrorPage(
dsiplayReloadButton: true,
message: currentState.errorMessage,
onReload: _load,
);
} else if (currentState is LoadedState) {
if (currentState.list == null) return NoContent();
return DragonScreen(dragonList: currentState.list);
} else if (currentState is NoConnectionDragonState) {
return NoInternetConnection(
message: currentState.errorMessage,
onReload: () {
BlocProvider.of<DragonBloc>(context).add(LaunchInitial());
},
);
}
return Center(
child: CircularProgressIndicator(),
);
},
);
}
void _load() {
_dragonBloc.add(LaunchInitial());
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/dragon/dragon_detail.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_spacexopedia/bloc/dragon/dragon_model.dart';
import 'package:flutter_spacexopedia/helper/utils.dart';
import 'package:flutter_spacexopedia/ui/theme/extentions.dart';
import 'package:flutter_spacexopedia/ui/widgets/custom_heading_tile.dart';
import 'package:flutter_spacexopedia/ui/widgets/custom_list_tile.dart';
import 'package:flutter_spacexopedia/ui/widgets/image_slider.dart';
import 'package:flutter_spacexopedia/ui/widgets/title_text.dart';
import 'package:url_launcher/url_launcher.dart';
class DragonDetail extends StatelessWidget {
const DragonDetail({Key key, this.model}) : super(key: key);
final DragonModel model;
Widget _links(
String title,
String value,
int from,
int to,
) {
String url = value;
if (value != null) {
value = value.substring(from, to);
} else {
value = "N/A";
}
return SListTile(title, value, onPressed: () {
canLaunch(url).then((yes) {
if (yes) {
launch(url);
}
});
});
}
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
body: Column(
children: <Widget>[
Expanded(
child: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
title: Title(
color: theme.backgroundColor,
child: Text(model.name),
title: model.name,
),
pinned: true,
stretch: true,
expandedHeight: 260,
flexibleSpace: PhotoPageView(
imageList: model.flickrImages,
),
),
SliverList(
delegate: SliverChildListDelegate(
[
SizedBox(height: model.description == null ? 0 : 16),
model.description == null
? SizedBox.shrink()
: ListTile(
title: TitleText("Description", fontSize: 15),
subtitle: TitleText(
model.description ?? "",
fontSize: 14,
fontWeight: FontWeight.w400,
textAlign: TextAlign.justify,
).vP8,
),
SizedBox(height: 10),
Divider(height: 0),
SHeadingTile("Basic info"),
SListTile("Name", model.name),
Divider(height: 0),
SListTile("Type", model.type),
Divider(height: 0),
SListTile("Diameter", "${model.diameter.meters} m"),
Divider(height: 0),
SListTile("Height", "${model.heightWTrunk.meters} m"),
Divider(height: 0),
SListTile("Weight", "${model.dryMassKg} Kg"),
Divider(height: 0),
SListTile("First flight on",
"${Utils.toformattedDate(model.firstFlight)}"),
Divider(height: 0),
SListTile("Crew Capicity", "${model.crewCapacity}"),
Divider(height: 0),
SListTile(
"Orbit duration",
"${model.orbitDurationYr} yr",
),
SListTile("Launch payload mass",
"${model.launchPayloadMass.kg} Kg"),
Divider(height: 0),
SListTile("Return payload mass",
"${model.returnPayloadMass.kg} Kg"),
Divider(height: 0),
SListTile("Launch payload volume",
"${model.launchPayloadVol.cubicMeters} cubic meter"),
Divider(height: 0),
SListTile("Return payload mass",
"${model.returnPayloadVol.cubicMeters} cubic meter"),
Divider(height: 0),
_links("Wiki", model.wikipedia,0,24),
// Divider(height: 0),
SHeadingTile("Heat shield"),
SListTile("Material", model.heatShield.material),
Divider(height: 0),
SListTile("Size", "${model.heatShield.sizeMeters} m"),
Divider(height: 0),
SListTile(
"Temprature",
"${model.heatShield.tempDegrees} degree",
),
Divider(height: 0),
SListTile("Partner", "${model.heatShield.devPartner}"),
],
),
),
],
),
),
],
),
);
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/dragon/dragon_screen.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_spacexopedia/bloc/dragon/dragon_model.dart';
import 'package:flutter_spacexopedia/helper/utils.dart';
import 'package:flutter_spacexopedia/ui/pages/dragon/dragon_detail.dart';
import 'package:flutter_spacexopedia/ui/widgets/list_card.dart';
import 'package:flutter_spacexopedia/ui/widgets/title_text.dart';
import 'package:flutter_spacexopedia/ui/widgets/title_value.dart';
class DragonScreen extends StatelessWidget {
final List<DragonModel> dragonList;
const DragonScreen({Key key, this.dragonList}) : super(key: key);
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: dragonList.length,
itemBuilder: (context, index) => DragonCard(
model: dragonList[index],
),
);
}
}
class DragonCard extends StatelessWidget {
final DragonModel model;
const DragonCard({Key key, this.model}) : super(key: key);
@override
Widget build(BuildContext context) {
return ListCard(
imagePath: model.flickrImages?.first,
onPressed: () {
Navigator.push(context,MaterialPageRoute(builder: (_) => DragonDetail(model: model,)));
},
bodyContent: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
TitleText(model.name, fontSize:14),
TitleValue(
title: "Rocket Id:",
value: "${model.id}",
),
TitleValue(
title: "First flight date:",
value: Utils.toformattedDate(model.firstFlight),
),
TitleValue(
title: "Type:",
value: model.type,
),
],
),
);
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/core/core_page.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_spacexopedia/bloc/core/index.dart';
import 'package:flutter_spacexopedia/ui/pages/common/error_page.dart';
import 'package:flutter_spacexopedia/ui/pages/common/no_connection.dart';
import 'package:flutter_spacexopedia/ui/pages/common/no_content.dart';
import 'package:flutter_spacexopedia/ui/pages/core/core_screen.dart';
class CorePage extends StatefulWidget {
static const String routeName = '/core';
@override
_CorePageState createState() => _CorePageState();
}
class _CorePageState extends State<CorePage> {
final _coreBloc = CoreBloc();
@override
void initState() {
super.initState();
_load();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return BlocBuilder<CoreBloc, CoreState>(
bloc: _coreBloc,
builder: (
BuildContext context,
CoreState currentState,
) {
if (currentState is LoadingCore) {
return Center(
child: CircularProgressIndicator(),
);
} else if (currentState is ErrorCoreState) {
return ErrorPage(
dsiplayReloadButton: true,
message: currentState.errorMessage,
onReload: _load,
);
} else if (currentState is LoadedState) {
if (currentState.list == null) return NoContent();
return CoreScreen(list: currentState.list);
} else if (currentState is NoConnectionDragonState) {
return NoInternetConnection(
message: currentState.errorMessage,
onReload: () {
BlocProvider.of<CoreBloc>(context).add(LaunchInitial());
},
);
}
return Center(
child: CircularProgressIndicator(),
);
},
);
}
void _load() {
_coreBloc.add(LaunchInitial());
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/core/core_screen.dart
|
import 'package:flutter/material.dart';
import 'package:flutter_spacexopedia/bloc/core/core_model.dart';
import 'package:flutter_spacexopedia/helper/utils.dart';
import 'package:flutter_spacexopedia/ui/theme/extentions.dart';
import 'package:flutter_spacexopedia/ui/widgets/list_card.dart';
import 'package:flutter_spacexopedia/ui/widgets/title_value.dart';
class CoreScreen extends StatelessWidget {
final List<CoreModel> list;
const CoreScreen({Key key, this.list}) : super(key: key);
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: list.length,
itemBuilder: (context, index) => DragonCard(
model: list[index],
),
);
}
}
class DragonCard extends StatelessWidget {
final CoreModel model;
const DragonCard({Key key, this.model}) : super(key: key);
@override
Widget build(BuildContext context) {
return ListCard(
hideImage: true,
bodyContent: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
TitleValue(
title: "Mission:",
value: model.missions.first.name,
),
TitleValue(
title: "Core serial:",
value: model.coreSerial,
),
TitleValue(
title: "Original Launch date:",
value: Utils.toformattedDate(model.originalLaunch),
),
TitleValue(
title: "Status:",
value: model.getStatus(),
),
TitleValue(
title: "Reuse count:",
value: model.reuseCount.toString(),
),
TitleValue(
title: "Water landing:",
value: model.waterLanding ? "Yes" : "No",
),
],
).hP16,
);
}
}
| 0
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages
|
mirrored_repositories/flutter_spacexopedia/lib/ui/pages/roadster/roadster_screen.dart
|
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:flutter_spacexopedia/ui/theme/extentions.dart';
import 'package:flutter_spacexopedia/ui/widgets/title_text.dart';
import 'package:flutter_spacexopedia/ui/widgets/image_slider.dart';
import 'package:flutter_spacexopedia/bloc/roadster/roadster_model.dart';
class RoadsterScreen extends StatelessWidget {
final RoadsterModel model;
const RoadsterScreen({Key key, this.model}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
child: SingleChildScrollView(
child: Column(
children: <Widget>[
PhotoPageView(
imageList: model.flickrImages,
),
TitleText(model.name, fontSize:20).vP8,
TitleText(model.details, fontSize:14, textAlign: TextAlign.justify, fontWeight: FontWeight.w400,).pO(bottom: 8,left:8,right:8),
Divider(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
OutlineButton(
onPressed: () {
launch(model.wikipedia);
},
child: TitleText("Wiki", fontSize:16),
),
OutlineButton(
onPressed: () {
launch(model.video);
},
child: TitleText("Video", fontSize:16),
),
],
),
Divider(),
_RodsterListTile(
title: "Distance", value: model.earthDistanceKm.toString()),
_RodsterListTile(
title: "Weight", value: model.launchMassKg.toString()),
_RodsterListTile(
title: "Orbit type", value: model.orbitType.toString()),
_RodsterListTile(title: "Epoch", value: model.epochJd.toString()),
_RodsterListTile(
title: "ApoapsisAu", value: model.apoapsisAu.toString()),
_RodsterListTile(
title: "Periapsis Arg", value: model.periapsisArg.toString()),
_RodsterListTile(
title: "periapsis Au", value: model.periapsisAu.toString()),
_RodsterListTile(
title: "Semimajor Axis Au",
value: model.semiMajorAxisAu.toString()),
_RodsterListTile(
title: "Eccentricity", value: model.eccentricity.toString()),
_RodsterListTile(
title: "Inclination", value: model.inclination.toString()),
_RodsterListTile(
title: "Longitude", value: model.longitude.toString()),
_RodsterListTile(
title: "Period Days", value: model.periodDays.toString()),
_RodsterListTile(
title: "Speed Kmph", value: model.speedKph.toString()),
_RodsterListTile(
title: "Speed Mph", value: model.speedMph.toString()),
_RodsterListTile(
title: "Earth Distance(Km)",
value: model.earthDistanceKm.toString()),
_RodsterListTile(
title: "Earth Distance(Mi)",
value: model.earthDistanceMi.toString()),
_RodsterListTile(
title: "Mars Distance(Km)",
value: model.marsDistanceKm.toString()),
_RodsterListTile(
title: "Mars Distance(Mi)",
value: model.marsDistanceMi.toString()),
],
),
),
);
}
}
class _RodsterListTile extends StatelessWidget {
final String title, value;
const _RodsterListTile({Key key, this.title, this.value}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 16),
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
TitleText(
title,
fontSize: 16,
fontWeight: FontWeight.w400
),
TitleText(
value,
fontSize: 14,
fontWeight: FontWeight.w400
),
],
),
SizedBox(
height: 12,
),
Divider(height: 0),
],
),
);
}
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.