repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/movie_app/lib/pages/home/widgets/movielist/bloc
mirrored_repositories/movie_app/lib/pages/home/widgets/movielist/bloc/movielist/movielist_event.dart
import 'package:equatable/equatable.dart'; abstract class MovieListEvent extends Equatable { const MovieListEvent(); @override List<Object> get props => []; } class GetFavoriteMovieListEvent extends MovieListEvent {} class GetPopularMovieListEvent extends MovieListEvent {}
0
mirrored_repositories/movie_app/lib/pages/home/widgets/movielist/bloc
mirrored_repositories/movie_app/lib/pages/home/widgets/movielist/bloc/movielist/movielist_bloc.dart
import 'dart:async'; import 'package:bloc/bloc.dart'; import 'package:movieapp/pages/home/widgets/movielist/repository/movies_repository.dart'; import './bloc.dart'; class MovieListBloc extends Bloc<MovieListEvent, MovieListState> { final MovieRepository _repository = MovieRepository(); @override MovieListState get initialState => MovieLoadingState(); @override Stream<MovieListState> mapEventToState(MovieListEvent event) async* { if (event is GetFavoriteMovieListEvent) { yield MovieLoadingState(); yield FavoriteMovieLoadedState(favoriteList: _repository.getMoviesList(MovieType.Favorite), name: 'Favorite List'); } else if (event is GetPopularMovieListEvent) { yield MovieLoadingState(); yield PopularMovieLoadedState(popularList: _repository.getMoviesList(MovieType.Popular), name: 'Popular List'); } } }
0
mirrored_repositories/movie_app/lib/pages/home/widgets/movielist/bloc
mirrored_repositories/movie_app/lib/pages/home/widgets/movielist/bloc/movielist/movielist_state.dart
import 'package:equatable/equatable.dart'; abstract class MovieListState extends Equatable { const MovieListState(); @override List<Object> get props => []; } class MovieLoadingState extends MovieListState {} class FavoriteMovieLoadedState extends MovieListState { final List<String> favoriteList; final String name; FavoriteMovieLoadedState({this.favoriteList, this.name}); @override List<Object> get props => [favoriteList]; } class PopularMovieLoadedState extends MovieListState { final List<String> popularList; final String name; PopularMovieLoadedState({this.popularList, this.name}); @override List<Object> get props => [popularList]; }
0
mirrored_repositories/movie_app/lib/pages/home/widgets
mirrored_repositories/movie_app/lib/pages/home/widgets/banner/banner_state_builder.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:movieapp/pages/home/widgets/banner/bloc/banner_bloc.dart'; import 'package:movieapp/pages/home/widgets/banner/bloc/banner_state.dart'; import 'top_banner_container.dart'; class BannerStateBuilder extends StatelessWidget { @override Widget build(BuildContext context) { var currentState = BlocProvider .of<BannerBloc>(context) .state; if (currentState is LoadingBannerState) { return Center( child: CircularProgressIndicator(), ); } else if (currentState is LoadedBannerState) { return BannerContainer(); } } }
0
mirrored_repositories/movie_app/lib/pages/home/widgets
mirrored_repositories/movie_app/lib/pages/home/widgets/banner/top_banner_container.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:movieapp/pages/home/widgets/banner/bloc/banner_bloc.dart'; import 'package:movieapp/pages/home/widgets/banner/bloc/banner_state.dart'; import 'package:movieapp/model/movie_model.dart'; import 'package:movieapp/pages/detail/movie_detail.dart'; class BannerContainer extends StatefulWidget { @override _BannerContainerState createState() => _BannerContainerState(); } class _BannerContainerState extends State<BannerContainer> { PageController _pageController; LoadedBannerState _bannerLoadedState; @override void initState() { super.initState(); _pageController = PageController(initialPage: 1, viewportFraction: 0.8); _bannerLoadedState = BlocProvider.of<BannerBloc>(context).state as LoadedBannerState; } @override Widget build(BuildContext context) { return Container( height: 250, width: double.infinity, // match_parent in android child: PageView.builder( itemBuilder: (BuildContext context, int page) { return BannerSelector(page: page,pageController: _pageController, movie: _bannerLoadedState.moviesList[page]); }, itemCount: _bannerLoadedState.moviesList.length, controller: _pageController, ), ); } @override void dispose() { _pageController.dispose(); super.dispose(); } } class BannerSelector extends StatelessWidget { final int page; final PageController pageController; final Movie movie; const BannerSelector({Key key, this.page, this.pageController, this.movie}) : super(key: key); @override Widget build(BuildContext context) { return AnimatedBuilder( animation: pageController, builder: (BuildContext context, Widget widget) { double value = 1; if (pageController.position.haveDimensions) { value = pageController.page - page; value = (1 - (value.abs() * 0.3) + 0.02).clamp(0.0, 1.0); } return GestureDetector( onTap: ()=> Navigator.push(context, MaterialPageRoute(builder: (_) => MovieDetailPage(movie))), child: Center( child: SizedBox( height: Curves.easeInOut.transform(value) * 270, width: Curves.easeInOut.transform(value) * 400, child: widget, ), ), ); }, child: Stack( children: <Widget>[ Center( child: Container( margin: EdgeInsets.symmetric(vertical: 20, horizontal: 10), decoration: BoxDecoration( boxShadow: [ BoxShadow( color: Colors.black54, offset: Offset(0, 4), blurRadius: 10) ], ), child: Hero( tag: movie.imageUrl, child: ClipRRect( borderRadius: BorderRadius.circular(10), child: Image( image: AssetImage(movie.imageUrl), fit: BoxFit.fill, height: 220, width: double.infinity, ), ), ), ), ), Positioned( child: Text( movie.title, style: TextStyle( color: Colors.white, fontSize: 16, fontWeight: FontWeight.bold), ), bottom: 25, left: 20, width: 200, ) ], ), ); } }
0
mirrored_repositories/movie_app/lib/pages/home/widgets/banner
mirrored_repositories/movie_app/lib/pages/home/widgets/banner/repository/banner_repository.dart
import 'package:movieapp/model/movie_model.dart'; class BannerRepository { // In real app, you can make the API call here and return Future<List<Movie>> List<Movie> getBannerList() { return movies; } }
0
mirrored_repositories/movie_app/lib/pages/home/widgets/banner
mirrored_repositories/movie_app/lib/pages/home/widgets/banner/bloc/bloc.dart
export 'banner_bloc.dart'; export 'banner_event.dart'; export 'banner_state.dart';
0
mirrored_repositories/movie_app/lib/pages/home/widgets/banner
mirrored_repositories/movie_app/lib/pages/home/widgets/banner/bloc/banner_bloc.dart
import 'dart:async'; import 'package:bloc/bloc.dart'; import 'package:movieapp/pages/home/widgets/banner/repository/banner_repository.dart'; import 'bloc.dart'; class BannerBloc extends Bloc<BannerEvent, BannerState> { BannerRepository _repository = BannerRepository(); @override BannerState get initialState => LoadingBannerState(); @override Stream<BannerState> mapEventToState(BannerEvent event,) async* { if (event is AppStartEvent) { yield LoadingBannerState(); yield LoadedBannerState(moviesList: _repository.getBannerList()); } } }
0
mirrored_repositories/movie_app/lib/pages/home/widgets/banner
mirrored_repositories/movie_app/lib/pages/home/widgets/banner/bloc/banner_state.dart
import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:movieapp/model/movie_model.dart'; abstract class BannerState extends Equatable { const BannerState(); @override List<Object> get props => []; } class LoadingBannerState extends BannerState {} class LoadedBannerState extends BannerState { final List<Movie> moviesList; LoadedBannerState({@required this.moviesList}); @override List<Object> get props => [moviesList]; }
0
mirrored_repositories/movie_app/lib/pages/home/widgets/banner
mirrored_repositories/movie_app/lib/pages/home/widgets/banner/bloc/banner_event.dart
import 'package:equatable/equatable.dart'; abstract class BannerEvent extends Equatable { const BannerEvent(); @override List<Object> get props => []; } class AppStartEvent extends BannerEvent {}
0
mirrored_repositories/movie_app/lib
mirrored_repositories/movie_app/lib/model/movie_model.dart
class Movie { String imageUrl; String title; String categories; int year; String country; int length; String description; List<String> screenshots; double rating; Movie( {this.imageUrl, this.title, this.categories, this.year, this.country, this.length, this.description, this.screenshots, this.rating}); } final List<Movie> movies = [ Movie( imageUrl: 'assets/images/spiderman.jpg', title: 'Spider-Man: Far From Home', categories: 'Fantasy, Sci-fi', year: 2018, country: 'USA', length: 129, description: 'Our friendly neighborhood Super Hero decides to join his best friends Ned, MJ, and the rest of the gang on a European vacation. However, Peter\'s plan to leave super heroics behind for a few weeks are quickly scrapped when he begrudgingly agrees to help Nick Fury uncover the mystery of several elemental creature attacks, creating havoc across the continent.', screenshots: [ 'assets/images/spiderman_0.jpg', 'assets/images/spiderman_1.jpg', 'assets/images/spiderman_2.jpg', ], rating: 4.0), Movie( imageUrl: 'assets/images/nutcracker.jpg', title: 'The Nutcracker And The Four Realms', categories: 'Adventure, Family, Fantasy', year: 2018, country: 'USA', length: 100, description: 'All Clara wants is a key - a one-of-a-kind key that will unlock a box that holds a priceless gift from her late mother. A golden thread, presented to her at godfather Drosselmeyer\'s annual holiday party, leads her to the coveted key-which promptly disappears into a strange and mysterious parallel world. It\'s there that Clara encounters a soldier named Phillip, a gang of mice and the regents who preside over three Realms: Land of Snowflakes, Land of Flowers, and Land of Sweets. Clara and Phillip must brave the ominous Fourth Realm, home to the tyrant Mother Ginger, to retrieve Clara\'s key and hopefully return harmony to the unstable world.', screenshots: [ 'assets/images/nutcracker_0.jpg', 'assets/images/nutcracker_1.jpg', 'assets/images/nutcracker_2.jpg', ], rating: 3.5, ), Movie( imageUrl: 'assets/images/toystory.jpg', title: 'Toy Story 4', categories: 'Adventure, Fantasy', year: 2019, country: 'USA', length: 100, description: 'Woody, Buzz Lightyear and the rest of the gang embark on a road trip with Bonnie and a new toy named Forky. The adventurous journey turns into an unexpected reunion as Woody\'s slight detour leads him to his long-lost friend Bo Peep. As Woody and Bo discuss the old days, they soon start to realize that they\'re two worlds apart when it comes to what they want from life as a toy.', screenshots: [ 'assets/images/toystory_0.jpg', 'assets/images/toystory_1.jpg', 'assets/images/toystory_2.jpg', ], rating: 4.5, ), ]; class Label { String imageUrl; String title; Label(this.imageUrl, this.title); } final List<Label> labels = [ Label('assets/images/seven_deadly_sins.jpg', 'Discovery'), Label('assets/images/daredevil.jpg', 'Categories'), Label('assets/images/endgame.jpg', 'Specials'), Label('assets/images/shigatsu_wa_kimi_no_uso.jpg', 'New'), ]; final List<String> favorite = [ 'assets/images/shigatsu_wa_kimi_no_uso.jpg', 'assets/images/plastic_memories.png', 'assets/images/erased.jpg', 'assets/images/seven_deadly_sins.jpg', 'assets/images/cobra_kai.jpg', ]; final List<String> popular = [ 'assets/images/stranger_things.jpg', 'assets/images/endgame.jpg', 'assets/images/oitnb.jpg', 'assets/images/daredevil.jpg', ];
0
mirrored_repositories/movie_app
mirrored_repositories/movie_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 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:movieapp/main.dart'; void main() { }
0
mirrored_repositories/music
mirrored_repositories/music/lib/util.dart
import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart'; import 'cupertino_swipe_back_observer.dart'; class Util { static Future openPage(context, Widget builder) async { // wait until animation finished await CupertinoSwipeBackObserver.promise?.future; return await Navigator.of(context).push( CupertinoPageRoute(builder: (ctx) => builder), ); } // 复制内容到剪贴板 static copyToClipboard(final String text) { if (text == null) return; Clipboard.setData(new ClipboardData(text: text)); } }
0
mirrored_repositories/music
mirrored_repositories/music/lib/cupertino_swipe_back_observer.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; // 此类修复左滑关闭窗口时导致程序奔溃的bug // See:https://github.com/flutter/flutter/issues/27334#issuecomment-468179107 class CupertinoSwipeBackObserver extends NavigatorObserver { static Completer promise; @override void didStartUserGesture(Route route, Route previousRoute) { // make a new promise promise = Completer(); super.didStartUserGesture(route, previousRoute); } @override void didStopUserGesture() { super.didStopUserGesture(); // resolve the promise promise.complete(); } }
0
mirrored_repositories/music
mirrored_repositories/music/lib/items.dart
import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:dio/dio.dart'; import 'dart:convert'; import 'util.dart'; import 'player.dart'; class Items extends StatelessWidget { Items({Key key, this.type, this.keyword}) : super(key: key); final String type; final String keyword; @override Widget build(BuildContext context) { return Material( child: ItemsPage( type: type, keyword: keyword, ), ); } } class ItemsPage extends StatefulWidget { ItemsPage({Key key, this.type, this.keyword}) : super(key: key); final String type; final String keyword; @override _ItemsPageState createState() => _ItemsPageState(); } class _ItemsPageState extends State<ItemsPage> { List _list = List(); // 页码 int _page = 1; // 每页显示数量 int _limit = 30; // 是否正在请求 bool _request = false; // 是否为最后一页 bool _isLastPage = false; ScrollController _scrollController = ScrollController(); @override void initState() { super.initState(); _getList(widget.type, widget.keyword); _scrollController.addListener(() { if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) { _getList(widget.type, widget.keyword); } }); } @override Widget build(BuildContext context) { return CupertinoPageScaffold( navigationBar: CupertinoNavigationBar( middle: const Text("搜索列表"), ), child: ListView.separated( separatorBuilder: (context, index) => Divider(height: .0), controller: _scrollController, itemCount: _list == null ? 1 : _list.length + 1, itemBuilder: _render, ), ); } Widget _getMoreWidget() { if (_isLastPage) { return Container( alignment: Alignment.center, padding: EdgeInsets.all(16.0), child: Text( "没有更多了", style: TextStyle(color: Colors.grey), ), ); } else { return Container( padding: const EdgeInsets.all(16.0), alignment: Alignment.center, child: CupertinoActivityIndicator( radius: 10.0, ), ); } } // 渲染列表数据 Widget _render(BuildContext context, int index) { if (index < _list.length) { return ListTile( title: Text( "${_list[index]['name']}", style: TextStyle(fontWeight: FontWeight.bold), ), trailing: Text('${_list[index]['artist'][0]}'), onTap: () async { await Util.openPage(context, Player(detail: _list[index])); }, ); } return _getMoreWidget(); } Future<Null> _getList(String type, String keyword) async { if (!this.mounted) return; if (false == _request && false == _isLastPage || _list.length == 0) { setState(() { _request = true; _isLastPage = false; }); } try { await Dio().post( "https://api.wispx.cn/music/search", data: { 'type': type, 'keywords': keyword, 'page': _page, 'limit': _limit, }, ).then((response) { if (response.statusCode == 200) { var data = json.decode(response.data); if (data.length > 0) { setState(() { if (_page == 1 && data.length < _limit) { _isLastPage = true; } _list.addAll(data); _page++; }); } else { setState(() { _isLastPage = true; }); } } }); } catch (e) { await showCupertinoDialog( context: context, builder: (context) { return CupertinoAlertDialog( title: Text('发生错误'), content: Text('资源获取失败'), actions: <Widget>[ CupertinoDialogAction( child: const Text('好的'), onPressed: () { Navigator.pop(context); }, ), ], ); }, ); } } }
0
mirrored_repositories/music
mirrored_repositories/music/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'items.dart'; import 'cupertino_swipe_back_observer.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Poly Music', home: MyHomePage(title: 'Poly Music'), navigatorObservers: <NavigatorObserver>[ CupertinoSwipeBackObserver(), ], ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { String _type = 'netease'; TextEditingController _textController = TextEditingController(); ScrollController _scrollController; @override Widget build(BuildContext context) { return CupertinoPageScaffold( navigationBar: CupertinoNavigationBar( middle: const Text("Poly Music"), trailing: CupertinoButton( padding: EdgeInsets.all(0.0), child: const Text('关于'), onPressed: () { showCupertinoDialog( context: context, builder: (context) { return CupertinoAlertDialog( title: const Text('关于本软件'), content: const Text('作者邮箱:[email protected]'), actions: <Widget>[ CupertinoDialogAction( child: const Text('知道了'), onPressed: () { Navigator.pop(context); }, ), ], ); }, ); }, ), ), child: Container( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ SingleChildScrollView( scrollDirection: Axis.horizontal, controller: _scrollController, padding: EdgeInsets.fromLTRB(50.0, 0, 50.0, 10.0), child: Row( children: <Widget>[ Container( width: _type == 'netease' ? 80.0 : 60.0, height: _type == 'netease' ? 80.0 : 60.0, margin: EdgeInsets.all(10.0), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(50.0)), ), child: GestureDetector( child: CircleAvatar( foregroundColor: Colors.blue, backgroundImage: AssetImage('assets/images/netease.jpg'), ), onTap: () { setState(() { _type = 'netease'; }); }, ), ), Container( width: _type == 'tencent' ? 80.0 : 60.0, height: _type == 'tencent' ? 80.0 : 60.0, margin: EdgeInsets.all(10.0), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(50.0)), ), child: GestureDetector( child: CircleAvatar( foregroundColor: Colors.blue, backgroundImage: AssetImage('assets/images/tencent.jpg'), ), onTap: () { setState(() { _type = 'tencent'; }); }, ), ), Container( width: _type == 'xiami' ? 80.0 : 60.0, height: _type == 'xiami' ? 80.0 : 60.0, margin: EdgeInsets.all(10.0), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(50.0)), ), child: GestureDetector( child: CircleAvatar( foregroundColor: Colors.blue, backgroundImage: AssetImage('assets/images/xiami.jpg'), ), onTap: () { setState(() { _type = 'xiami'; }); }, ), ), Container( width: _type == 'kugou' ? 80.0 : 60.0, height: _type == 'kugou' ? 80.0 : 60.0, margin: EdgeInsets.all(10.0), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(50.0)), ), child: GestureDetector( child: CircleAvatar( foregroundColor: Colors.blue, backgroundImage: AssetImage('assets/images/kugou.jpg'), ), onTap: () { setState(() { _type = 'kugou'; }); }, ), ), Container( width: _type == 'baidu' ? 80.0 : 60.0, height: _type == 'baidu' ? 80.0 : 60.0, margin: EdgeInsets.all(10.0), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(50.0)), ), child: GestureDetector( child: CircleAvatar( foregroundColor: Colors.blue, backgroundImage: AssetImage('assets/images/baidu.jpg'), ), onTap: () { setState(() { _type = 'baidu'; }); }, ), ), ], ), ), Center( child: Padding( padding: EdgeInsets.fromLTRB(50.0, 20.0, 50.0, 0), child: CupertinoTextField( cursorColor: Colors.white, controller: _textController, placeholder: '输入歌曲名称搜索\\( ̄︶ ̄)/', keyboardType: TextInputType.text, padding: EdgeInsets.all(20.0), textAlign: TextAlign.center, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(50.0), boxShadow: const [ BoxShadow(blurRadius: 20.0, color: Colors.black26), ], ), onEditingComplete: () { if (_textController.text != '' && _textController.text != null) { Navigator.push( context, CupertinoPageRoute( fullscreenDialog: true, builder: (context) => Items( type: _type, keyword: _textController.text, ), ), ); } }, ), ), ), ], ), ), ); } @override dispose() { _textController.dispose(); _scrollController.dispose(); super.dispose(); } }
0
mirrored_repositories/music
mirrored_repositories/music/lib/player.dart
import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:dio/dio.dart'; import 'dart:convert'; import 'package:audioplayers/audioplayers.dart'; import 'util.dart'; class Player extends StatelessWidget { Player({Key key, this.detail}) : super(key: key); final Map detail; @override Widget build(BuildContext context) { return MyPlayerPage(detail: detail); } } class MyPlayerPage extends StatefulWidget { MyPlayerPage({Key key, this.detail}) : super(key: key); final Map detail; @override _MyPlayerPageState createState() => _MyPlayerPageState(); } class _MyPlayerPageState extends State<MyPlayerPage> { // 音乐资源地址 String _musicResourcesUrl; // 音乐图片地址 String _musicPicUrl; // 播放状态 bool _state = false; AudioPlayer audioPlayer = new AudioPlayer(); @override void initState() { super.initState(); _getMusic(); // 监听播放进度 audioPlayer.onAudioPositionChanged.listen((Duration p) { // print('当前播放进度 $p'); }); } @override Widget build(BuildContext context) { return CupertinoPageScaffold( navigationBar: CupertinoNavigationBar( leading: CupertinoButton( padding: EdgeInsets.all(0.0), child: Row( children: <Widget>[Icon(Icons.arrow_back_ios), Text('Back')], ), onPressed: () { Navigator.pop(context); }, ), middle: Text("Player"), trailing: CupertinoButton( padding: EdgeInsets.all(0.0), child: Icon(Icons.more_horiz), onPressed: () { _showDialog(context); }, ), ), child: Container( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Center( child: Container( width: 200.0, height: 200.0, margin: EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 30.0), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(200.0), boxShadow: const [ BoxShadow(blurRadius: 50.0, color: Colors.black26), ], ), child: ClipOval( child: null == _musicPicUrl && null == _musicResourcesUrl ? Center( child: CupertinoActivityIndicator(radius: 10.0), ) : FadeInImage( placeholder: AssetImage( 'assets/images/${widget.detail['source']}.jpg', ), image: NetworkImage(_musicPicUrl), ), ), ), ), Center( child: CupertinoButton( padding: EdgeInsets.all(0.0), child: Icon( _state ? CupertinoIcons.pause_solid : CupertinoIcons.play_arrow_solid, size: 70.0, ), onPressed: _play, ), ) ], ), ), ); } void _init() async { int result = await audioPlayer.play(_musicResourcesUrl); if (result == 1) { setState(() { _state = true; }); } else { _showBackAlertDialog(context); } } void _play() async { setState(() { _state = !_state; }); audioPlayer.onPlayerStateChanged.listen((AudioPlayerState s) { print('当前播放状态: $s'); }); if (_state) { await audioPlayer.resume(); } else { await audioPlayer.pause(); } } Future<Null> _getMusic() async { if (!mounted) return; try { // 获取歌曲图片 await Dio().post('https://api.wispx.cn/music/pic', data: { 'id': widget.detail['pic_id'], 'type': widget.detail['source'], }).then((response) { if (response.statusCode == 200) { var data = json.decode(response.data); setState(() { _musicPicUrl = data['url']; }); } else { throw Exception('接口异常'); } }); // 获取歌曲资源 await Dio().post( 'https://api.wispx.cn/music/url', data: { 'id': widget.detail['url_id'], 'type': widget.detail['source'], }, ).then((response) { if (response.statusCode == 200) { var data = json.decode(response.data); setState(() { _musicResourcesUrl = data['url']; }); _init(); } else { throw Exception('接口异常'); } }); } catch (e) { _showBackAlertDialog(context); } } _showBackAlertDialog(BuildContext context) async { final result = await showCupertinoDialog( context: context, builder: (context) { return CupertinoAlertDialog( content: Text('资源获取失败!'), actions: <Widget>[ CupertinoDialogAction( child: const Text('好的'), onPressed: () { Navigator.pop(context, 'back'); }, ), ], ); }, ); if (result != null && result == 'back') { Navigator.pop(context); } } _showMsgAlertDialog(BuildContext context, {String msg}) async { await showCupertinoDialog( context: context, builder: (context) { return CupertinoAlertDialog( content: Text(msg), actions: <Widget>[ CupertinoDialogAction( child: const Text('好的'), onPressed: () { Navigator.pop(context); }, ), ], ); }, ); } void _showDialog(BuildContext context) async { await showCupertinoModalPopup<int>( context: context, builder: (context) { return CupertinoActionSheet( title: Text("More"), cancelButton: CupertinoActionSheetAction( child: Text("Cancel"), onPressed: () { Navigator.pop(context); }, ), actions: <Widget>[ CupertinoActionSheetAction( child: Text('复制歌曲ID'), onPressed: () { Util.copyToClipboard(widget.detail['id'].toString()); Navigator.pop(context); _showMsgAlertDialog(context, msg: '复制成功'); }, ), CupertinoActionSheetAction( child: Text('复制歌曲名称'), onPressed: () { Util.copyToClipboard(widget.detail['name'].toString()); Navigator.pop(context); _showMsgAlertDialog(context, msg: '复制成功'); }, ), CupertinoActionSheetAction( child: Text('复制歌手名称'), onPressed: () { Util.copyToClipboard(widget.detail['artist'][0].toString()); Navigator.pop(context); _showMsgAlertDialog(context, msg: '复制成功'); }, ), CupertinoActionSheetAction( child: Text('复制歌曲链接'), onPressed: () { Util.copyToClipboard(_musicResourcesUrl.toString()); Navigator.pop(context); _showMsgAlertDialog(context, msg: '复制成功'); }, ), ], ); }, ); } @override void dispose() { // 释放播放器 audioPlayer.release(); super.dispose(); } }
0
mirrored_repositories/music
mirrored_repositories/music/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:music/main.dart'; void main() { /*testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); });*/ }
0
mirrored_repositories/DogLife
mirrored_repositories/DogLife/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter_dog/pages/reset-password.page.dart'; import 'pages/login.page.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Dog Life', debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.deepOrange, ), home: LoginPage (), ); } }
0
mirrored_repositories/DogLife/lib
mirrored_repositories/DogLife/lib/pages/reset-password.page.dart
// ignore_for_file: prefer_const_constructors, use_key_in_widget_constructors, prefer_const_literals_to_create_immutables import 'dart:convert'; import 'package:flutter/material.dart'; class ResetPasswordPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.white, leading: IconButton( icon: Icon(Icons.arrow_back), color: Colors.black, onPressed:() => Navigator.pop(context, false), ), ), body: Container( padding: EdgeInsets.only( top: 60, left: 40, right: 40, ), color: Colors.white, child: ListView( children: [ SizedBox( height: 200, width: 200, child: Image.asset("assets/reset-password-icon.png"), ), SizedBox( height: 20, ), Text( "Esqueceu sua senha?", style: TextStyle( fontSize: 32, fontWeight: FontWeight.w500, ), textAlign: TextAlign.center, ), SizedBox( height: 10, ), Text( "Por favor, informe o E-mail associado a sua conta que enviaremos um link com as instruções para a recuperação de sua senha.", style: TextStyle( fontSize: 17, fontWeight: FontWeight.w400, ), textAlign: TextAlign.center, ), SizedBox( height: 20, ), TextFormField( keyboardType: TextInputType.emailAddress, decoration: InputDecoration( labelText: "Digite seu e-mail", labelStyle: TextStyle( color: Colors.black38, fontWeight: FontWeight.w400, fontSize: 20, ), ), style: TextStyle(fontSize: 18), ), SizedBox( height: 20, ), Container( height: 60, alignment: Alignment.centerLeft, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, stops: [0.2, 1], colors: [ Color(0xFFF58524), Color(0xFFF92B7F), ], ), borderRadius: BorderRadius.all( Radius.circular(5), ), ), child: SizedBox.expand( child: TextButton( child: Text( "Enviar", style: TextStyle( fontWeight: FontWeight.bold, color: Colors.white, fontSize: 20, ), textAlign: TextAlign.center, ), onPressed: () {}, ), ), ), SizedBox( height: 20, ), ], ), ), ); } }
0
mirrored_repositories/DogLife/lib
mirrored_repositories/DogLife/lib/pages/login.page.dart
// ignore_for_file: use_key_in_widget_constructors, prefer_const_constructors, prefer_const_literals_to_create_immutables, avoid_unnecessary_containers, sort_child_properties_last import 'package:flutter/material.dart'; import 'package:flutter_dog/pages/reset-password.page.dart'; import 'package:flutter_dog/pages/signup.page.dart'; class LoginPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: Container( padding: EdgeInsets.only( top: 60, left: 40, right: 40, ), color: Colors.white, child: ListView( children: [ SizedBox(//diminuindo a imagem width: 128, height: 128, child: Image.asset("assets/logo.png"), ), SizedBox( height: 30, ), TextFormField( keyboardType: TextInputType.emailAddress, decoration: InputDecoration( labelText: "E-mail", labelStyle: TextStyle( color: Colors.black38, fontWeight: FontWeight.w400, fontSize: 20, ), ), style: TextStyle( fontSize: 20, ), ), SizedBox( height: 10, ), TextFormField( keyboardType: TextInputType.text, obscureText: true, decoration: InputDecoration( labelText: "Senha", labelStyle: TextStyle( color: Colors.black38, fontWeight: FontWeight.w400, fontSize: 20, ), ), style: TextStyle( fontSize: 20, ), ), Container( height: 40, alignment: Alignment.centerRight, child: TextButton( onPressed: (){ Navigator.push( context, MaterialPageRoute( builder: (context) => ResetPasswordPage(), ), ); }, child: Text( "Esqueci minha Senha", style: TextStyle( fontWeight: FontWeight.w600, fontSize: 15, ), ), ), ), SizedBox( height: 40, ), Container( height: 60, alignment: Alignment.centerLeft, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, stops: [0.2, 1], colors: [ Color(0xFFF58524), Color(0xFFF92B7F), ], ), borderRadius: BorderRadius.all( Radius.circular(5), ), ), child: SizedBox.expand( child: TextButton( child: Row ( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Text( "Entrar", style: TextStyle( fontWeight: FontWeight.bold, color: Colors.white, fontSize: 26, ), textAlign: TextAlign.left, ), Container( child: SizedBox( child: Image.asset("assets/bone.png"), height: 28, width: 28, ), ) ], ), onPressed: () {}, ), ), ), SizedBox( height: 10, ), Container( height: 60, alignment: Alignment.centerLeft, decoration: BoxDecoration( color: Color(0xFF3C5A99), borderRadius: BorderRadius.all( Radius.circular(5), ), ), child: SizedBox.expand( child: TextButton( child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Text( "Entrar com Facebook", style: TextStyle( fontWeight: FontWeight.bold, color: Colors.white, fontSize: 22, ), textAlign: TextAlign.left, ), Container( child: SizedBox( child: Image.asset("assets/fb-icon.png"), height: 28, width: 28, ), ) ], ), onPressed: () {}, ), ), ), SizedBox( height: 10, ), Container( height: 40, child: TextButton( child: Text( "Cadastre-se", textAlign: TextAlign.center, style: TextStyle( fontSize: 17, ), ), onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) => SignupPage (), ), ); }, ), ) ], ), ), ); } }
0
mirrored_repositories/DogLife/lib
mirrored_repositories/DogLife/lib/pages/signup.page.dart
// ignore_for_file: prefer_const_constructors, use_key_in_widget_constructors, prefer_const_literals_to_create_immutables, unnecessary_new import 'dart:ffi'; import 'package:flutter/material.dart'; class SignupPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: Container( padding: EdgeInsets.only(top: 10, left: 40, right: 40), color: Colors.white, child: ListView( children: [ Container( width: 200, height: 200, alignment: Alignment(0.0, 1.15),//alinha o container filho decoration: new BoxDecoration( image: new DecorationImage( image: AssetImage("assets/profile-picture.png"), fit: BoxFit.fitHeight, ), ), child: Container( height: 56, width: 56, alignment: Alignment.center, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, stops: [0.2, 1.0], colors: [ Color(0xFFF58524), Color(0xFFF92B7F), ], ), border: Border.all( width: 4.0, color: const Color(0xFFFFFFFF), ), borderRadius: BorderRadius.all( Radius.circular(56) ), ), child: SizedBox.expand( child: TextButton( child: Icon( Icons.add, color: Colors.white, ), onPressed: () {}, ), ), ), ), SizedBox( height: 20, ), TextFormField( keyboardType: TextInputType.text, decoration: InputDecoration( labelText: "Nome", labelStyle: TextStyle( color: Colors.black38, fontWeight: FontWeight.w400, fontSize: 20, ), ), style: TextStyle( fontSize: 20, ), ), SizedBox( height: 10, ), TextFormField( keyboardType: TextInputType.emailAddress, decoration: InputDecoration( labelText: "E-mail", labelStyle: TextStyle( color: Colors.black38, fontWeight: FontWeight.w400, fontSize: 20, ), ), style: TextStyle( fontSize: 20, ), ), SizedBox( height: 10, ), TextFormField( keyboardType: TextInputType.text, obscureText: true, decoration: InputDecoration( labelText: "Senha", labelStyle: TextStyle( color: Colors.black38, fontWeight: FontWeight.w400, fontSize: 20, ), ), style: TextStyle(fontSize: 20), ), SizedBox( height: 10, ), TextFormField( keyboardType: TextInputType.text, obscureText: true, decoration: InputDecoration( labelText: "Confirmar Senha", labelStyle: TextStyle( color: Colors.black38, fontWeight: FontWeight.w400, fontSize: 20, ), ), style: TextStyle(fontSize: 20), ), SizedBox( height: 20, ), Container( height: 60, alignment: Alignment.centerLeft, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, stops: [0.2, 1], colors: [ Color(0xFFF58524), Color(0xFFF92B7F), ], ), borderRadius: BorderRadius.all( Radius.circular(15), ), ), child: SizedBox.expand( child: TextButton( child: Text( "Cadastrar", style: TextStyle( fontWeight: FontWeight.bold, color: Colors.white, fontSize: 20, ), textAlign: TextAlign.center, ), onPressed: () {}, ), ), ), SizedBox( height: 10, ), Container( height: 40, alignment: Alignment.center, child: TextButton( child: Text( "Cancelar", textAlign: TextAlign.center, style: TextStyle( fontSize: 16, ), ), onPressed: () => Navigator.pop(context, false), ), ), ], ), ), ); } }
0
mirrored_repositories/DogLife
mirrored_repositories/DogLife/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_dog/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/Taxi-App
mirrored_repositories/Taxi-App/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_bloc.dart'; import 'package:taxi_app/screens/home_screen.dart'; void main() => runApp(MultiBlocProvider(providers: [ BlocProvider<TaxiBookingBloc>( create: (context) => TaxiBookingBloc(), ) ], child: MyApp())); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Taxi', debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.blue, primaryColor: Colors.black, fontFamily: 'Ubuntu', textTheme: TextTheme( title: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w600), subtitle: TextStyle(color: Colors.black54), subhead: TextStyle(color: Colors.black54, fontWeight: FontWeight.w800), headline: TextStyle(fontSize: 18.0, fontWeight: FontWeight.w800))), home: HomeScreen(), ); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/controllers/user_controller.dart
import 'package:taxi_app/models/user.dart'; class UserController { static User getUser() { return User( name: "Bhavneet Singh", mobileNumber: "+911234567890", photoUrl: "https://avatars0.githubusercontent.com/u/31070108?s=460&v=4"); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/controllers/payment_method_controller.dart
import 'package:taxi_app/models/payment_method.dart'; class PaymentMethodController { static Future<List<PaymentMethod>> getMethods() async { return [ PaymentMethod( title: "Cash", description: "Default", id: "1", icon: "https://cdn4.iconfinder.com/data/icons/aiga-symbol-signs/612/aiga_cashier_bg-512.png"), PaymentMethod( title: "Master Card", description: "**** **** **** 4863", id: "2", icon: "https://icon-library.net/images/mastercard-icon-png/mastercard-icon-png-28.jpg") ]; } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/controllers/location_controller.dart
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:taxi_app/models/google_location.dart'; class LocationController { static Future<GoogleLocation> getCurrentLocation() async { return GoogleLocation("ChIJN1t_tDeuEmsRUsoyG83frY4", LatLng(40.7829, -73.9654), "Central Parl, New York, NY, USA"); } static Future<GoogleLocation> getLocationfromId(LatLng position) async { return GoogleLocation("ChIJN1t_tDeuEmsRUsoyG83frY4", LatLng(40.747092, -73.987013), "20 W 34th St, New York, NY 10001, USA"); } static Future<List<LatLng>> getPolylines(LatLng start, LatLng end) async { List<Map> map = [ {"lat": 40.7835246, "lng": -73.9651392}, {"lat": 40.74700869999999, "lng": -73.9870749}, {"lat": 40.7836479, "lng": -73.96495809999999}, {"lat": 40.78148909999999, "lng": -73.9627453}, {"lat": 40.7802148, "lng": -73.9613768}, {"lat": 40.74653929999999, "lng": -73.9859729}, {"lat": 40.74700869999999, "lng": -73.9870749} ]; return map.map((val) => LatLng(val["lat"], val["lng"])).toList(); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/controllers/taxi_controller.dart
import 'package:taxi_app/models/taxi.dart'; import 'package:taxi_app/models/taxi_type.dart'; class TaxiController { static Future<List<Taxi>> getTaxis() async { return [ Taxi.named( plateNo: "", isAvailable: true, taxiType: TaxiType.Standard, id: "1", title: "Standard"), Taxi.named( plateNo: "", isAvailable: true, taxiType: TaxiType.Premium, id: "2", title: "Premium"), Taxi.named( plateNo: "", isAvailable: true, taxiType: TaxiType.Platinum, id: "3", title: "Standard"), ]; } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/controllers/user_location_controller.dart
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:taxi_app/models/user_location.dart'; import 'package:location/location.dart'; class UserLocationController { static Future<LatLng> getCurrentLocation() async { Location location = Location(); bool check = await location.hasPermission(); if (!check) { bool result = await location.requestPermission(); if (result) { LocationData position = await location.getLocation(); return LatLng(position.latitude, position.longitude); } } return null; } static Future<List<UserLocation>> getSavedLocations() async { return [ UserLocation.named( name: "Home", locationType: UserLocationType.Home, position: LatLng(0, 0), minutesFar: 52), UserLocation.named( name: "Innov8", locationType: UserLocationType.Office, position: LatLng(0, 0), minutesFar: 36), ]; } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/controllers/taxi_booking_controller.dart
import 'dart:math'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:taxi_app/controllers/location_controller.dart'; import 'package:taxi_app/models/google_location.dart'; import 'package:taxi_app/models/taxi.dart'; import 'package:taxi_app/models/taxi_booking.dart'; import 'package:taxi_app/models/taxi_driver.dart'; class TaxiBookingController { static Future<double> getPrice(TaxiBooking taxiBooking) async { return 150; } static Future<TaxiDriver> getTaxiDriver(TaxiBooking booking) async { return TaxiDriver.named( driverPic: "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e3/Sidhu_in_Punjab.jpg/440px-Sidhu_in_Punjab.jpg", driverName: "Ram kapoor", driverRating: 4.5, taxiDetails: "Toyota (BFD823-434)"); } static Future<List<Taxi>> getTaxisAvailable() async { GoogleLocation location = await LocationController.getCurrentLocation(); const double maxRadius = 200 / 111300; Random random = Random(); List<Taxi> taxis = List<Taxi>.generate(10, (index) { double u = random.nextDouble(); double v = random.nextDouble(); double w = maxRadius + sqrt(u); double t = 2 * pi * v; double x1 = w * cos(t); double y1 = w * sin(t); x1 = x1 / cos(y1); LatLng oldPos = location.position; return Taxi.named( id: "$index", position: LatLng(x1 + oldPos.latitude, y1 + oldPos.longitude), title: "Taxi $index"); }); return taxis; } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/widgets/home_app_bar.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_state.dart'; import 'package:taxi_app/controllers/user_controller.dart'; import 'package:taxi_app/models/user.dart'; import 'package:taxi_app/widgets/ease_in_widget.dart'; class HomeAppBar extends StatefulWidget with PreferredSizeWidget { @override _HomeAppBarState createState() => _HomeAppBarState(); @override Size get preferredSize => Size.fromHeight(64); } class _HomeAppBarState extends State<HomeAppBar> with TickerProviderStateMixin { AnimationController controller; @override void initState() { super.initState(); controller = AnimationController( vsync: this, duration: Duration( milliseconds: 500, ), ); } @override Widget build(BuildContext context) { User user = UserController.getUser(); return BlocListener<TaxiBookingBloc, TaxiBookingState>( listener: (context, state) { if (state is TaxiBookingNotSelectedState) { controller.forward( from: 0, ); } else { if (controller.value == 1) controller.reverse(from: 1.0); } }, child: AnimatedBuilder( animation: controller, child: Container( padding: EdgeInsets.all(16.0), decoration: BoxDecoration(color: Colors.white, boxShadow: [ BoxShadow( color: Colors.black12.withOpacity(0.1), blurRadius: 25.0, spreadRadius: 0.2), ]), child: SafeArea( bottom: false, child: Row( children: <Widget>[ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: <Widget>[ Text("Hey ${user.name.split(" ")[0]}", style: TextStyle( color: Colors.black, fontSize: 18.0, fontWeight: FontWeight.w700, )), SizedBox( height: 6.0, ), Text( "Grab your new ride now", style: TextStyle( color: Colors.black54, fontWeight: FontWeight.w600), ), ], ), ), EaseInWidget( onTap: () { Scaffold.of(context).openEndDrawer(); }, child: Container( child: Icon(Icons.menu), padding: EdgeInsets.all(12.0), decoration: BoxDecoration( shape: BoxShape.circle, boxShadow: [ BoxShadow( color: Colors.black12.withOpacity(0.05), blurRadius: 25.0, spreadRadius: 0.2) ], color: Colors.white), ), ) ], ), ), ), builder: (context, child) { return FadeTransition( opacity: Tween<double>(begin: 0, end: 1).animate(controller), child: SlideTransition( position: Tween<Offset>(begin: Offset(0, -1), end: Offset(0, 0)) .animate(controller), child: child, ), ); }), ); } @override void dispose() { controller.dispose(); super.dispose(); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/widgets/taxi_booking_details_widget.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_event.dart'; import 'package:taxi_app/bloc/taxi_booking_state.dart'; import 'package:taxi_app/models/google_location.dart'; import 'package:taxi_app/models/taxi_booking.dart'; import 'package:taxi_app/widgets/rounded_button.dart'; class TaxiBookingDetailsWidget extends StatefulWidget { @override _TaxiBookingDetailsWidgetState createState() => _TaxiBookingDetailsWidgetState(); } class _TaxiBookingDetailsWidgetState extends State<TaxiBookingDetailsWidget> { GoogleLocation source, destination; int noOfPersons; DateTime bookingTime; @override void initState() { super.initState(); TaxiBooking taxiBooking = (BlocProvider.of<TaxiBookingBloc>(context).state as DetailsNotFilledState) .booking; noOfPersons = taxiBooking.noOfPersons; bookingTime = taxiBooking.bookingTime; source = taxiBooking.source; destination = taxiBooking.destination; } @override Widget build(BuildContext context) { return Container( child: Column( children: <Widget>[ Expanded( child: Container( padding: EdgeInsets.symmetric(horizontal: 6.0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min, children: <Widget>[ SizedBox( height: 20.0, ), Text( "Address", style: Theme.of(context).textTheme.headline, ), SizedBox( height: 24.0, ), buildInputWidget(source?.areaDetails, "hint", () {}), SizedBox( height: 16.0, ), buildInputWidget(destination?.areaDetails, "Enter your destination", () {}), SizedBox( height: 36.0, ), Text( "Seat and Time", style: Theme.of(context).textTheme.headline, ), SizedBox( height: 24.0, ), buildPersonSelector(), SizedBox( height: 24.0, ), buildTimeSelector() ], ), ), ), Row( children: <Widget>[ RoundedButton( onTap: () { BlocProvider.of<TaxiBookingBloc>(context) .add(BackPressedEvent()); }, iconData: Icons.keyboard_backspace, ), SizedBox( width: 18.0, ), Expanded( flex: 2, child: RoundedButton( text: "See Next", onTap: () { BlocProvider.of<TaxiBookingBloc>(context).add( DetailsSubmittedEvent( bookingTime: bookingTime, destination: destination, source: source, noOfPersons: noOfPersons)); }, ), ) ], ), ], ), ); } Widget buildPersonSelector() { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( "Need Seat", style: Theme.of(context).textTheme.title, ), Row( mainAxisSize: MainAxisSize.min, children: [1, 2, 3] .map((val) => GestureDetector( onTap: () { setState(() { noOfPersons = val; }); }, child: buildContainer("$val", val == noOfPersons))) .toList(), ) ], ); } Widget buildTimeSelector() { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: <Widget>[ Text( "Schedule Time", style: Theme.of(context).textTheme.title, ), bookingTime == null ? Container() : Text( "${bookingTime.day}-${bookingTime.month}-${bookingTime.year}", style: Theme.of(context).textTheme.subtitle, ) ], ), Row( mainAxisSize: MainAxisSize.min, children: [ buildTimeContainer( text: "Now", enabled: bookingTime == null, onTap: () { setState(() { bookingTime = null; }); }), buildTimeContainer( iconData: Icons.timer, enabled: bookingTime != null, onTap: () async { DateTime time = await showDatePicker( context: context, firstDate: DateTime.now(), lastDate: DateTime(2030), initialDate: DateTime.now()..add(Duration(days: 1)), initialDatePickerMode: DatePickerMode.day, ); setState(() { bookingTime = time; }); }) ], ) ], ); } Widget buildContainer(String val, bool enabled) { return Container( margin: EdgeInsets.symmetric(horizontal: 6.0), padding: EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0), decoration: BoxDecoration( color: enabled ? Colors.black : Color(0xffeeeeee), borderRadius: BorderRadius.circular(12.0)), child: Text( "$val", style: Theme.of(context).textTheme.headline.copyWith( color: enabled ? Colors.white : Colors.black, fontSize: 15.0), )); } Widget buildTimeContainer( {String text, IconData iconData, bool enabled = false, Function() onTap}) { return GestureDetector( onTap: onTap, child: Container( margin: EdgeInsets.symmetric(horizontal: 6.0), padding: EdgeInsets.all(12.0), decoration: BoxDecoration( color: enabled ? Colors.black : Color(0xffeeeeee), borderRadius: BorderRadius.circular(12.0)), child: text != null ? Text( "$text", style: Theme.of(context).textTheme.headline.copyWith( color: enabled ? Colors.white : Colors.black, fontSize: 15.0), ) : Icon( iconData, color: enabled ? Colors.white : Colors.black, size: 18.0, )), ); } Widget buildInputWidget(String text, String hint, Function() onTap) { return Container( padding: EdgeInsets.symmetric(vertical: 18.0, horizontal: 16.0), decoration: BoxDecoration( color: Color(0xffeeeeee).withOpacity(0.5), borderRadius: BorderRadius.circular(12.0), ), child: Text( text ?? hint, style: Theme.of(context) .textTheme .title .copyWith(color: text == null ? Colors.black45 : Colors.black), maxLines: 1, overflow: TextOverflow.ellipsis, ), ); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/widgets/taxi_booking_taxis_widget.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_event.dart'; import 'package:taxi_app/bloc/taxi_booking_state.dart'; import 'package:taxi_app/models/taxi_booking.dart'; import 'package:taxi_app/models/taxi_type.dart'; import 'package:taxi_app/widgets/rounded_button.dart'; class TaxiBookingTaxisWidget extends StatefulWidget { @override _TaxiBookingTaxisWidgetState createState() => _TaxiBookingTaxisWidgetState(); } class _TaxiBookingTaxisWidgetState extends State<TaxiBookingTaxisWidget> { TaxiBooking taxiBooking; final List<TaxiType> taxiTypes = [ TaxiType.Standard, TaxiType.Premium, TaxiType.Platinum ]; @override void initState() { super.initState(); taxiBooking = (BlocProvider.of<TaxiBookingBloc>(context).state as TaxiNotSelectedState) .booking; selectedTaxiType = taxiBooking.taxiType; if (selectedTaxiType == null) { selectedTaxiType = TaxiType.Standard; } } @override Widget build(BuildContext context) { return Container( child: Column( children: <Widget>[ Expanded( child: Container( padding: EdgeInsets.symmetric(horizontal: 6.0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min, children: <Widget>[ SizedBox( height: 20.0, ), Text( "Choose Taxi", style: Theme.of(context).textTheme.headline, maxLines: 1, overflow: TextOverflow.ellipsis, ), SizedBox( height: 16.0, ), buildTaxis(), buildPriceDetails(), SizedBox( height: 16.0, ), buildLocation(taxiBooking.source.areaDetails, "From"), SizedBox( height: 12.0, ), Padding( padding: const EdgeInsets.symmetric(horizontal: 12.0), child: Divider(), ), SizedBox( height: 12.0, ), buildLocation(taxiBooking.destination.areaDetails, "To"), ], ), ), ), Row( children: <Widget>[ RoundedButton( onTap: () { BlocProvider.of<TaxiBookingBloc>(context) .add(BackPressedEvent()); }, iconData: Icons.keyboard_backspace, ), SizedBox( width: 18.0, ), Expanded( flex: 2, child: RoundedButton( text: "Request Trip", onTap: () { BlocProvider.of<TaxiBookingBloc>(context) .add(TaxiSelectedEvent(taxiType: selectedTaxiType)); }, ), ) ], ), ], ), ); } TaxiType selectedTaxiType; Widget buildTaxis() { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: taxiTypes .map((val) => GestureDetector( onTap: () { setState(() { selectedTaxiType = val; }); }, child: Opacity( opacity: val == selectedTaxiType ? 1.0 : 0.5, child: Padding( padding: const EdgeInsets.all(12.0), child: Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ ClipRRect( borderRadius: BorderRadius.circular(16.0), child: Image.asset( "images/taxi.jpg", height: MediaQuery.of(context).size.width / 6, width: MediaQuery.of(context).size.width / 6, fit: BoxFit.cover, ), ), SizedBox( height: 12.0, ), Text( val.toString().replaceFirst("TaxiType.", ""), style: Theme.of(context).textTheme.title, ), ], ), ), ), )) .toList(), ); } Widget buildPriceDetails() { return Column( children: <Widget>[ Divider(), SizedBox( height: 14.0, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ buildIconText("21 km", Icons.directions), buildIconText("1-3", Icons.person_outline), buildIconText("\$150", Icons.monetization_on), ], ), SizedBox( height: 14.0, ), Divider() ], ); } Widget buildIconText(String text, IconData iconData) { return Row( children: <Widget>[ Icon( iconData, size: 22.0, color: Colors.black, ), Text( " $text", style: Theme.of(context).textTheme.title, ) ], ); } Widget buildLocation(String area, String label) { return Row( children: <Widget>[ Text( "•", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 32.0), ), SizedBox( width: 12.0, ), Expanded( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( "$label", style: TextStyle(fontSize: 14.0, color: Colors.black38), ), Text( "$area", style: Theme.of(context).textTheme.title, ) ], ), ) ], ); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/widgets/taxi_booking_confirmed_widget.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_state.dart'; import 'package:taxi_app/models/taxi_booking.dart'; import 'package:taxi_app/models/taxi_driver.dart'; import 'package:taxi_app/widgets/taxi_booking_cancellation_dialog.dart'; class TaxiBookingConfirmedWidget extends StatefulWidget { @override _TaxiBookingConfirmedWidgetState createState() => _TaxiBookingConfirmedWidgetState(); } class _TaxiBookingConfirmedWidgetState extends State<TaxiBookingConfirmedWidget> with TickerProviderStateMixin<TaxiBookingConfirmedWidget> { AnimationController animationController; Animation animation; TaxiDriver driver; TaxiBooking booking; @override void initState() { super.initState(); booking = (BlocProvider.of<TaxiBookingBloc>(context).state as TaxiBookingConfirmedState) .booking; driver = (BlocProvider.of<TaxiBookingBloc>(context).state as TaxiBookingConfirmedState) .driver; animationController = AnimationController(vsync: this, duration: Duration(milliseconds: 200)); animation = CurvedAnimation( curve: Curves.easeIn, parent: animationController, ); WidgetsBinding.instance.addPostFrameCallback((duration) { animationController.forward(); }); } @override Widget build(BuildContext context) { return AnimatedBuilder( animation: animation, child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min, children: <Widget>[ ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(40.0), topRight: Radius.circular(40.0)), child: Container( color: Colors.black, padding: EdgeInsets.symmetric( vertical: 28.0, horizontal: 28.0), child: Row( children: <Widget>[ Expanded( child: Text( "Ride Info", style: Theme.of(context) .textTheme .title .copyWith(color: Colors.white), ), ), InkWell( onTap: () { showDialog( context: context, builder: (context) => TaxiBookingCancellationDialog()); }, child: Icon( Icons.close, color: Colors.white, )) ], ), )), Container( color: Colors.black, child: ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(40.0), topRight: Radius.circular(40.0)), child: Container( padding: EdgeInsets.all(24.0), color: Colors.white, child: buildDriver(), ), ), ) ]), ), builder: (context, child) { return Container( height: 200.0 * animation.value, child: child, ); }); } Widget buildDriver() { return Row( children: <Widget>[ ClipRRect( borderRadius: BorderRadius.circular(12.0), child: Image.network( "${driver.driverPic}", width: 48.0, height: 48.0, fit: BoxFit.cover, ), ), SizedBox( width: 16.0, ), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ Text( "${driver.driverName}", style: Theme.of(context).textTheme.title, ), SizedBox( height: 4.0, ), Text( "${driver.taxiDetails}", style: Theme.of(context).textTheme.subtitle, ) ], )), SizedBox( width: 8.0, ), Container( decoration: BoxDecoration( color: Color(0xffeeeeee).withOpacity(0.5), borderRadius: BorderRadius.circular(12.0)), padding: EdgeInsets.all(6.0), child: Row( mainAxisSize: MainAxisSize.min, children: <Widget>[ Icon( Icons.star, color: Colors.yellow, size: 20.0, ), Text( "${driver.driverRating}", style: Theme.of(context).textTheme.title, ), ], ), ) ], ); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/widgets/rounded_button.dart
import 'package:flutter/material.dart'; import 'package:taxi_app/widgets/ease_in_widget.dart'; class RoundedButton extends StatelessWidget { final String text; final Function() onTap; final IconData iconData; const RoundedButton({Key key, this.text, this.iconData, @required this.onTap}) : super(key: key); @override Widget build(BuildContext context) { return EaseInWidget( onTap: onTap, child: Material( child: Container( padding: text != null ? EdgeInsets.symmetric(vertical: 22.0, horizontal: 16.0) : EdgeInsets.symmetric(vertical: 19.0, horizontal: 22.0), alignment: Alignment.center, decoration: BoxDecoration( color: Colors.black, borderRadius: BorderRadius.circular(12.0), boxShadow: [ BoxShadow( color: Colors.black12.withOpacity(0.1), blurRadius: 12.0, spreadRadius: 0.1) ]), child: text != null ? Text( "$text", style: Theme.of(context).textTheme.title.copyWith( color: Colors.white, ), ) : Icon( iconData, color: Colors.white, ), ), ), ); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/widgets/taxi_map.dart
import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:taxi_app/bloc/taxi_booking_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_event.dart'; import 'package:taxi_app/bloc/taxi_booking_state.dart'; import 'package:taxi_app/controllers/location_controller.dart'; import 'package:taxi_app/models/google_location.dart'; import 'package:taxi_app/models/taxi.dart'; import 'package:taxi_app/models/taxi_booking.dart'; import 'dart:ui' as ui; class TaxiMap extends StatefulWidget { @override _TaxiMapState createState() => _TaxiMapState(); } class _TaxiMapState extends State<TaxiMap> { GoogleMapController controller; Set<Marker> markers = Set<Marker>(); Set<Polyline> polylines = Set<Polyline>(); Set<Circle> circles = Set<Circle>(); GoogleLocation currentLocation; @override void initState() { super.initState(); } void clearData() { markers.clear(); polylines.clear(); circles.clear(); } Circle createCircle(Color color, LatLng position) { return Circle( circleId: CircleId(position.toString()), fillColor: color, strokeColor: color.withOpacity(0.4), center: position, strokeWidth: 75, radius: 32.0, visible: true); } @override Widget build(BuildContext context) { return Scaffold( body: BlocListener<TaxiBookingBloc, TaxiBookingState>( listener: (context, state) { if (state is TaxiBookingNotSelectedState) { List<Taxi> taxis = state.taxisAvailable; clearData(); addTaxis(taxis); } if (state is TaxiBookingConfirmedState) { clearData(); TaxiBooking booking = (state).booking; addPolylines(booking.source.position, booking.destination.position); } if (state is TaxiNotConfirmedState) { clearData(); TaxiBooking booking = (state).booking; addPolylines(booking.source.position, booking.destination.position); } }, child: GoogleMap( initialCameraPosition: CameraPosition(target: LatLng(17.0, 24.0), zoom: 8.0), onMapCreated: (controller) async { this.controller = controller; BlocProvider.of<TaxiBookingBloc>(context) .add(TaxiBookingStartEvent()); currentLocation = await LocationController.getCurrentLocation(); controller.animateCamera( CameraUpdate.newLatLngZoom(currentLocation.position, 12)); BlocProvider.of<TaxiBookingBloc>(context) .add(TaxiBookingStartEvent()); }, myLocationButtonEnabled: false, markers: markers, polylines: polylines, circles: circles, ), ), ); } Future addTaxis(List<Taxi> taxis) async { GoogleLocation currentPositon = await LocationController.getCurrentLocation(); circles.add(createCircle(Colors.blueAccent, currentPositon.position)); if (this.controller == null) { return; } controller.moveCamera(CameraUpdate.newLatLng(currentPositon.position)); markers.clear(); await Future.wait(taxis.map((taxi) async { final Uint8List markerIcon = await getBytesFromAsset("images/taxi_marker.png", 100); BitmapDescriptor descriptor = BitmapDescriptor.fromBytes(markerIcon); print('Taxi ${taxi.id}'); markers.add(Marker( markerId: MarkerId("${taxi.id}"), position: LatLng(taxi.position.latitude, taxi.position.longitude), infoWindow: InfoWindow( title: taxi.title, ), icon: descriptor, )); })); setState(() {}); } Future<Marker> createMarker( Color color, LatLng position, String title) async { final Uint8List markerIcon = await getBytesFromAsset("images/location.png", 100); BitmapDescriptor descriptor = BitmapDescriptor.fromBytes(markerIcon); return Marker( markerId: MarkerId("${position.toString()}"), position: position, infoWindow: InfoWindow( title: title, ), icon: descriptor, ); } Future<void> addPolylines(LatLng start, LatLng end) async { List<LatLng> result = await LocationController.getPolylines(start, end); setState(() {}); Marker startM = await createMarker(Colors.black, start, "Start"); Marker endM = await createMarker(Colors.black, end, "End"); markers.add(startM); markers.add(endM); for (int i = 1; i < result.length; i++) { polylines.add( Polyline( polylineId: PolylineId("${result[i].toString()}"), color: Colors.black, points: [result[i - 1], result[i]], width: 3, visible: true, startCap: Cap.roundCap, jointType: JointType.mitered, endCap: Cap.roundCap, geodesic: true, patterns: [PatternItem.dash(12)], zIndex: 1), ); } result.forEach((val) {}); setState(() {}); controller.animateCamera(CameraUpdate.newLatLngZoom(result[0], 14)); } Future<Uint8List> getBytesFromAsset(String path, int width) async { ByteData data = await rootBundle.load(path); ui.Codec codec = await ui.instantiateImageCodec(data.buffer.asUint8List(), targetWidth: width); ui.FrameInfo fi = await codec.getNextFrame(); return (await fi.image.toByteData(format: ui.ImageByteFormat.png)) .buffer .asUint8List(); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/widgets/taxi_booking_cancellation_dialog.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_event.dart'; class TaxiBookingCancellationDialog extends StatelessWidget { @override Widget build(BuildContext context) { return AlertDialog( title: Text("Cancel Ride"), content: Text("Do you want to cancel ride?"), actions: <Widget>[ FlatButton( child: Text( "Cancel", style: TextStyle(fontSize: 16.0), ), onPressed: () { Navigator.of(context).pop(); }, ), FlatButton( child: Text( "Ok", style: TextStyle(fontSize: 16.0), ), onPressed: () { BlocProvider.of<TaxiBookingBloc>(context) .add(TaxiBookingCancelEvent()); Navigator.of(context).pop(); }, ) ], ); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/widgets/home_drawer.dart
import 'package:flutter/material.dart'; import 'package:taxi_app/controllers/user_controller.dart'; import 'package:taxi_app/models/user.dart'; class HomeDrawer extends StatelessWidget { @override Widget build(BuildContext context) { User user = UserController.getUser(); return Drawer( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ Container( color: Colors.black, padding: EdgeInsets.fromLTRB(16, 8, 16, 24), child: SafeArea( bottom: false, child: Row( mainAxisSize: MainAxisSize.min, children: <Widget>[ Container( decoration: BoxDecoration( border: Border.all(color: Colors.white, width: 2.0), borderRadius: BorderRadius.circular(12.0)), child: ClipRRect( borderRadius: BorderRadius.circular(12.0), child: Image.network( user.photoUrl, width: 42, height: 42, fit: BoxFit.fill, ), ), ), SizedBox( width: 12.0, ), Expanded( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ Text( user.name ?? "", style: TextStyle( color: Colors.white, fontWeight: FontWeight.w600), ), SizedBox( height: 4.0, ), Text( user.mobileNumber ?? "", style: TextStyle( color: Colors.white60, fontSize: 12.0, fontWeight: FontWeight.w600), ) ], ), ) ], ), ), ), buildAction("My Rides", Icons.history, () {}), buildAction("Promotions", Icons.card_membership, () {}), buildAction("My Favourites", Icons.star_border, () {}), buildAction("My payment", Icons.payment, () {}), buildAction("Notification", Icons.notifications_none, () {}), buildAction("Support", Icons.chat_bubble_outline, () {}), ], ), ); } Widget buildAction(String title, IconData iconData, Function onPressed) { return ListTile( onTap: onPressed, title: Text( title, style: TextStyle(color: Colors.black45), ), leading: Icon( iconData, color: Colors.black, ), ); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/widgets/location_map.dart
import 'package:flutter/material.dart'; class LocationMap extends StatefulWidget { @override _LocationMapState createState() => _LocationMapState(); } class _LocationMapState extends State<LocationMap> { @override Widget build(BuildContext context) { return Container(); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/widgets/taxi_booking_not_confirmed_widget.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_state.dart'; import 'package:taxi_app/models/taxi_booking.dart'; import 'package:taxi_app/models/taxi_driver.dart'; import 'package:taxi_app/widgets/rounded_button.dart'; import 'package:taxi_app/widgets/taxi_booking_cancellation_dialog.dart'; class TaxiBookingNotConfirmedWidget extends StatefulWidget { @override _TaxiBookingNotConfirmedWidgetState createState() => _TaxiBookingNotConfirmedWidgetState(); } class _TaxiBookingNotConfirmedWidgetState extends State<TaxiBookingNotConfirmedWidget> { TaxiBooking booking; TaxiDriver driver; @override void initState() { super.initState(); booking = (BlocProvider.of<TaxiBookingBloc>(context).state as TaxiNotConfirmedState) .booking; driver = (BlocProvider.of<TaxiBookingBloc>(context).state as TaxiNotConfirmedState) .driver; } @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.all(12.0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ Expanded( child: Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ buildDriver(), SizedBox( height: 12.0, ), buildPriceDetails(), SizedBox( height: 16.0, ), Row( children: <Widget>[ Icon( Icons.location_on, size: 22.0, ), SizedBox( width: 4.0, ), Expanded( child: Text( "Change Pickup Location", style: Theme.of(context).textTheme.subhead, )), Text( "Edit", style: Theme.of(context).textTheme.title, ) ], ), SizedBox( height: 24.0, ), SizedBox( height: 32.0, ), ], ), ), Row( children: <Widget>[ RoundedButton( onTap: () {}, iconData: Icons.call, ), SizedBox( width: 24.0, ), Expanded( flex: 2, child: RoundedButton( text: "Cancel Booking", onTap: () { showDialog( context: context, builder: (context) => TaxiBookingCancellationDialog()); }, ), ) ], ), ], ), ); } Widget buildDriver() { return Row( children: <Widget>[ ClipRRect( borderRadius: BorderRadius.circular(12.0), child: Image.network( "${driver.driverPic}", width: 48.0, height: 48.0, fit: BoxFit.cover, ), ), SizedBox( width: 16.0, ), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ Text( "${driver.driverName}", style: Theme.of(context).textTheme.title, ), SizedBox( height: 4.0, ), Text( "${driver.taxiDetails}", style: Theme.of(context).textTheme.subtitle, ) ], )), SizedBox( width: 8.0, ), Container( decoration: BoxDecoration( color: Color(0xffeeeeee).withOpacity(0.5), borderRadius: BorderRadius.circular(12.0)), padding: EdgeInsets.all(6.0), child: Row( mainAxisSize: MainAxisSize.min, children: <Widget>[ Icon( Icons.star, color: Colors.yellow, size: 20.0, ), Text( "${driver.driverRating}", style: Theme.of(context).textTheme.title, ), ], ), ) ], ); } Widget buildPriceDetails() { return Column( children: <Widget>[ Divider(), SizedBox( height: 14.0, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ buildIconText("21 km", Icons.directions), buildIconText("1-3", Icons.person_outline), buildIconText("\$150", Icons.monetization_on), ], ), SizedBox( height: 14.0, ), Divider() ], ); } Widget buildIconText(String text, IconData iconData) { return Row( children: <Widget>[ Icon( iconData, size: 22.0, color: Colors.black, ), Text( " $text", style: Theme.of(context).textTheme.title, ) ], ); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/widgets/loading_shimmer.dart
import 'package:flutter/material.dart'; import 'package:shimmer/shimmer.dart'; class LoadingShimmer extends StatelessWidget { @override Widget build(BuildContext context) { return Container( child: ListView.builder( shrinkWrap: true, itemBuilder: (context, index) => Shimmer.fromColors( baseColor: Color(0xffeeeeee), highlightColor: Colors.grey.withOpacity(0.3), child: Container( margin: EdgeInsets.symmetric(vertical: 8.0), padding: EdgeInsets.all(12.0), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Container( width: 75.0, height: 75.0, color: Color(0xffeeeeee), ), SizedBox( width: 12.0, ), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ Container( margin: EdgeInsets.only(right: 12.0), height: 18.0, color: Color(0xffeeeeee), ), SizedBox( height: 10.0, ), Container( margin: EdgeInsets.only(right: 24.0), height: 14.0, color: Color(0xffeeeeee), ), ], ), ) ], ), ), ), itemCount: 3, ), ); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/widgets/destination_selection_widget.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:taxi_app/bloc/taxi_booking_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_event.dart'; import 'package:taxi_app/controllers/user_location_controller.dart'; import 'package:taxi_app/models/user_location.dart'; import 'package:taxi_app/widgets/ease_in_widget.dart'; class DestinationSelctionWidget extends StatefulWidget { @override _DestinationSelctionWidgetState createState() => _DestinationSelctionWidgetState(); } class _DestinationSelctionWidgetState extends State<DestinationSelctionWidget> with TickerProviderStateMixin<DestinationSelctionWidget> { bool isLoading; List<UserLocation> savedLocations; AnimationController animationController; Animation animation; @override void initState() { super.initState(); isLoading = true; WidgetsBinding.instance.addPostFrameCallback((duration) { loadDestinations(); }); animationController = AnimationController(vsync: this, duration: Duration(milliseconds: 500)); animation = CurvedAnimation( curve: Curves.easeInExpo, parent: animationController, ); WidgetsBinding.instance.addPostFrameCallback((duration) { animationController.forward(); }); } Future<void> loadDestinations() async { setState(() { isLoading = true; }); savedLocations = await UserLocationController.getSavedLocations(); setState(() { isLoading = false; }); } @override Widget build(BuildContext context) { return isLoading ? Container() : AnimatedBuilder( animation: animation, builder: (context, child) { return Container( height: 150 * animation.value, child: child, ); }, child: Container( height: 150.0, color: Colors.transparent, child: ListView.builder( itemBuilder: (context, index) => SingleChildScrollView( child: index == 0 ? buildNewDestinationWidget() : buildDestinationWidget(savedLocations[index - 1]), ), shrinkWrap: true, itemCount: savedLocations.length + 1, scrollDirection: Axis.horizontal, ), ), ); } Widget buildDestinationWidget(UserLocation location) { return EaseInWidget( onTap: () { selectDestination(location.position); }, child: Container( alignment: Alignment.center, margin: EdgeInsets.all(12.0), padding: EdgeInsets.symmetric(vertical: 16.0, horizontal: 28.0), decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Colors.black12.withOpacity(0.05), blurRadius: 15.0, spreadRadius: 0.05), ], borderRadius: BorderRadius.circular(12.0)), child: Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ Container( decoration: BoxDecoration( color: Color(0xffeeeeee), shape: BoxShape.circle, ), padding: EdgeInsets.all(8.0), child: Icon( location.locationType == UserLocationType.Home ? Icons.home : Icons.work, size: 22.0, color: Colors.black54, ), ), SizedBox( height: 12.0, ), Text( "${location.locationType.toString().replaceFirst("UserLocationType.", "")}", style: Theme.of(context).textTheme.title, ), SizedBox( height: 4.0, ), Text( "${location.minutesFar} minutes", style: Theme.of(context) .textTheme .subtitle .copyWith(fontSize: 12.0), ) ], ), )); } Widget buildNewDestinationWidget() { return EaseInWidget( onTap: () { selectDestination(null); }, child: Container( alignment: Alignment.center, margin: EdgeInsets.all(12.0), padding: EdgeInsets.symmetric(vertical: 16.0, horizontal: 28.0), decoration: BoxDecoration( color: Colors.white, boxShadow: [ BoxShadow( color: Colors.black12.withOpacity(0.05), blurRadius: 15.0, spreadRadius: 0.05), ], borderRadius: BorderRadius.circular(12.0)), child: Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ Container( decoration: BoxDecoration( color: Colors.black, shape: BoxShape.circle, ), padding: EdgeInsets.all(8.0), child: Icon( Icons.my_location, size: 22.0, color: Colors.white, ), ), SizedBox( height: 12.0, ), Text( "New Ride", style: Theme.of(context).textTheme.title, ), SizedBox( height: 4.0, ), Text( "Select Dest.", style: Theme.of(context).textTheme.subtitle.copyWith(fontSize: 12.0), ) ], ), ), ); } void selectDestination(LatLng position) async { await animationController.reverse(from: 1.0); BlocProvider.of<TaxiBookingBloc>(context) .add(DestinationSelectedEvent(destination: position)); } @override void dispose() { animationController.dispose(); super.dispose(); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/widgets/taxi_booking_home_widget.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_state.dart'; import 'package:taxi_app/widgets/loading_shimmer.dart'; import 'package:taxi_app/widgets/taxi_booking_details_widget.dart'; import 'package:taxi_app/widgets/taxi_booking_not_confirmed_widget.dart'; import 'package:taxi_app/widgets/taxi_booking_payments_widget.dart'; import 'package:taxi_app/widgets/taxi_booking_state_widget.dart'; import 'package:taxi_app/widgets/taxi_booking_taxis_widget.dart'; class TaxiBookingHomeWidget extends StatefulWidget { @override _TaxiBookingHomeWidgetState createState() => _TaxiBookingHomeWidgetState(); } class _TaxiBookingHomeWidgetState extends State<TaxiBookingHomeWidget> with TickerProviderStateMixin<TaxiBookingHomeWidget> { AnimationController animationController; Animation animation; @override void initState() { super.initState(); print("Home Build "); animationController = AnimationController(vsync: this, duration: Duration(milliseconds: 200)); animation = CurvedAnimation( curve: Curves.easeIn, parent: animationController, ); WidgetsBinding.instance.addPostFrameCallback((duration) { animationController.forward(); }); } @override Widget build(BuildContext context) { double requiredHeight = MediaQuery.of(context).size.height * 2.5 / 3; return BlocListener<TaxiBookingBloc, TaxiBookingState>( listener: (context, state) async { if (state is TaxiBookingCancelledState) await animationController.reverse(from: 1.0); }, child: AnimatedBuilder( animation: animation, builder: (context, child) { return Container( height: requiredHeight * animation.value, child: child, ); }, child: SingleChildScrollView( child: Container( height: requiredHeight, child: Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(40.0), topRight: Radius.circular(40.0)), child: TaxiBookingStateWidget()), Expanded( child: Container( color: Colors.black, child: ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(36.0), topRight: Radius.circular(36.0)), child: Container( color: Colors.white, padding: EdgeInsets.all(16.0), height: MediaQuery.of(context).size.height * 1 / 1.6, margin: EdgeInsets.only(bottom: 24.0), child: BlocBuilder<TaxiBookingBloc, TaxiBookingState>( builder: (context, currentState) { switch (currentState.runtimeType) { case TaxiBookingLoadingState: return LoadingShimmer(); case DetailsNotFilledState: return TaxiBookingDetailsWidget(); case TaxiNotSelectedState: return TaxiBookingTaxisWidget(); case PaymentNotInitializedState: return TaxiBookingPaymentsWidget(); case TaxiNotConfirmedState: return TaxiBookingNotConfirmedWidget(); default: return Center( child: Text("Not Initialized"), ); } }, ), ), ), ), ) ], ), ), )), ); } @override void dispose() { animationController.dispose(); super.dispose(); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/widgets/dashed_line.dart
import 'package:flutter/material.dart'; class DashedLine extends StatelessWidget { final double height; final double dashWidth; final Color color; const DashedLine( {this.height = 1, this.color = Colors.black, this.dashWidth = 5.0}); @override Widget build(BuildContext context) { return LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { final boxWidth = constraints.constrainWidth(); final dashHeight = height; final dashCount = (boxWidth / (2 * dashWidth)).floor(); return Flex( children: List.generate(dashCount, (index) { return SizedBox( width: dashWidth, height: dashHeight, child: DecoratedBox( decoration: BoxDecoration(color: color), ), ); }), mainAxisAlignment: MainAxisAlignment.spaceAround, direction: Axis.horizontal, ); }, ); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/widgets/ease_in_widget.dart
import 'package:flutter/material.dart'; class EaseInWidget extends StatefulWidget { final Widget child; final Function onTap; const EaseInWidget({Key key,@required this.child,@required this.onTap}) : super(key: key); @override State<StatefulWidget> createState() => _EaseInWidgetState(); } class _EaseInWidgetState extends State<EaseInWidget> with TickerProviderStateMixin<EaseInWidget>{ AnimationController controller; Animation<double>easeInAnimation; @override void initState() { super.initState(); controller=AnimationController(vsync: this,duration: Duration(milliseconds: 200,),value: 1.0); easeInAnimation=Tween(begin:1.0,end:0.95).animate( CurvedAnimation(parent: controller, curve: Curves.easeIn,), ); controller.reverse(); } @override Widget build(BuildContext context) { return GestureDetector( onTap: (){ if(widget.onTap==null){ return ; } controller.forward().then((val){ controller.reverse().then((val){ widget.onTap(); }); }); }, child: ScaleTransition(scale: easeInAnimation,child: widget.child,), ); } @override void dispose() { controller.dispose(); super.dispose(); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/widgets/taxi_booking_state_widget.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_state.dart'; import 'package:taxi_app/widgets/dashed_line.dart'; import 'package:taxi_app/widgets/taxi_booking_cancellation_dialog.dart'; class TaxiBookingStateWidget extends StatelessWidget { @override Widget build(BuildContext context) { return BlocBuilder( bloc: BlocProvider.of<TaxiBookingBloc>(context), builder: (context, state) { int selectedTab = 1; TaxiBookingState currentState = state; String title = ""; if (state is TaxiBookingLoadingState) { currentState = state.state; } switch (currentState.runtimeType) { case DetailsNotFilledState: selectedTab = 1; title = "New Destination"; break; case TaxiNotSelectedState: selectedTab = 2; title = "Choose Ride"; break; case PaymentNotInitializedState: selectedTab = 3; title = "Payment Method"; break; case TaxiNotConfirmedState: selectedTab = 4; title = "Ride Info"; break; } return Container( color: Colors.black, padding: EdgeInsets.symmetric(vertical: 16.0, horizontal: 24.0), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( title, style: Theme.of(context).textTheme.title.copyWith( color: Colors.white, fontWeight: FontWeight.normal), ), IconButton( icon: Icon(Icons.clear), onPressed: () { showDialog( context: context, builder: (context) => TaxiBookingCancellationDialog()); }, color: Colors.white), ], ), SizedBox( height: 12.0, ), Row(children: [ buildTab(context, "1", selectedTab >= 1), Expanded( child: DashedLine( color: Colors.white.withOpacity(0.3), ), ), buildTab(context, "2", selectedTab >= 2), Expanded( child: DashedLine( color: Colors.white.withOpacity(0.3), ), ), buildTab(context, "3", selectedTab >= 3), Expanded( child: DashedLine( color: Colors.white.withOpacity(0.3), ), ), buildTab(context, "4", selectedTab >= 4), ]), SizedBox( height: 12.0, ) ], ), ); }, ); } Widget buildTab(BuildContext context, String val, bool enabled) { return Container( padding: EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0), decoration: BoxDecoration( color: enabled ? Colors.white : Colors.white.withOpacity(0.2), borderRadius: BorderRadius.circular(12.0)), child: Text( "$val", style: Theme.of(context).textTheme.headline.copyWith( color: enabled ? Colors.black : Colors.white, fontSize: 15), )); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/widgets/taxi_booking_payments_widget.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_event.dart'; import 'package:taxi_app/bloc/taxi_booking_state.dart'; import 'package:taxi_app/models/payment_method.dart'; import 'package:taxi_app/widgets/rounded_button.dart'; class TaxiBookingPaymentsWidget extends StatefulWidget { @override _TaxiBookingPaymentsWidgetState createState() => _TaxiBookingPaymentsWidgetState(); } class _TaxiBookingPaymentsWidgetState extends State<TaxiBookingPaymentsWidget> { List<PaymentMethod> methods = []; PaymentMethod selectedMethod; @override void initState() { super.initState(); methods = (BlocProvider.of<TaxiBookingBloc>(context).state as PaymentNotInitializedState) .methodsAvaiable; } @override Widget build(BuildContext context) { return Container( child: Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ Expanded( child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(12.0), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ Text( "Select Payment", style: Theme.of(context).textTheme.headline, ), ListView.separated( itemBuilder: (context, index) { return buildPaymentMethod(methods[index]); }, padding: EdgeInsets.symmetric(vertical: 24.0), separatorBuilder: (context, index) => Container( height: 18.0, ), physics: ClampingScrollPhysics(), shrinkWrap: true, itemCount: methods.length, ), Text( "Promo Code", style: Theme.of(context).textTheme.headline, ), SizedBox( height: 18.0, ), buildInputWidget(null, "Add promo code", () {}) ], ), ), ), ), Row( children: <Widget>[ RoundedButton( onTap: () { BlocProvider.of<TaxiBookingBloc>(context) .add(BackPressedEvent()); }, iconData: Icons.keyboard_backspace, ), SizedBox( width: 18.0, ), Expanded( flex: 2, child: RoundedButton( text: "Confirm Payment", onTap: () { BlocProvider.of<TaxiBookingBloc>(context) .add(PaymentMadeEvent(paymentMethod: selectedMethod)); }, ), ) ], ), ], ), ); } Widget buildPaymentMethod(PaymentMethod method) { return GestureDetector( onTap: () { setState(() { selectedMethod = method; }); }, child: Container( padding: EdgeInsets.all(12.0), decoration: BoxDecoration( color: Color(0xffeeeeee).withOpacity(0.5), borderRadius: BorderRadius.circular(12.0)), child: Row( children: <Widget>[ ClipRRect( borderRadius: BorderRadius.circular(16.0), child: Image.network( method.icon, width: 56.0, height: 56.0, fit: BoxFit.cover, ), ), SizedBox( width: 16.0, ), Expanded( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ Text( "${method.title}", style: Theme.of(context).textTheme.title, ), SizedBox( height: 4.0, ), Text( "${method.description}", style: Theme.of(context).textTheme.subtitle, ), ], ), ), selectedMethod == method ? Icon( Icons.check_circle, size: 28.0, ) : Container( width: 0, height: 0, ) ], ), ), ); } Widget buildInputWidget(String text, String hint, Function() onTap) { return Container( padding: EdgeInsets.symmetric(vertical: 24.0, horizontal: 16.0), decoration: BoxDecoration( color: Color(0xffeeeeee).withOpacity(0.5), borderRadius: BorderRadius.circular(12.0), ), child: Text( text ?? hint, style: Theme.of(context) .textTheme .title .copyWith(color: text == null ? Colors.black45 : Colors.black), maxLines: 1, overflow: TextOverflow.ellipsis, ), ); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/models/user_location.dart
import 'package:google_maps_flutter/google_maps_flutter.dart'; enum UserLocationType { Home, Office } class UserLocation { final String name; final UserLocationType locationType; final LatLng position; final int minutesFar; UserLocation(this.name, this.locationType, this.position, this.minutesFar); UserLocation.named({ this.name, this.locationType, this.position, this.minutesFar, }); }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/models/google_location.dart
import 'package:google_maps_flutter/google_maps_flutter.dart'; class GoogleLocation { final String placeId; final LatLng position; final String areaDetails; GoogleLocation(this.placeId, this.position, this.areaDetails); GoogleLocation.named({this.placeId, this.position, this.areaDetails}); }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/models/payment_method.dart
import 'package:equatable/equatable.dart'; import 'package:flutter/foundation.dart'; class PaymentMethod extends Equatable { final String id; final String title; final String icon; final String description; PaymentMethod( {@required this.id, @required this.title, @required this.icon, @required this.description}); @override List<Object> get props => [id, title, icon, description]; }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/models/taxi.dart
import 'package:equatable/equatable.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:taxi_app/models/taxi_type.dart'; class Taxi extends Equatable { final String id; final String title; final bool isAvailable; final String plateNo; final TaxiType taxiType; final LatLng position; Taxi(this.id, this.title, this.isAvailable, this.plateNo, this.taxiType, this.position); Taxi.named({ this.id, this.title, this.isAvailable, this.plateNo, this.taxiType, this.position, }); @override List<Object> get props => [title, isAvailable, plateNo, taxiType]; }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/models/taxi_type.dart
enum TaxiType { Standard, Premium, Platinum }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/models/taxi_driver.dart
import 'package:equatable/equatable.dart'; class TaxiDriver extends Equatable { final String id; final String driverName; final double driverRating; final String taxiDetails; final String driverPic; TaxiDriver(this.id, this.driverName, this.driverPic, this.driverRating, this.taxiDetails); TaxiDriver.named( {this.id, this.driverName, this.driverPic, this.driverRating, this.taxiDetails}); @override List<Object> get props => [id, driverName, driverPic, driverRating, taxiDetails]; }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/models/taxi_booking.dart
import 'package:taxi_app/models/payment_method.dart'; import 'google_location.dart'; import 'taxi_type.dart'; class TaxiBooking { final String id; final GoogleLocation source; final GoogleLocation destination; final int noOfPersons; final DateTime bookingTime; final TaxiType taxiType; final double estimatedPrice; final PaymentMethod paymentMethod; final String promoApplied; TaxiBooking( this.id, this.source, this.destination, this.noOfPersons, this.bookingTime, this.taxiType, this.estimatedPrice, this.paymentMethod, this.promoApplied); TaxiBooking.named({ this.id, this.source, this.destination, this.noOfPersons, this.bookingTime, this.taxiType, this.estimatedPrice, this.paymentMethod, this.promoApplied, }); TaxiBooking copyWith(TaxiBooking booking) { return TaxiBooking.named( id: booking.id ?? id, source: booking.source ?? source, destination: booking.destination ?? destination, noOfPersons: booking.noOfPersons ?? noOfPersons, bookingTime: booking.bookingTime ?? bookingTime, paymentMethod: booking.paymentMethod ?? paymentMethod, promoApplied: booking.promoApplied ?? promoApplied, estimatedPrice: booking.estimatedPrice ?? estimatedPrice, taxiType: booking.taxiType ?? taxiType); } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/models/user.dart
class User { final String name; final String mobileNumber; final String photoUrl; User({this.name, this.mobileNumber, this.photoUrl}); }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/bloc/taxi_booking_state.dart
import 'package:equatable/equatable.dart'; import 'package:flutter/foundation.dart'; import 'package:taxi_app/models/payment_method.dart'; import 'package:taxi_app/models/taxi.dart'; import 'package:taxi_app/models/taxi_booking.dart'; import 'package:taxi_app/models/taxi_driver.dart'; abstract class TaxiBookingState extends Equatable { TaxiBookingState(); } class TaxiBookingNotInitializedState extends TaxiBookingState { TaxiBookingNotInitializedState(); @override List<Object> get props => null; } class TaxiBookingNotSelectedState extends TaxiBookingState { final List<Taxi> taxisAvailable; TaxiBookingNotSelectedState({@required this.taxisAvailable}); @override List<Object> get props => null; } class DetailsNotFilledState extends TaxiBookingState { final TaxiBooking booking; DetailsNotFilledState({@required this.booking}); @override List<Object> get props => [booking]; } class TaxiNotSelectedState extends TaxiBookingState { final TaxiBooking booking; TaxiNotSelectedState({@required this.booking}); @override List<Object> get props => [booking]; } class PaymentNotInitializedState extends TaxiBookingState { final TaxiBooking booking; final List<PaymentMethod> methodsAvaiable; PaymentNotInitializedState({ @required this.booking, @required this.methodsAvaiable, }); @override List<Object> get props => [booking]; } class TaxiNotConfirmedState extends TaxiBookingState { final TaxiDriver driver; final TaxiBooking booking; TaxiNotConfirmedState({@required this.driver, @required this.booking}); @override List<Object> get props => [driver, booking]; } class TaxiConfirmedState extends TaxiBookingState { final TaxiDriver driver; final TaxiBooking booking; TaxiConfirmedState({@required this.driver, @required this.booking}); @override List<Object> get props => [driver, booking]; } class TaxiBookingCancelledState extends TaxiBookingState { @override List<Object> get props => null; } class TaxiBookingLoadingState extends TaxiBookingState { final TaxiBookingState state; TaxiBookingLoadingState({@required this.state}); @override List<Object> get props => [state]; } class TaxiBookingConfirmedState extends TaxiBookingState { final TaxiDriver driver; final TaxiBooking booking; TaxiBookingConfirmedState({@required this.driver, @required this.booking}); @override List<Object> get props => [driver]; }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/bloc/taxi_booking_event.dart
import 'package:equatable/equatable.dart'; import 'package:flutter/cupertino.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:taxi_app/models/google_location.dart'; import 'package:taxi_app/models/payment_method.dart'; import 'package:taxi_app/models/taxi_type.dart'; abstract class TaxiBookingEvent extends Equatable { TaxiBookingEvent(); } class TaxiBookingStartEvent extends TaxiBookingEvent { @override List<Object> get props => null; } class DestinationSelectedEvent extends TaxiBookingEvent { final LatLng destination; DestinationSelectedEvent({@required this.destination}); @override List<Object> get props => [destination]; } class DetailsSubmittedEvent extends TaxiBookingEvent { final GoogleLocation source; final GoogleLocation destination; final int noOfPersons; final DateTime bookingTime; DetailsSubmittedEvent( {@required this.source, @required this.destination, @required this.noOfPersons, @required this.bookingTime}); @override List<Object> get props => [source, destination, noOfPersons, bookingTime]; } class TaxiSelectedEvent extends TaxiBookingEvent { final TaxiType taxiType; TaxiSelectedEvent({@required this.taxiType}); @override List<Object> get props => [taxiType]; } class PaymentMadeEvent extends TaxiBookingEvent { final PaymentMethod paymentMethod; PaymentMadeEvent({@required this.paymentMethod}); @override List<Object> get props => [paymentMethod]; } class BackPressedEvent extends TaxiBookingEvent { @override List<Object> get props => null; } class TaxiBookingCancelEvent extends TaxiBookingEvent { @override List<Object> get props => null; }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/bloc/taxi_booking_bloc.dart
import 'package:bloc/bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_event.dart'; import 'package:taxi_app/bloc/taxi_booking_state.dart'; import 'package:taxi_app/controllers/location_controller.dart'; import 'package:taxi_app/controllers/payment_method_controller.dart'; import 'package:taxi_app/controllers/taxi_booking_controller.dart'; import 'package:taxi_app/models/google_location.dart'; import 'package:taxi_app/models/payment_method.dart'; import 'package:taxi_app/models/taxi.dart'; import 'package:taxi_app/models/taxi_booking.dart'; import 'package:taxi_app/models/taxi_driver.dart'; import 'package:taxi_app/storage/taxi_booking_storage.dart'; class TaxiBookingBloc extends Bloc<TaxiBookingEvent, TaxiBookingState> { @override TaxiBookingState get initialState => TaxiBookingNotInitializedState(); @override Stream<TaxiBookingState> mapEventToState(TaxiBookingEvent event) async* { if (event is TaxiBookingStartEvent) { List<Taxi> taxis = await TaxiBookingController.getTaxisAvailable(); yield TaxiBookingNotSelectedState(taxisAvailable: taxis); } if (event is DestinationSelectedEvent) { TaxiBookingStorage.open(); yield TaxiBookingLoadingState( state: DetailsNotFilledState(booking: null)); GoogleLocation source = await LocationController.getCurrentLocation(); GoogleLocation destination = await LocationController.getLocationfromId(event.destination); await TaxiBookingStorage.addDetails(TaxiBooking.named( source: source, destination: destination, noOfPersons: 1)); TaxiBooking taxiBooking = await TaxiBookingStorage.getTaxiBooking(); yield DetailsNotFilledState(booking: taxiBooking); } if (event is DetailsSubmittedEvent) { yield TaxiBookingLoadingState(state: TaxiNotSelectedState(booking: null)); await Future.delayed(Duration(seconds: 1)); await TaxiBookingStorage.addDetails(TaxiBooking.named( source: event.source, destination: event.destination, noOfPersons: event.noOfPersons, bookingTime: event.bookingTime, )); TaxiBooking booking = await TaxiBookingStorage.getTaxiBooking(); yield TaxiNotSelectedState( booking: booking, ); } if (event is TaxiSelectedEvent) { yield TaxiBookingLoadingState( state: PaymentNotInitializedState(booking: null, methodsAvaiable: [])); TaxiBooking prevBooking = await TaxiBookingStorage.getTaxiBooking(); double price = await TaxiBookingController.getPrice(prevBooking); await TaxiBookingStorage.addDetails( TaxiBooking.named(taxiType: event.taxiType, estimatedPrice: price)); TaxiBooking booking = await TaxiBookingStorage.getTaxiBooking(); List<PaymentMethod> methods = await PaymentMethodController.getMethods(); yield PaymentNotInitializedState( booking: booking, methodsAvaiable: methods); } if (event is PaymentMadeEvent) { yield TaxiBookingLoadingState( state: PaymentNotInitializedState(booking: null, methodsAvaiable: null)); TaxiBooking booking = await TaxiBookingStorage.addDetails( TaxiBooking.named(paymentMethod: event.paymentMethod)); TaxiDriver taxiDriver = await TaxiBookingController.getTaxiDriver(booking); yield TaxiNotConfirmedState(booking: booking, driver: taxiDriver); await Future.delayed(Duration(seconds: 1)); yield TaxiBookingConfirmedState(booking: booking, driver: taxiDriver); } if (event is TaxiBookingCancelEvent) { yield TaxiBookingCancelledState(); await Future.delayed(Duration(milliseconds: 500)); List<Taxi> taxis = await TaxiBookingController.getTaxisAvailable(); yield TaxiBookingNotSelectedState(taxisAvailable: taxis); } if (event is BackPressedEvent) { switch (state.runtimeType) { case DetailsNotFilledState: List<Taxi> taxis = await TaxiBookingController.getTaxisAvailable(); yield TaxiBookingNotSelectedState(taxisAvailable: taxis); break; case PaymentNotInitializedState: yield TaxiNotSelectedState( booking: (state as PaymentNotInitializedState).booking); break; case TaxiNotSelectedState: yield DetailsNotFilledState( booking: (state as TaxiNotSelectedState).booking); break; } } } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/storage/taxi_booking_storage.dart
import 'package:taxi_app/models/taxi_booking.dart'; class TaxiBookingStorage { static TaxiBooking _taxiBooking; static Future<void> open() async { _taxiBooking = TaxiBooking.named(); } static Future<TaxiBooking> addDetails(TaxiBooking taxiBooking) async { _taxiBooking = _taxiBooking.copyWith(taxiBooking); return _taxiBooking; } static Future<TaxiBooking> getTaxiBooking() async { return _taxiBooking; } }
0
mirrored_repositories/Taxi-App/lib
mirrored_repositories/Taxi-App/lib/screens/home_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_bloc.dart'; import 'package:taxi_app/bloc/taxi_booking_event.dart'; import 'package:taxi_app/bloc/taxi_booking_state.dart'; import 'package:taxi_app/widgets/destination_selection_widget.dart'; import 'package:taxi_app/widgets/home_app_bar.dart'; import 'package:taxi_app/widgets/home_drawer.dart'; import 'package:taxi_app/widgets/taxi_booking_confirmed_widget.dart'; import 'package:taxi_app/widgets/taxi_booking_home_widget.dart'; import 'package:taxi_app/widgets/taxi_map.dart'; class HomeScreen extends StatefulWidget { @override _HomeScreenState createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> { @override void initState() { super.initState(); SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light .copyWith(statusBarColor: Colors.transparent)); } @override Widget build(BuildContext context) { return WillPopScope( onWillPop: () async { BlocProvider.of<TaxiBookingBloc>(context).add(BackPressedEvent()); return false; }, child: AnnotatedRegion<SystemUiOverlayStyle>( value: SystemUiOverlayStyle.dark, child: Scaffold( endDrawer: HomeDrawer(), body: Stack( children: <Widget>[TaxiMap(), HomeAppBar()], ), bottomSheet: BlocBuilder<TaxiBookingBloc, TaxiBookingState>( builder: (BuildContext context, TaxiBookingState state) { if (state is TaxiBookingNotInitializedState) { return Container(); } if (state is TaxiBookingNotSelectedState) { return DestinationSelctionWidget(); } if (state is TaxiBookingConfirmedState) { return TaxiBookingConfirmedWidget(); } return TaxiBookingHomeWidget(); }), ), ), ); } }
0
mirrored_repositories/Taxi-App
mirrored_repositories/Taxi-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 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:taxi_app/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/Ubuntu-Launcher
mirrored_repositories/Ubuntu-Launcher/lib/main.dart
import 'package:flutter/material.dart'; import 'package:launcher/src/app.dart'; void main() { runApp(MyApp()); }
0
mirrored_repositories/Ubuntu-Launcher/lib
mirrored_repositories/Ubuntu-Launcher/lib/src/app.dart
import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:launcher/src/blocs/apps_cubit.dart'; import 'package:launcher/src/config/routes/app_routes.dart'; import 'package:launcher/src/config/themes/cubit/opacity_cubit.dart'; import 'package:launcher/src/data/apps_api_provider.dart'; import './config/routes/app_routes.dart'; class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MultiBlocProvider( providers: [ BlocProvider( create: (context) => AppsCubit(appsApiProvider: AppsApiProvider())..loadApps(), ), BlocProvider<OpacityCubit>(create: (context) => OpacityCubit()), ], child: MaterialApp( showPerformanceOverlay: false, debugShowCheckedModeBanner: false, theme: ThemeData( primaryColor: Colors.pink, accentColor: Colors.white, visualDensity: VisualDensity.adaptivePlatformDensity, canvasColor: Colors.transparent), darkTheme: ThemeData( // New brightness: Brightness.light, // New ), title: "Ubuntu Launcher", onGenerateRoute: AppRoutes.onGenerateRoute, )); } }
0
mirrored_repositories/Ubuntu-Launcher/lib/src
mirrored_repositories/Ubuntu-Launcher/lib/src/blocs/apps_state.dart
part of 'apps_cubit.dart'; @immutable abstract class AppsState extends Equatable { const AppsState(); @override List<Object> get props => []; } class AppsInitiateState extends AppsState { const AppsInitiateState(); @override List<Object> get props => []; } class AppsLoading extends AppsState { const AppsLoading(); @override List<Object> get props => []; } class AppsLoaded extends AppsState { final List<Application> apps; final ShortcutAppsModel shortcutAppsModel; final String sortType; AppsLoaded( {@required this.apps, @required this.sortType, @required this.shortcutAppsModel}); @override List<Object> get props => [shortcutAppsModel, apps, sortType]; } class AppsError extends AppsState { const AppsError(this.errorMessage); final String errorMessage; @override List<Object> get props => [errorMessage]; }
0
mirrored_repositories/Ubuntu-Launcher/lib/src
mirrored_repositories/Ubuntu-Launcher/lib/src/blocs/apps_cubit.dart
import 'package:bloc/bloc.dart'; import 'package:device_apps/device_apps.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:launcher/src/config/constants/enums.dart'; import 'package:launcher/src/data/apps_api_provider.dart'; import 'package:launcher/src/data/models/shortcut_app_model.dart'; import 'package:launcher/src/helpers/utilities/local_storage.dart'; import 'package:logger/logger.dart'; part 'apps_state.dart'; class AppsCubit extends Cubit<AppsState> { final AppsApiProvider appsApiProvider; AppsCubit({@required this.appsApiProvider}) : super(AppsInitiateState()) { listenApps(); } Future<void> loadApps() async { if (state is! AppsLoaded) emit(AppsLoading()); try { List<Application> apps = await appsApiProvider.fetchAppList(); String sortType = await LocalStorage.getSortType() ?? getCurrentPayloads( appsStatePayloadTypes: AppsStatePayloadTypes.SORT_TYPE) ?? SortTypes.Alphabetically.name; apps = getAppsSorted(appsToSort: apps, sortType: sortType); final ShortcutAppsModel shortcutApps = getCurrentPayloads( appsStatePayloadTypes: AppsStatePayloadTypes.SHORTCUT_APPS) ?? await getShortcutApps(apps); emit(AppsLoaded( shortcutAppsModel: shortcutApps, apps: apps, sortType: sortType ?? SortTypes.Alphabetically.name)); } catch (error) { Logger().w(error); emit(AppsError(error.toString())); } } void updateApps(List<Application> apps) { final shortcutApps = getCurrentPayloads( appsStatePayloadTypes: AppsStatePayloadTypes.SHORTCUT_APPS); final sortType = getCurrentPayloads( appsStatePayloadTypes: AppsStatePayloadTypes.SORT_TYPE); emit(AppsLoading()); emit(AppsLoaded( apps: apps, sortType: sortType, shortcutAppsModel: shortcutApps)); } Future<void> updateSortType(String sortType) async { LocalStorage.setSortType(sortType); final apps = getAppsSorted(sortType: sortType); emit(AppsLoaded( apps: apps, sortType: sortType, shortcutAppsModel: getCurrentPayloads( appsStatePayloadTypes: AppsStatePayloadTypes.SHORTCUT_APPS))); } dynamic getCurrentPayloads({AppsStatePayloadTypes appsStatePayloadTypes}) { if (state is AppsLoaded) { final appState = state as AppsLoaded; return appsStatePayloadTypes == AppsStatePayloadTypes.APPS ? appState.apps : appsStatePayloadTypes == AppsStatePayloadTypes.SHORTCUT_APPS ? appState.shortcutAppsModel : appsStatePayloadTypes == AppsStatePayloadTypes.SORT_TYPE ? appState.sortType : { appState.apps, appState.shortcutAppsModel, appState.sortType }; } else return null; } Future<ShortcutAppsModel> getShortcutApps(List<Application> apps) async { String settings, camera, sms, phone; try { final isNewUser = await LocalStorage.isUserNew(); if (!isNewUser) { final shortcutApps = await LocalStorage.getShortcutApps(); return shortcutApps; } else { for (int i = 0; i < apps.length; i++) { Application app = apps[i]; if (app.appName == "Settings") { settings = apps[i].packageName; } else if (app.appName.toLowerCase().contains("camera")) { camera = apps[i].packageName; } else if (app.appName.toLowerCase().contains("message") || app.appName.toLowerCase().contains("messaging") || app.appName.toLowerCase().contains("sms") || app.appName.toLowerCase().contains("messenger")) { sms = apps[i].packageName; } else if (app.appName.toLowerCase().contains("phone") || app.appName.toLowerCase().contains("call") || app.appName.toLowerCase().contains("dial")) { phone = apps[i].packageName; } } final shortcutApps = new ShortcutAppsModel( phone: phone, camera: camera, setting: settings, message: sms); if (shortcutApps.phone != null && shortcutApps.camera != null && shortcutApps.setting != null && shortcutApps.message != null) { LocalStorage.setShortcutApps(shortcutApps); LocalStorage.setUserNew(); } return shortcutApps; } } catch (error) { Logger().w(error); } } void updateShortcutApps(ShortcutAppsModel shortcutApps) { try { if (shortcutApps.phone != null && shortcutApps.camera != null && shortcutApps.setting != null && shortcutApps.message != null) { LocalStorage.setShortcutApps(shortcutApps); LocalStorage.setUserNew(); } } catch (error) { Logger().w(error); } final apps = getCurrentPayloads(appsStatePayloadTypes: AppsStatePayloadTypes.APPS); final sortType = getCurrentPayloads( appsStatePayloadTypes: AppsStatePayloadTypes.SORT_TYPE); emit(AppsLoading()); emit(AppsLoaded( apps: apps, sortType: sortType, shortcutAppsModel: shortcutApps)); } Future<void> listenApps() async { try { Stream<ApplicationEvent> appsEvent = DeviceApps.listenToAppsChanges(); appsEvent.listen((event) async { if (state is AppsLoaded) { final appState = state as AppsLoaded; final apps = appState.apps; Logger().wtf(event); if (event.event == ApplicationEventType.disabled) { final applicationEventType = event as ApplicationEventDisabled; Application app = await DeviceApps.getApp(applicationEventType.packageName); apps.add(app); loadApps(); Logger() .w("${applicationEventType.application.appName} is enabled"); } else if (event.event == ApplicationEventType.enabled) { apps.removeWhere( (element) => element.packageName == event.packageName); Logger().w("${event.packageName} is disabled"); } else if (event.event == ApplicationEventType.uninstalled) { final applicationEventType = event as ApplicationEventUninstalled; apps.removeWhere((element) => element.packageName == applicationEventType.packageName); Logger().w("${applicationEventType.packageName} is uninstalled"); } else if (event.event == ApplicationEventType.installed) { final applicationEventType = event as ApplicationEventInstalled; Application app = await DeviceApps.getApp(applicationEventType.packageName); apps.add(app); loadApps(); Logger().w("${applicationEventType.application} is installed"); } updateApps(apps); } }); } catch (errorMessage) { Logger().w(errorMessage); emit(AppsError(errorMessage.toString())); } } List<Application> getAppsSorted( {List<Application> appsToSort, String sortType}) { List<Application> apps = appsToSort ?? getCurrentPayloads(appsStatePayloadTypes: AppsStatePayloadTypes.APPS) ?? []; if (sortType == null || sortType == SortTypes.Alphabetically.name) { apps.sort( (a, b) => a.appName.toLowerCase().compareTo(b.appName.toLowerCase())); } else if (sortType == SortTypes.InstallationTime.name) { apps.sort((b, a) => a.installTimeMillis.compareTo(b.installTimeMillis)); } else if (sortType == SortTypes.UpdateTime.name) { apps.sort((b, a) => a.updateTimeMillis.compareTo(b.updateTimeMillis)); } return apps; } }
0
mirrored_repositories/Ubuntu-Launcher/lib/src/config
mirrored_repositories/Ubuntu-Launcher/lib/src/config/constants/enums.dart
enum SortTypes { Alphabetically, InstallationTime, UpdateTime } enum ShortcutAppTypes { PHONE, MESSAGE, CAMERA, SETTINGS } enum AppsStatePayloadTypes { APPS, SHORTCUT_APPS, SORT_TYPE }
0
mirrored_repositories/Ubuntu-Launcher/lib/src/config
mirrored_repositories/Ubuntu-Launcher/lib/src/config/constants/size.dart
import 'dart:ui'; final double pixelRatio = window.devicePixelRatio; final double physicalHeight = window.physicalSize.height; final double physicalWidth = window.physicalSize.width; final double deviceHeight = physicalHeight / pixelRatio; final double deviceWidth = physicalWidth / pixelRatio; final double titleSize = 0.035 * deviceHeight; final double subTitleSize = 0.032 * deviceHeight; final double mediumTextSize = 0.030 * deviceHeight; final double normalTextSize = 0.025 * deviceHeight; final double smallTextSize = 0.02 * deviceHeight; final double extraSmallTextSize = 0.018 * deviceHeight; final double buttonSize = 0.02 * deviceHeight; final double iconSize = 0.030 * deviceHeight; final double toggleSize = 0.035 * deviceHeight; final double textFieldSpace = 0.015 * deviceHeight;
0
mirrored_repositories/Ubuntu-Launcher/lib/src/config
mirrored_repositories/Ubuntu-Launcher/lib/src/config/constants/colors.dart
import 'package:flutter/material.dart'; final MaterialColor defaultColor = Colors.blue; final MaterialColor dangerColor = Colors.red; final MaterialColor warningColor = Colors.yellow; final MaterialColor successColor = Colors.green; final MaterialColor primaryColor = Colors.blue;
0
mirrored_repositories/Ubuntu-Launcher/lib/src/config
mirrored_repositories/Ubuntu-Launcher/lib/src/config/routes/app_routes.dart
import 'package:flutter/material.dart'; import 'package:launcher/src/core/modules/404/views/404_page.dart'; import 'package:launcher/src/core/modules/apps/views/views.dart'; import 'package:launcher/src/core/modules/home/views/views.dart'; import 'package:launcher/src/helpers/utilities/routeAnimator.dart'; class AppRoutes { static Route<dynamic> onGenerateRoute(RouteSettings settings) { switch (settings.name) { case Home.route: return MaterialPageRoute(builder: (_) => Home()); case AppDrawer.route: return RouteAnimator.createRoute(AppDrawer()); default: return MaterialPageRoute( builder: (_) => Page404(errorMessage: "Could not find route ${settings.name}")); } } }
0
mirrored_repositories/Ubuntu-Launcher/lib/src/config
mirrored_repositories/Ubuntu-Launcher/lib/src/config/routes/routes.dart
export './app_routes.dart';
0
mirrored_repositories/Ubuntu-Launcher/lib/src/config/themes
mirrored_repositories/Ubuntu-Launcher/lib/src/config/themes/cubit/opacity_state.dart
part of 'opacity_cubit.dart'; abstract class OpacityState extends Equatable { const OpacityState(); @override List<Object> get props => []; } class OpacityInitial extends OpacityState {} class OpacitySemi extends OpacityState {}
0
mirrored_repositories/Ubuntu-Launcher/lib/src/config/themes
mirrored_repositories/Ubuntu-Launcher/lib/src/config/themes/cubit/opacity_cubit.dart
import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; part 'opacity_state.dart'; class OpacityCubit extends Cubit<OpacityState> { OpacityCubit() : super(OpacityInitial()); void setOpacitySemi() => emit(OpacitySemi()); void opacityReset() => emit(OpacityInitial()); }
0
mirrored_repositories/Ubuntu-Launcher/lib/src
mirrored_repositories/Ubuntu-Launcher/lib/src/data/apps_api_provider.dart
import 'package:device_apps/device_apps.dart'; class AppsApiProvider { Future<List<Application>> fetchAppList() async { List<Application> apps = await DeviceApps.getInstalledApplications( includeAppIcons: true, includeSystemApps: true, onlyAppsWithLaunchIntent: true); return apps; } }
0
mirrored_repositories/Ubuntu-Launcher/lib/src/data
mirrored_repositories/Ubuntu-Launcher/lib/src/data/models/shortcut_app_model.dart
import 'package:device_apps/device_apps.dart'; class ShortcutAppsModel { String phone; String message; String camera; String setting; ShortcutAppsModel({this.phone, this.camera, this.message, this.setting}); Map<String, dynamic> toJson() { final Map<String, dynamic> data = new Map<String, dynamic>(); data['phone'] = this.phone; data['message'] = this.message; data['camera'] = this.camera; data['setting'] = this.setting; return data; } }
0
mirrored_repositories/Ubuntu-Launcher/lib/src/core/modules/apps
mirrored_repositories/Ubuntu-Launcher/lib/src/core/modules/apps/views/views.dart
export './app_drawer.dart';
0
mirrored_repositories/Ubuntu-Launcher/lib/src/core/modules/apps
mirrored_repositories/Ubuntu-Launcher/lib/src/core/modules/apps/views/app_drawer.dart
import 'package:device_apps/device_apps.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:launcher/src/config/constants/size.dart'; import 'package:launcher/src/config/themes/cubit/opacity_cubit.dart'; import 'package:launcher/src/helpers/widgets/error_message.dart'; import 'package:logger/logger.dart'; import 'package:launcher/src/config/constants/enums.dart'; import 'package:launcher/src/blocs/apps_cubit.dart'; import 'package:autocomplete_textfield/autocomplete_textfield.dart'; class AppDrawer extends StatelessWidget { static const route = '/app-drawer'; TextEditingController _searchController; GlobalKey<AutoCompleteTextFieldState<String>> _autoCompeleteTextFieldkey = new GlobalKey(); List<String> sortTypes = [ SortTypes.Alphabetically.toString().split('.').last, SortTypes.InstallationTime.toString().split('.').last, SortTypes.UpdateTime.toString().split('.').last, ]; final ratio = 1.1 * 411.42857142857144 / deviceWidth; @override Widget build(BuildContext context) { final appsCubit = BlocProvider.of<AppsCubit>(context); final opacityCubit = BlocProvider.of<OpacityCubit>(context); return WillPopScope( onWillPop: () async => true, child: Focus( onFocusChange: (isFocusChanged) { if (isFocusChanged) { opacityCubit.setOpacitySemi(); appsCubit.loadApps(); } }, child: Scaffold( backgroundColor: Colors.transparent, appBar: PreferredSize( preferredSize: Size.fromHeight(100.0), child: SafeArea( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Expanded( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ GestureDetector( onTap: () { // opacityCubit.opacityReset(); Navigator.pop(context); }, child: Container( padding: const EdgeInsets.all(5), child: Hero( tag: 'drawer', child: Image.asset( "assets/images/drawer.png", fit: BoxFit.cover, ), ), ), ), DropdownButton<String>( // value: sortType, icon: Icon( Icons.sort, color: Colors.white, ), iconSize: 40, elevation: 16, focusColor: Colors.green, style: TextStyle(color: Colors.black), underline: Container( color: Colors.transparent, child: Text(""), ), onChanged: (sortType) { appsCubit.updateSortType(sortType); }, items: sortTypes .map<DropdownMenuItem<String>>((String value) { return DropdownMenuItem<String>( value: value, child: Card( child: Container( alignment: Alignment.center, padding: const EdgeInsets.all(5), child: Text( value, style: TextStyle(color: Colors.black), ), ), ), ); }).toList(), ) ], ), ), Flexible( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 10), child: BlocBuilder<AppsCubit, AppsState>( builder: (context, appState) { if (appState is AppsLoaded) { return Container( padding: const EdgeInsets.symmetric( horizontal: 20), decoration: BoxDecoration( color: Colors.white30, borderRadius: BorderRadius.circular(15), ), child: SimpleAutoCompleteTextField( suggestionsAmount: appState.apps.length, style: TextStyle( letterSpacing: 1.2, color: Colors.white, fontSize: normalTextSize), controller: _searchController, key: _autoCompeleteTextFieldkey, suggestions: appState.apps .map((app) => app.appName) .toList(), textSubmitted: (appName) { for (int i = 0; i < appState.apps.length; i++) { if (appState.apps[i].appName .toString() == appName) { DeviceApps.openApp( appState.apps[i].packageName); break; } } }, clearOnSubmit: true, keyboardType: TextInputType.text, decoration: InputDecoration( contentPadding: const EdgeInsets.all(10), border: InputBorder.none, suffixIcon: Icon( Icons.search_sharp, color: Colors.grey, ), fillColor: Colors.white, focusColor: Colors.white, hintStyle: TextStyle( fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, color: Colors.grey, fontSize: smallTextSize), hintText: ' Type to search applications', ), )); } else return Container(); }, )), ), ], ), ), ), body: RefreshIndicator( color: Colors.white, onRefresh: () => appsCubit.loadApps(), child: Container( padding: const EdgeInsets.only(left: 50), child: BlocBuilder<AppsCubit, AppsState>( builder: (context, state) { if (state is AppsLoading) { return Center( child: Container( height: 50, width: 50, color: Colors.transparent, child: Image.asset( "assets/images/loader2.gif", fit: BoxFit.cover, ), ), ); } else if (state is AppsLoaded) { return StaggeredGridView.countBuilder( crossAxisCount: ((4 * deviceWidth) / 432).round(), itemCount: state.apps.length, itemBuilder: (BuildContext context, int i) { Application app = state.apps[i]; return GestureDetector( onTap: () { try { DeviceApps.openApp(app.packageName); } catch (error) { Logger().w(error); ErrorMessage( context: context, error: error.toString()) .display(); } Navigator.pop(context); }, onLongPress: () async { try { Navigator.pop(context); // if (LocalPlatform().isAndroid) { // final AndroidIntent intent = AndroidIntent( // action: // 'action_application_details_settings', // data: 'package:' + // app.packageName, // replace com.example.app with your applicationId // ); // await intent.launch(); // } DeviceApps.openAppSettings(app.packageName); } catch (error) { Logger().w(error); ErrorMessage(context: context, error: error) .display(); } }, child: GridTile( child: Padding( padding: const EdgeInsets.all(10.0), child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ app is ApplicationWithIcon ? Container( child: CircleAvatar( backgroundImage: MemoryImage( app.icon, ), backgroundColor: Colors.white, ), ) : Container( child: CircleAvatar( backgroundImage: AssetImage( "assets/images/no_image.png"), backgroundColor: Colors.white, ), ), SizedBox( height: 5, ), Expanded( child: Text( app.appName, textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: smallTextSize), overflow: ratio < 1.2 ? TextOverflow.clip : TextOverflow.ellipsis, ), ), ], ), ), )); }, staggeredTileBuilder: (int index) => new StaggeredTile.count(1, ratio < 1.2 ? ratio : 1.0), ); } else return Center( child: Column( children: [ RefreshProgressIndicator(), Text( "Something Went Wrong", style: TextStyle(color: Colors.white, fontSize: 20.0), ) ], ), ); }, ), ), ), ), ), ); } }
0
mirrored_repositories/Ubuntu-Launcher/lib/src/core/modules/home
mirrored_repositories/Ubuntu-Launcher/lib/src/core/modules/home/views/home_page.dart
import 'dart:io'; import 'package:device_apps/device_apps.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:image_picker/image_picker.dart'; import 'package:launcher/src/blocs/apps_cubit.dart'; import 'package:launcher/src/config/constants/colors.dart'; import 'package:launcher/src/config/constants/enums.dart'; import 'package:launcher/src/config/constants/size.dart'; import 'package:launcher/src/config/themes/cubit/opacity_cubit.dart'; import 'package:launcher/src/core/modules/apps/views/app_drawer.dart'; import 'package:launcher/src/data/models/shortcut_app_model.dart'; import 'package:launcher/src/helpers/utilities/image_picker.dart'; import 'package:launcher/src/helpers/utilities/local_storage.dart'; import 'package:launcher/src/helpers/widgets/custom_snackbar.dart'; import 'package:launcher/src/helpers/widgets/error_message.dart'; import 'package:launcher/src/helpers/widgets/success_message.dart'; import 'package:logger/logger.dart'; import 'package:url_launcher/url_launcher.dart'; class Home extends StatefulWidget { static const route = '/'; @override State<StatefulWidget> createState() { return HomeState(); } } class HomeState extends State { GlobalKey scaffoldKey = GlobalKey<ScaffoldState>(); double sidebarOpacity = 1; String defaultWallpaper = "assets/images/wallpaper.jpg"; String starterIcon = "assets/images/drawer.png"; bool autoOpenDrawer; String currentWallpaper; Future<void> loadWallpaper() async { currentWallpaper = await LocalStorage.getWallpaper(); setState(() {}); } @override void initState() { loadWallpaper(); super.initState(); } _launchCaller() async { const url = "tel:"; if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } } @override Widget build(BuildContext context) { final appsCubit = BlocProvider.of<AppsCubit>(context); final opacityCubit = BlocProvider.of<OpacityCubit>(context); Future<void> _showAppSelectDialog(ShortcutAppTypes appTypes) async { return showDialog<void>( context: context, barrierDismissible: true, // user must tap button! builder: (BuildContext context) { return AlertDialog( // scrollable: true, backgroundColor: Colors.transparent, title: Text( 'Select ${appTypes.name} App', overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: normalTextSize, color: Colors.pinkAccent), ), content: BlocBuilder<AppsCubit, AppsState>( builder: (context, state) { if (state is AppsLoaded) return Card( color: Colors.transparent, child: Container( height: deviceHeight / 2, width: deviceWidth, child: ListView( physics: ScrollPhysics(), shrinkWrap: true, children: <Widget>[ for (final app in state.apps) GestureDetector( onTap: () async { Navigator.of(context).pop(); Navigator.of(context).pop(); final ShortcutAppsModel shortcutApps = state.shortcutAppsModel; switch (appTypes) { case ShortcutAppTypes.CAMERA: shortcutApps.camera = app.packageName; break; case ShortcutAppTypes.MESSAGE: shortcutApps.message = app.packageName; break; case ShortcutAppTypes.PHONE: shortcutApps.phone = app.packageName; break; case ShortcutAppTypes.SETTINGS: shortcutApps.setting = app.packageName; break; default: break; } BlocProvider.of<AppsCubit>(context) .updateShortcutApps(shortcutApps); SuccessMessage( message: '${appTypes.name} application selected successfully.', context: context, ).display(); }, child: Container( margin: const EdgeInsets.all(5), child: Column( children: [ Row( children: [ app is ApplicationWithIcon ? CircleAvatar( backgroundImage: MemoryImage( app.icon, ), backgroundColor: Colors.white, ) : Icon( Icons.apps, size: iconSize, ), SizedBox( width: 10, ), Expanded( child: Padding( padding: const EdgeInsets.all(10.0), child: Text( app.appName, overflow: TextOverflow.ellipsis, style: TextStyle( color: Colors.white, fontSize: normalTextSize), ), ), ), ], ), // Divider() ], ), ), ) ], ), ), ); else return Container( alignment: Alignment.center, child: CircularProgressIndicator(), ); }, ), ); }, ); } Widget shortcutAppsBuild( IconData icon, String application, ShortcutAppTypes appType) { return GestureDetector( onTap: () async { if (application == null) { _showAppSelectDialog(appType); } else { try { // Todo : Need to fix this. // there is bug where system dial app is not working for some phone or dial app is not visible in device apps if (appType == ShortcutAppTypes.PHONE) _launchCaller(); else { bool isLaunchAble = await DeviceApps.openApp(application); Logger().w(isLaunchAble); if (!isLaunchAble) { // _showAppSelectDialog(appType); Navigator.pop(context); // DeviceApps.openAppSettings(application); ErrorMessage( context: context, fn: () => DeviceApps.openAppSettings(application), seconds: 4, error: "Please tap here to enable the application first or long press on the app icon to change application.") .display(); } } } catch (error) { Logger().w(error); ErrorMessage( context: context, error: "Something went wrong, Please try again.") .display(); } } }, onLongPress: () => _showAppSelectDialog(appType), child: Padding( padding: const EdgeInsets.only(top: 30.0), child: Icon( icon, size: iconSize, color: Colors.white, ), ), ); } SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle( statusBarIconBrightness: Brightness.light, statusBarColor: Color.fromRGBO(39, 21, 40, 0.5), // systemNavigationBarColor: Color.fromRGBO(72, 33, 79, 1), ), ); return WillPopScope( onWillPop: () async => false, child: Focus( onFocusChange: (isFocusChanged) { if (isFocusChanged) { opacityCubit.opacityReset(); appsCubit.loadApps(); } }, child: Scaffold( drawer: BlocBuilder<OpacityCubit, OpacityState>( builder: (context, state) { return Opacity( opacity: state is OpacityInitial ? 1 : .30, child: SafeArea( child: Container( color: Color.fromRGBO(39, 21, 40, 0.5), // Colors.pink.withOpacity(0.5), height: MediaQuery.of(context).size.height, width: 60.0, child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( children: [ GestureDetector( onTap: () { opacityCubit.setOpacitySemi(); Navigator.pushNamed( context, AppDrawer.route); }, child: Container( padding: const EdgeInsets.all(10), // width: 35, child: ClipRRect( child: Hero( tag: 'drawer', child: Image.asset( starterIcon, fit: BoxFit.cover, ), ), ), ), ), ], ), BlocBuilder<AppsCubit, AppsState>( builder: (context, state) { if (state is AppsLoaded) { return Column(children: [ shortcutAppsBuild( Icons.phone, state.shortcutAppsModel.phone, ShortcutAppTypes.PHONE), shortcutAppsBuild( Icons.sms, state.shortcutAppsModel.message, ShortcutAppTypes.MESSAGE), shortcutAppsBuild( Icons.camera, state.shortcutAppsModel.camera, ShortcutAppTypes.CAMERA), shortcutAppsBuild( Icons.settings, state.shortcutAppsModel.setting, ShortcutAppTypes.SETTINGS) ]); } else return Container(); }, ), Opacity( opacity: 0, child: IconButton( onPressed: () {}, icon: Icon(Icons.menu)), ), ]))), ); }, ), body: BlocBuilder<AppsCubit, AppsState>(builder: (context, state) { if (state is AppsLoading) return SafeArea( child: Container( key: scaffoldKey, decoration: BoxDecoration( image: DecorationImage( image: AssetImage("assets/images/boot2.gif"), fit: BoxFit.fill, )), height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, ), ); else if (state is AppsLoaded) { return GestureDetector( onLongPress: () async { pickImageFile(context, (image) async { if (image == null) { CustomSnackBar( context: context, message: "No image is selected", color: Colors.yellow) .display(); } else { setState(() { currentWallpaper = image.path; LocalStorage.setWallpaper(image.path); }); SuccessMessage( context: context, message: "Wallpaper changed successfully") .display(); } ; }); }, child: Container( key: scaffoldKey, decoration: BoxDecoration( image: DecorationImage( image: currentWallpaper != null ? FileImage(File(currentWallpaper)) : AssetImage(defaultWallpaper), fit: BoxFit.cover, )), height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, child: Row( children: <Widget>[ GestureDetector( onTap: () => Scaffold.of(context).openDrawer(), child: Container( color: Colors.transparent, height: MediaQuery.of(context).size.height, child: SizedBox( width: 70, )), ), ], ), ), ); } else { return Stack( children: [ Container( key: scaffoldKey, decoration: BoxDecoration( image: DecorationImage( image: AssetImage("assets/images/ubuntu-splash-screen.gif"), fit: BoxFit.cover, )), height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, ), Align( alignment: Alignment.bottomCenter, child: Text("Something went wrong!"), ) ], ); } }), // drawerEnableOpenDragGesture: // (appsCubit.state is AppsLoaded) ? true : false, ), ), ); } }
0
mirrored_repositories/Ubuntu-Launcher/lib/src/core/modules/home
mirrored_repositories/Ubuntu-Launcher/lib/src/core/modules/home/views/views.dart
export './home_page.dart';
0
mirrored_repositories/Ubuntu-Launcher/lib/src/core/modules
mirrored_repositories/Ubuntu-Launcher/lib/src/core/modules/404/404.dart
export './views/404_page.dart';
0
mirrored_repositories/Ubuntu-Launcher/lib/src/core/modules/404
mirrored_repositories/Ubuntu-Launcher/lib/src/core/modules/404/views/404_page.dart
import 'package:flutter/material.dart'; import 'package:launcher/src/config/constants/colors.dart'; import 'package:launcher/src/config/constants/size.dart'; class Page404 extends StatelessWidget { final String errorMessage; const Page404({Key key, @required this.errorMessage}) : assert(errorMessage != null), super(key: key); @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Text( errorMessage, style: TextStyle(color: dangerColor, fontSize: normalTextSize), ), ), ); } }
0
mirrored_repositories/Ubuntu-Launcher/lib/src/helpers
mirrored_repositories/Ubuntu-Launcher/lib/src/helpers/widgets/error_message.dart
import 'package:flutter/material.dart'; import 'package:launcher/src/config/constants/colors.dart'; import 'package:launcher/src/helpers/widgets/custom_snackbar.dart'; class ErrorMessage extends CustomSnackBar { final BuildContext context; final String error; final int days; final int seconds; final GlobalKey<ScaffoldState> key; final Function fn; // create constructor for ErrorMessage class ErrorMessage({ @required this.context, @required this.error, this.fn, this.days: 0, this.seconds: 2, this.key, }) : super( context: context, message: error, days: days, seconds: seconds, color: dangerColor, key: key); }
0
mirrored_repositories/Ubuntu-Launcher/lib/src/helpers
mirrored_repositories/Ubuntu-Launcher/lib/src/helpers/widgets/custom_snackbar.dart
import 'package:flutter/material.dart'; import 'package:launcher/src/config/constants/size.dart'; import 'package:logger/logger.dart'; class CustomSnackBar { final BuildContext context; final String message; final int days; final int seconds; final Color color; final Function fn; final GlobalKey<ScaffoldState> key; CustomSnackBar({ @required this.context, @required this.message, this.seconds: 2, this.fn, this.days: 0, this.color, this.key, }); display() { final snackBar = SnackBar( margin: const EdgeInsets.all(10), behavior: SnackBarBehavior.floating, duration: Duration(days: days, seconds: seconds), backgroundColor: color, content: GestureDetector( onTap: fn, child: Container( margin: const EdgeInsets.all(10), decoration: BoxDecoration( borderRadius: BorderRadius.circular(20), ), child: Row( children: [ Icon( Icons.error, color: Colors.white, ), SizedBox( width: 20, ), Expanded( child: Text( message, overflow: TextOverflow.visible, style: TextStyle(fontSize: smallTextSize), ), ) ], ), ), ), ); if (key != null) { return key.currentState.showSnackBar(snackBar); } else return ScaffoldMessenger.of(context).showSnackBar(snackBar); } }
0
mirrored_repositories/Ubuntu-Launcher/lib/src/helpers
mirrored_repositories/Ubuntu-Launcher/lib/src/helpers/widgets/success_message.dart
import 'package:flutter/material.dart'; import 'package:launcher/src/config/constants/colors.dart'; import 'package:launcher/src/helpers/widgets/custom_snackbar.dart'; class SuccessMessage extends CustomSnackBar { final BuildContext context; final String message; final int days; final int seconds; final GlobalKey<ScaffoldState> key; // create constructor for SuccessMessage class SuccessMessage({ @required this.context, @required this.message, this.days: 0, this.seconds: 2, this.key, }) : super( context: context, message: message, days: days, seconds: seconds, color: successColor, key: key); }
0
mirrored_repositories/Ubuntu-Launcher/lib/src/helpers
mirrored_repositories/Ubuntu-Launcher/lib/src/helpers/widgets/warning_message.dart
import 'package:flutter/material.dart'; import 'package:launcher/src/config/constants/colors.dart'; import 'package:launcher/src/helpers/widgets/custom_snackbar.dart'; class WarningMessage extends CustomSnackBar { final BuildContext context; final String warning; final int days; final int seconds; final GlobalKey<ScaffoldState> key; // create constructor for warning class WarningMessage({ @required this.context, @required this.warning, this.days, this.seconds, this.key, }) : super( context: context, message: warning, days: days, seconds: seconds, color: warningColor, key: key); }
0
mirrored_repositories/Ubuntu-Launcher/lib/src/helpers
mirrored_repositories/Ubuntu-Launcher/lib/src/helpers/utilities/local_storage.dart
import 'package:launcher/src/config/constants/enums.dart'; import 'package:launcher/src/data/models/shortcut_app_model.dart'; import 'package:shared_preferences/shared_preferences.dart'; class LocalStorage { static Future<void> setShortcutApps(ShortcutAppsModel shortcutApps) async { final SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setString(ShortcutAppTypes.CAMERA.name, shortcutApps.camera); prefs.setString(ShortcutAppTypes.PHONE.name, shortcutApps.phone); prefs.setString(ShortcutAppTypes.SETTINGS.name, shortcutApps.setting); prefs.setString(ShortcutAppTypes.MESSAGE.name, shortcutApps.message); } static Future<ShortcutAppsModel> getShortcutApps() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); return ShortcutAppsModel( camera: prefs.getString(ShortcutAppTypes.CAMERA.name), phone: prefs.getString(ShortcutAppTypes.PHONE.name), setting: prefs.getString(ShortcutAppTypes.SETTINGS.name), message: prefs.getString(ShortcutAppTypes.MESSAGE.name)); } static Future<void> setUserNew() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setBool("isNew", false); } static Future<bool> isUserNew() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); return prefs.getBool("isNew") ?? true; } static Future<void> setSortType(String sortType) async { final SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setString('sortType', sortType); } static Future<String> getSortType() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); return prefs.getString('sortType'); } static Future<void> setWallpaper(String path) async { final SharedPreferences preferences = await SharedPreferences.getInstance(); preferences.setString("wallpaper", path); } static Future<String> getWallpaper() async { final SharedPreferences preferences = await SharedPreferences.getInstance(); String image = preferences.getString("wallpaper"); return image; } static Future<void> clearAll() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.clear(); } }
0
mirrored_repositories/Ubuntu-Launcher/lib/src/helpers
mirrored_repositories/Ubuntu-Launcher/lib/src/helpers/utilities/image_picker.dart
import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; import 'package:launcher/src/config/constants/size.dart'; import 'package:launcher/src/helpers/widgets/error_message.dart'; final picker = ImagePicker(); Future<PickedFile> getImage() async { var image = await picker.getImage(source: ImageSource.gallery); return image; } Future<PickedFile> _selectImageFromFile() async { var image = await picker.getImage( source: ImageSource.gallery, ); return image; } Future<PickedFile> _captureFromCamera() async { var image = await picker.getImage(source: ImageSource.camera); return image; } typedef ImagePickedCallback = void Function(PickedFile image); void pickImageFile(BuildContext context, ImagePickedCallback callback) { showDialog( context: context, builder: (builder) => new AlertDialog( scrollable: true, title: Text( "Select Wallpaper from", style: TextStyle(fontSize: subTitleSize), ), actions: [ TextButton( onPressed: () { Navigator.of(context).pop(); }, child: Text( "Cancel", style: TextStyle( fontSize: smallTextSize, color: Colors.red, ), ), ) ], content: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ GestureDetector( onTap: () async { try { var image = await _captureFromCamera(); callback(image); } catch (err) { ErrorMessage(context: context, error: err.toString()).display(); } finally { Navigator.of(context).pop(); } }, child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Icon(Icons.camera_alt_outlined, size: iconSize * 2), Text( "Camera", style: TextStyle(fontSize: normalTextSize), ) ], ), ), GestureDetector( onTap: () async { try { var image = await _selectImageFromFile(); callback(image); } catch (err) { ErrorMessage(context: context, error: err.toString()).display(); } finally { Navigator.of(context).pop(); } }, child: Column( children: [ Icon(Icons.image_outlined, size: iconSize * 2), Text( "Gallery", style: TextStyle(fontSize: normalTextSize), ) ], ), ) ], ), ), ); }
0
mirrored_repositories/Ubuntu-Launcher/lib/src/helpers
mirrored_repositories/Ubuntu-Launcher/lib/src/helpers/utilities/routeAnimator.dart
import 'package:flutter/material.dart'; class RouteAnimator { static Route createRoute(Widget home) { { return PageRouteBuilder( opaque: false, pageBuilder: (context, animation, secondaryAnimation) => home, transitionsBuilder: (context, a1, a2, widget) { return Transform.scale( scale: a1.value, child: Opacity( opacity: a1.value, child: widget, ), ); }, transitionDuration: Duration(milliseconds: 300), barrierDismissible: true, barrierLabel: '', ); } } }
0
mirrored_repositories/brokerage_calculator
mirrored_repositories/brokerage_calculator/lib/main.dart
import 'package:brokerage_calculator/providers/deliveryProvider.dart'; import 'package:brokerage_calculator/providers/intradayProvider.dart'; import 'package:flutter/material.dart'; import 'package:brokerage_calculator/screens/homePage.dart'; import 'package:provider/provider.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MultiProvider( providers: [ ChangeNotifierProvider(create: (_) => IntradayProvider()), ChangeNotifierProvider(create: (_) => DeliveryProvider()), ], child: MaterialApp( title: 'Brokerage Calculator For Zerodha', theme: ThemeData( primarySwatch: Colors.purple, ), home: HomePage(), ), ); } }
0
mirrored_repositories/brokerage_calculator/lib
mirrored_repositories/brokerage_calculator/lib/helpers/enums.dart
enum Market { NSE, BSE, } extension marketExtension on Market { String? asString() => { Market.NSE: "NSE", Market.BSE: "BSE", }[this]; }
0
mirrored_repositories/brokerage_calculator/lib
mirrored_repositories/brokerage_calculator/lib/screens/equityIntraday.dart
import 'package:brokerage_calculator/providers/intradayProvider.dart'; import 'package:brokerage_calculator/screens/widgets/heading.dart'; import 'package:brokerage_calculator/helpers/enums.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class EquityIntraday extends StatefulWidget { @override _EquityIntradayState createState() => _EquityIntradayState(); } class _EquityIntradayState extends State<EquityIntraday> { @override Widget build(BuildContext context) { final intradayProvider = Provider.of<IntradayProvider>(context, listen: true); //intradayProvider.setBuyPrice(price: ""); //intradayProvider.setSellPrice(price: ""); //intradayProvider.setQuantity(quantity: ""); return SingleChildScrollView( child: Padding( padding: EdgeInsets.all(16.0), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ //Heading heading(heading: 'Equity Intraday'), Padding( padding: EdgeInsets.symmetric(vertical: 10.0), ), //Market Radio Button Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Expanded( child: ListTile( title: Text('NSE'), leading: Radio( value: Market.NSE, groupValue: intradayProvider.selectedMarket, onChanged: (value) { intradayProvider.selectMarket(market: value as Market); }, ), ), ), Expanded( child: ListTile( title: Text('BSE'), leading: Radio( value: Market.BSE, groupValue: intradayProvider.selectedMarket, onChanged: (value) { intradayProvider.selectMarket(market: value as Market); }, ), ), ), ], ), Divider(), //Buy Sell Quantity Row( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Expanded( child: TextField( enabled: true, keyboardType: TextInputType.number, style: TextStyle( color: Colors.grey.shade800, fontSize: 12.0, ), decoration: InputDecoration( labelText: "Buy", labelStyle: TextStyle(color: Colors.purple), border: OutlineInputBorder(), ), onChanged: (String value) { intradayProvider.setBuyPrice(price: value); intradayProvider.calcCharges(); }, ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 10.0), ), Expanded( child: TextField( enabled: true, keyboardType: TextInputType.number, style: TextStyle( color: Colors.grey.shade800, fontSize: 12.0, ), decoration: InputDecoration( labelText: "Sell", labelStyle: TextStyle(color: Colors.purple), border: OutlineInputBorder(), ), onChanged: (String value) { intradayProvider.setSellPrice(price: value); intradayProvider.calcCharges(); }, ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 10.0), ), Expanded( child: TextField( enabled: true, keyboardType: TextInputType.number, style: TextStyle( color: Colors.grey.shade800, fontSize: 12.0, ), decoration: InputDecoration( labelText: "Quantity", labelStyle: TextStyle(color: Colors.purple), border: OutlineInputBorder(), ), onChanged: (String value) { intradayProvider.setQuantity(quantity: value); intradayProvider.calcCharges(); }, ), ) ], ), Padding( padding: EdgeInsets.symmetric(vertical: 7.0), ), //Min Sell Price Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Text( 'Minimum Profit Sell: ${intradayProvider.minSellPrice}', style: TextStyle( color: Colors.green.shade400, ), ), ], ), Padding( padding: EdgeInsets.symmetric(vertical: 5.0), ), Divider(), Padding( padding: EdgeInsets.symmetric(vertical: 5.0), ), //Net P&L Column( children: <Widget>[ Text( 'Net P&L', style: TextStyle( fontSize: 20.0, color: Colors.black54, ), ), Padding( padding: EdgeInsets.symmetric(vertical: 5.0), ), Text( intradayProvider.netProfit.toString(), style: TextStyle( fontSize: 25.0, color: intradayProvider.netProfit.isNegative ? Colors.red : Colors.green, ), ), ], ), Padding( padding: EdgeInsets.symmetric(vertical: 5.0), ), Divider(), ListTile( title: Text('Total Tax & Charge'), trailing: Text(intradayProvider.totalCharge.toString()), ), Divider(), //Charges Expanded Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Expanded( child: ExpansionPanelList.radio( expansionCallback: (int index, bool _isExpanded) {}, children: <ExpansionPanel>[ //Brokerage ExpansionPanelRadio( value: 1, headerBuilder: (BuildContext context, bool _isExpanded) { return ListTile( title: Text('Total Brokerage'), trailing: Text( intradayProvider.totalBrokerage.toString()), ); }, body: Column( children: <ListTile>[ ListTile( title: Text('Buy Brokerage'), trailing: Text( intradayProvider.buyBrokerage.toString()), ), ListTile( title: Text('Sell Brokerage'), trailing: Text( intradayProvider.sellBrokerage.toString()), ), ], ), canTapOnHeader: true, ), //STT ExpansionPanelRadio( value: 2, headerBuilder: (BuildContext context, bool _isExpanded) { return ListTile( title: Text('STT'), trailing: Text(intradayProvider.totalSTT.toString()), ); }, body: ListTile( subtitle: Text( 'Securities Transaction Tax(STT) is only applied while selling the equity.'), ), canTapOnHeader: true, ), //Transaction Charge ExpansionPanelRadio( value: 3, headerBuilder: (BuildContext context, bool _isExpanded) { return ListTile( title: Text('Transaction Charge'), trailing: Text( intradayProvider.totalTxnCharge.toString()), ); }, body: Column( children: <ListTile>[ ListTile( title: Text('Buy Transaction Charge'), trailing: Text( intradayProvider.buyTxnCharge.toString()), ), ListTile( title: Text('Sell Transaction Charge'), trailing: Text( intradayProvider.sellTxnCharge.toString()), ), ], ), canTapOnHeader: true, ), //GST ExpansionPanelRadio( value: 4, headerBuilder: (BuildContext context, bool _isExpanded) { return ListTile( title: Text('GST'), trailing: Text(intradayProvider.totalGST.toString()), ); }, body: Column( children: <ListTile>[ ListTile( title: Text('Buy GST'), trailing: Text(intradayProvider.buyGST.toString()), ), ListTile( title: Text('Sell GST'), trailing: Text(intradayProvider.sellGST.toString()), ), ], ), canTapOnHeader: true, ), //Sebi Charges ExpansionPanelRadio( value: 5, headerBuilder: (BuildContext context, bool _isExpanded) { return ListTile( title: Text('Sebi Charge'), trailing: Text( intradayProvider.totalSebiCharge.toString()), ); }, body: Column( children: <ListTile>[ ListTile( title: Text('Buy Sebi Charge'), trailing: Text( intradayProvider.buySebiCharge.toString()), ), ListTile( title: Text('Sell Sebi Charge'), trailing: Text( intradayProvider.sellSebiCharge.toString()), ), ], ), canTapOnHeader: true, ), //Stamp Duty ExpansionPanelRadio( value: 6, headerBuilder: (BuildContext context, bool _isExpanded) { return ListTile( title: Text('Stamp Duty'), trailing: Text(intradayProvider.stampDuty.toString()), ); }, body: ListTile( subtitle: Text('Stamp charges on buying side.'), ), canTapOnHeader: true, ), ], ), ) ], ) ], ), ), ); } }
0
mirrored_repositories/brokerage_calculator/lib
mirrored_repositories/brokerage_calculator/lib/screens/equityDelivery.dart
import 'package:brokerage_calculator/screens/widgets/heading.dart'; import 'package:brokerage_calculator/providers/deliveryProvider.dart'; import 'package:brokerage_calculator/helpers/enums.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class EquityDelivery extends StatefulWidget { @override _EquityDeliveryState createState() => _EquityDeliveryState(); } class _EquityDeliveryState extends State<EquityDelivery> { @override Widget build(BuildContext context) { final deliveryProvider = Provider.of<DeliveryProvider>(context, listen: true); return SingleChildScrollView( child: Padding( padding: EdgeInsets.all(16.0), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ //Heading heading(heading: 'Equity Delivery'), Padding( padding: EdgeInsets.symmetric(vertical: 10.0), ), Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Expanded( child: ListTile( title: Text('NSE'), leading: Radio( value: Market.NSE, groupValue: deliveryProvider.selectedMarket, onChanged: (value) { deliveryProvider.selectMarket(market: value as Market); }, ), ), ), Expanded( child: ListTile( title: Text('BSE'), leading: Radio( value: Market.BSE, groupValue: deliveryProvider.selectedMarket, onChanged: (value) { deliveryProvider.selectMarket(market: value as Market); }, ), ), ), ], ), Divider(), Padding( padding: EdgeInsets.symmetric(vertical: 5.0), ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Expanded( child: TextField( enabled: true, keyboardType: TextInputType.number, style: TextStyle( color: Colors.grey.shade800, fontSize: 12.0, ), decoration: InputDecoration( labelText: "Buy", labelStyle: TextStyle(color: Colors.purple), border: OutlineInputBorder(), ), onChanged: (String value) { deliveryProvider.setBuyPrice(price: value); deliveryProvider.calcBuyCharges(); }, ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 10.0), ), Expanded( child: TextField( enabled: true, keyboardType: TextInputType.number, style: TextStyle( color: Colors.grey.shade800, fontSize: 12.0, ), decoration: InputDecoration( labelText: "Sell", labelStyle: TextStyle(color: Colors.purple), border: OutlineInputBorder(), ), onChanged: (String value) { deliveryProvider.setSellPrice(price: value); deliveryProvider.calcCharges(); }, ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 10.0), ), Expanded( child: TextField( enabled: true, keyboardType: TextInputType.number, style: TextStyle( color: Colors.grey.shade800, fontSize: 12.0, ), decoration: InputDecoration( labelText: "Quantity", labelStyle: TextStyle(color: Colors.purple), border: OutlineInputBorder(), ), onChanged: (String value) { deliveryProvider.setQuantity(quantity: value); deliveryProvider.calcCharges(); }, ), ), ], ), Padding( padding: EdgeInsets.symmetric(vertical: 5.0), ), //Minimum Profit Sell Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Text( 'Minimum Profit Sell: ${deliveryProvider.minSellPrice}', style: TextStyle( color: Colors.green.shade400, ), ), ], ), Padding( padding: EdgeInsets.symmetric(vertical: 5.0), ), Divider(), Padding( padding: EdgeInsets.symmetric(vertical: 5.0), ), Column( //Net P&L children: <Widget>[ Text( 'Net P&L', style: TextStyle( fontSize: 20.0, color: Colors.black54, ), ), Padding( padding: EdgeInsets.symmetric(vertical: 5.0), ), Text( deliveryProvider.netProfit.toString(), style: TextStyle( fontSize: 25.0, color: deliveryProvider.netProfit.isNegative ? Colors.red : Colors.green, ), ), ], ), Padding( padding: EdgeInsets.symmetric(vertical: 5.0), ), Divider(), //Total Charges ListTile( title: Text('Total Tax & Charge'), trailing: Text(deliveryProvider.totalCharge.toString()), ), Divider(), Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Expanded( child: ExpansionPanelList.radio( expansionCallback: (int index, bool _isExpanded) {}, children: <ExpansionPanel>[ //Brokerage ExpansionPanelRadio( value: 1, headerBuilder: (BuildContext context, bool _isExpanded) { return ListTile( title: Text('Total Brokerage'), trailing: Text( deliveryProvider.totalBrokerage.toString()), ); }, body: ListTile( trailing: Text('Zerodha charges 0 brokerage.'), ), canTapOnHeader: true, ), //STT ExpansionPanelRadio( value: 2, headerBuilder: (BuildContext context, bool _isExpanded) { return ListTile( title: Text('STT'), trailing: Text(deliveryProvider.totalSTT.toString()), ); }, body: Column( children: <ListTile>[ ListTile( title: Text('Buy STT'), trailing: Text(deliveryProvider.buySTT.toString()), ), ListTile( title: Text('Sell STT'), trailing: Text(deliveryProvider.sellSTT.toString()), ), ], ), canTapOnHeader: true, ), //Transaction Charge ExpansionPanelRadio( value: 3, headerBuilder: (BuildContext context, bool _isExpanded) { return ListTile( title: Text('Transaction Charge'), trailing: Text( deliveryProvider.totalTxnCharge.toString()), ); }, body: Column( children: <ListTile>[ ListTile( title: Text('Buy Transaction Charge'), trailing: Text( deliveryProvider.buyTxnCharge.toString()), ), ListTile( title: Text('Sell Transaction Charge'), trailing: Text( deliveryProvider.sellTxnCharge.toString()), ), ], ), canTapOnHeader: true, ), //GST ExpansionPanelRadio( value: 4, headerBuilder: (BuildContext context, bool _isExpanded) { return ListTile( title: Text('GST'), trailing: Text(deliveryProvider.totalGST.toString()), ); }, body: Column( children: <ListTile>[ ListTile( title: Text('Buy GST'), trailing: Text(deliveryProvider.buyGST.toString()), ), ListTile( title: Text('Sell GST'), trailing: Text(deliveryProvider.sellGST.toString()), ), ], ), canTapOnHeader: true, ), //Sebi Charges ExpansionPanelRadio( value: 5, headerBuilder: (BuildContext context, bool _isExpanded) { return ListTile( title: Text('Sebi Charge'), trailing: Text( deliveryProvider.totalSebiCharge.toString()), ); }, body: Column( children: <ListTile>[ ListTile( title: Text('Buy Sebi Charge'), trailing: Text( deliveryProvider.buySebiCharge.toString()), ), ListTile( title: Text('Sell Sebi Charge'), trailing: Text( deliveryProvider.sellSebiCharge.toString()), ), ], ), canTapOnHeader: true, ), //Stamp Duty ExpansionPanelRadio( value: 6, headerBuilder: (BuildContext context, bool _isExpanded) { return ListTile( title: Text('Stamp Duty'), trailing: Text(deliveryProvider.stampDuty.toString()), ); }, body: ListTile( subtitle: Text('Stamp charges on buying side.'), ), canTapOnHeader: true, ), ExpansionPanelRadio( value: 7, headerBuilder: (BuildContext context, bool _isExpanded) { return ListTile( title: Text('DP Charge'), trailing: Text(deliveryProvider.dpcharge.toString()), ); }, body: ListTile( subtitle: Text( '₹13.5 + GST per scrip (irrespective of quantity), on the day, is debited from the trading account when stocks are sold. This is charged by the depository (CDSL) and depository participant (Zerodha).'), ), canTapOnHeader: true, ), ], ), ), ], ), ], ), ), ); } }
0
mirrored_repositories/brokerage_calculator/lib
mirrored_repositories/brokerage_calculator/lib/screens/homePage.dart
import 'package:flutter/material.dart'; import 'package:brokerage_calculator/screens/equityIntraday.dart'; import 'package:brokerage_calculator/screens/equityDelivery.dart'; class HomePage extends StatefulWidget { @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { @override Widget build(BuildContext context) { return DefaultTabController( length: 2, child: SafeArea( child: Scaffold( appBar: AppBar( title: Center( child: Text('Brokerage Calculator For Zerodha'), ), bottom: TabBar( tabs: [ Padding( padding: EdgeInsets.symmetric(vertical: 10), child: Text('Equity Intraday'), ), Padding( padding: EdgeInsets.symmetric(vertical: 10), child: Text('Equity Delivery'), ) ], ), ), body: TabBarView( children: <Widget>[ EquityIntraday(), EquityDelivery(), ], ), ), ), ); } }
0
mirrored_repositories/brokerage_calculator/lib/screens
mirrored_repositories/brokerage_calculator/lib/screens/widgets/heading.dart
import 'package:flutter/material.dart'; Widget heading({required String heading}) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( heading, style: TextStyle(fontSize: 30.0, fontWeight: FontWeight.bold), textAlign: TextAlign.center, ), ], ); }
0
mirrored_repositories/brokerage_calculator/lib
mirrored_repositories/brokerage_calculator/lib/providers/intradayProvider.dart
import 'package:flutter/material.dart'; import 'package:brokerage_calculator/helpers/enums.dart'; class IntradayProvider extends ChangeNotifier { Market _selectedMarket = Market.NSE; double _buyPrice = 0, _sellPrice = 0; int _quantity = 0; double _buyBrokerage = 0, _sellBrokerage = 0, _totalBrokerage = 0; double _buySTT = 0, _sellSTT = 0, _totalSTT = 0; double _buyTxnCharge = 0, _sellTxnCharge = 0, _totalTxnCharge = 0; double _buyGST = 0, _sellGST = 0, _totalGST = 0; double _buySebiCharge = 0, _sellSebiCharge = 0, _totalSebiCharge = 0; double _stampDuty = 0; double _totalCharge = 0; double _netProfit = 0; double _minSellPrice = 0; //<<<<<<<<<<<<<<<<<<<< Getters >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Market get selectedMarket => _selectedMarket; double get buyPrice => _buyPrice; double get sellPrice => _sellPrice; int get quantity => _quantity; double get buyBrokerage => _buyBrokerage; double get sellBrokerage => _sellBrokerage; double get totalBrokerage => _totalBrokerage; double get buySTT => _buySTT; double get sellSTT => _sellSTT; double get totalSTT => _totalSTT; double get buyTxnCharge => _buyTxnCharge; double get sellTxnCharge => _sellTxnCharge; double get totalTxnCharge => _totalTxnCharge; double get buyGST => _buyGST; double get sellGST => _sellGST; double get totalGST => _totalGST; double get buySebiCharge => _buySebiCharge; double get sellSebiCharge => _sellSebiCharge; double get totalSebiCharge => _totalSebiCharge; double get stampDuty => _stampDuty; double get totalCharge => _totalCharge; double get netProfit => _netProfit; double get minSellPrice => _minSellPrice; //<<<<<<<<<<<<<<<<<<<< Setters >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> void selectMarket({required Market market}) { _selectedMarket = market; notifyListeners(); } void setBuyPrice({required String price}) { if (price == "") { _buyPrice = 0; } else { _buyPrice = double.parse(price); } calcMinSell(); notifyListeners(); } void setSellPrice({required String price}) { if (price == "") { _sellPrice = 0; } else { _sellPrice = double.parse(price); } notifyListeners(); } void setQuantity({required String quantity}) { if (quantity == "") { _quantity = 0; } else { _quantity = int.parse(quantity); } calcMinSell(); notifyListeners(); } void calcMinSell() { double buyPrice = _buyPrice; int quantity = _quantity; if (buyPrice == 0 || quantity == 0) { _minSellPrice = 0; notifyListeners(); return; } double minSellPriceInc = 0; if (_selectedMarket == Market.NSE) { minSellPriceInc = 0.01; } else { minSellPriceInc = 0.01; } double totalBuyCharges = round( num: (_buyGST + _buySTT + _buySebiCharge + _buyTxnCharge + _stampDuty + _buyBrokerage), n: 2); _minSellPrice = round(num: ((totalBuyCharges / quantity) + buyPrice), n: 2); double totalSellCharges = calcMinSellCharges(sellPrice: _minSellPrice, quantity: quantity); double net = ((_minSellPrice - buyPrice) * quantity) - totalBuyCharges - totalSellCharges; while (net <= 0) { _minSellPrice += minSellPriceInc; totalSellCharges = calcMinSellCharges(sellPrice: _minSellPrice, quantity: quantity); net = ((_minSellPrice - buyPrice) * quantity) - totalBuyCharges - totalSellCharges; } _minSellPrice = round(num: _minSellPrice, n: 2); notifyListeners(); } void calcBuyCharges() { double buyPrice = _buyPrice; int quantity = _quantity; double buyAmount = buyPrice * quantity; _buyBrokerage = (0.0003 * buyAmount) > 20 ? 20 : round(num: 0.0003 * buyAmount, n: 3); _buySTT = 0; _buyTxnCharge = round(num: 0.0000345 * buyAmount, n: 3); _buyGST = round(num: 0.18 * (_buyTxnCharge + _buyBrokerage), n: 3); _buySebiCharge = round(num: 0.0000001 * buyAmount, n: 3); _stampDuty = (0.00003 * buyAmount) < 300 ? round(num: (0.00003 * buyAmount), n: 2) : 300; notifyListeners(); } void calcSellCharges() { double sellPrice = _sellPrice; int quantity = _quantity; double sellAmount = sellPrice * quantity; _sellBrokerage = (0.0003 * sellAmount) > 20 ? 20 : round(num: 0.0003 * sellAmount, n: 3); _sellSTT = round(num: 0.00025 * sellAmount, n: 3); _sellTxnCharge = round(num: 0.0000345 * sellAmount, n: 3); _sellGST = round(num: 0.18 * (_sellTxnCharge + _sellBrokerage), n: 3); _sellSebiCharge = round(num: 0.0000001 * sellAmount, n: 3); notifyListeners(); } void calcCharges() { double buyPrice = _buyPrice; double sellPrice = _sellPrice; int quantity = _quantity; calcBuyCharges(); calcSellCharges(); _totalBrokerage = (_buyBrokerage + _sellBrokerage) > 20 ? 20 : round(num: (_buyBrokerage + _sellBrokerage), n: 2); _totalSTT = round(num: _buySTT + _sellSTT, n: 2); _totalGST = round(num: _buyGST + _sellGST, n: 2); _totalSebiCharge = round(num: _buySebiCharge + _sellSebiCharge, n: 2); _totalTxnCharge = round(num: _buyTxnCharge + _sellTxnCharge, n: 2); _totalCharge = round( num: (_totalBrokerage + _totalGST + _totalSTT + _totalSebiCharge + _totalTxnCharge + _stampDuty), n: 2); _netProfit = round(num: (((sellPrice - buyPrice) * quantity) - _totalCharge), n: 2); calcMinSell(); notifyListeners(); } void initializeValues() { _selectedMarket = Market.NSE; _buyPrice = 0; _sellPrice = 0; _quantity = 0; _buyBrokerage = 0; _sellBrokerage = 0; _totalBrokerage = 0; _buySTT = 0; _sellSTT = 0; _totalSTT = 0; _buyTxnCharge = 0; _sellTxnCharge = 0; _totalTxnCharge = 0; _buyGST = 0; _sellGST = 0; _totalGST = 0; _buySebiCharge = 0; _sellSebiCharge = 0; _totalSebiCharge = 0; _stampDuty = 0; _totalCharge = 0; _netProfit = 0; _minSellPrice = 0; } //<<<<<<<<<<<<<<<<<<<<< functions >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> double round({required double num, required int n}) { return double.parse(num.toStringAsFixed(n)); } double calcMinSellCharges( {required double sellPrice, required int quantity}) { double sellAmount = sellPrice * quantity; double sellBrokerage = (0.0003 * sellAmount) > 20 ? 20 : round(num: 0.0003 * sellAmount, n: 3); _sellSTT = round(num: 0.00025 * sellAmount, n: 3); _sellTxnCharge = round(num: 0.0000345 * sellAmount, n: 3); _sellGST = round(num: 0.18 * (_sellTxnCharge + _sellBrokerage), n: 3); _sellSebiCharge = round(num: 0.0000001 * sellAmount, n: 3); double totalSellCharge = sellSTT + sellTxnCharge + sellGST + sellSebiCharge + sellBrokerage; return round(num: totalSellCharge, n: 3); } }
0
mirrored_repositories/brokerage_calculator/lib
mirrored_repositories/brokerage_calculator/lib/providers/deliveryProvider.dart
import 'dart:core'; import 'package:flutter/material.dart'; import 'package:brokerage_calculator/helpers/enums.dart'; class DeliveryProvider extends ChangeNotifier { Market _selectedMarket = Market.NSE; double _buyPrice = 0, _sellPrice = 0; int _quantity = 0; double _totalBrokerage = 0; double _buySTT = 0, _sellSTT = 0, _totalSTT = 0; double _buyTxnCharge = 0, _sellTxnCharge = 0, _totalTxnCharge = 0; double _buyGST = 0, _sellGST = 0, _totalGST = 0; double _buySebiCharge = 0, _sellSebiCharge = 0, _totalSebiCharge = 0; double _stampDuty = 0; double _totalCharge = 0; double _dpCharge = 0; double _netProfit = 0; double _minSellPrice = 0; //<<<<<<<<<<<<<<<<<<<< Getters >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Market get selectedMarket => _selectedMarket; double get buyPrice => _buyPrice; double get sellPrice => _sellPrice; int get quantity => _quantity; double get totalBrokerage => _totalBrokerage; double get buySTT => _buySTT; double get sellSTT => _sellSTT; double get totalSTT => _totalSTT; double get buyTxnCharge => _buyTxnCharge; double get sellTxnCharge => _sellTxnCharge; double get totalTxnCharge => _totalTxnCharge; double get buyGST => _buyGST; double get sellGST => _sellGST; double get totalGST => _totalGST; double get buySebiCharge => _buySebiCharge; double get sellSebiCharge => _sellSebiCharge; double get totalSebiCharge => _totalSebiCharge; double get stampDuty => _stampDuty; double get dpcharge => _dpCharge; double get totalCharge => _totalCharge; double get netProfit => _netProfit; double get minSellPrice => _minSellPrice; //<<<<<<<<<<<<<<<<<<<< Setters >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> void selectMarket({required Market market}) { _selectedMarket = market; notifyListeners(); } void setBuyPrice({required String price}) { if (price == "") { _buyPrice = 0; } else { _buyPrice = double.parse(price); } calcMinSell(); notifyListeners(); } void setSellPrice({required String price}) { if (price == "") { _sellPrice = 0; } else { _sellPrice = double.parse(price); } notifyListeners(); } void setQuantity({required String quantity}) { if (quantity == "") { _quantity = 0; } else { _quantity = int.parse(quantity); } calcMinSell(); notifyListeners(); } void calcMinSell() { double buyPrice = _buyPrice; int quantity = _quantity; if (buyPrice == 0 || quantity == 0) { _minSellPrice = 0; notifyListeners(); return; } double minSellPriceInc = 0; if (_selectedMarket == Market.NSE) { minSellPriceInc = 0.01; } else { minSellPriceInc = 0.01; } double totalBuyCharges = round( num: (_buyGST + _buySTT + _buySebiCharge + _buyTxnCharge + _stampDuty), n: 3); _minSellPrice = round(num: ((totalBuyCharges / quantity) + buyPrice), n: 3); double totalSellCharges = calcMinSellCharges(sellPrice: _minSellPrice, quantity: quantity); double net = round( num: ((_minSellPrice - buyPrice) * quantity) - totalBuyCharges - totalSellCharges, n: 3); while (net <= 0) { _minSellPrice += minSellPriceInc; totalSellCharges = calcMinSellCharges(sellPrice: _minSellPrice, quantity: quantity); net = ((_minSellPrice - buyPrice) * quantity) - totalBuyCharges - totalSellCharges; } _minSellPrice = round(num: _minSellPrice, n: 2); notifyListeners(); } void calcBuyCharges() { double buyPrice = _buyPrice; int quantity = _quantity; double buyAmount = buyPrice * quantity; _buySTT = round(num: 0.001 * buyAmount, n: 3); _buyTxnCharge = round(num: 0.0000345 * buyAmount, n: 3); _buyGST = round(num: 0.18 * _buyTxnCharge, n: 3); _buySebiCharge = round(num: 0.0000001 * buyAmount, n: 3); _stampDuty = (0.00015 * buyAmount) < 1500 ? round(num: (0.00015 * buyAmount), n: 2) : 1500; notifyListeners(); } void calcSellCharges() { double sellPrice = _sellPrice; int quantity = _quantity; double sellAmount = sellPrice * quantity; _sellSTT = round(num: 0.001 * sellAmount, n: 3); _sellTxnCharge = round(num: 0.0000345 * sellAmount, n: 3); _sellGST = round(num: 0.18 * _sellTxnCharge, n: 3); _sellSebiCharge = round(num: 0.0000001 * sellAmount, n: 3); _dpCharge = (quantity > 0 && sellPrice > 0) ? round(num: 1.18 * 13.5, n: 2) : 0; notifyListeners(); } void calcCharges() { double buyPrice = _buyPrice; double sellPrice = _sellPrice; int quantity = _quantity; calcBuyCharges(); calcSellCharges(); _totalSTT = round(num: _buySTT + _sellSTT, n: 2); _totalGST = round(num: _buyGST + _sellGST, n: 2); _totalSebiCharge = round(num: _buySebiCharge + _sellSebiCharge, n: 2); _totalTxnCharge = round(num: _buyTxnCharge + _sellTxnCharge, n: 2); _totalCharge = round( num: (_totalBrokerage + _totalGST + _totalSTT + _totalSebiCharge + _totalTxnCharge + _stampDuty + _dpCharge), n: 2); _netProfit = round(num: (((sellPrice - buyPrice) * quantity) - _totalCharge), n: 2); calcMinSell(); notifyListeners(); } //<<<<<<<<<<<<<<<<<<<<< functions >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> double round({required double num, required int n}) { return double.parse(num.toStringAsFixed(n)); } double calcMinSellCharges( {required double sellPrice, required int quantity}) { double sellAmount = sellPrice * quantity; double sellSTT = round(num: 0.001 * sellAmount, n: 3); double sellTxnCharge = round(num: 0.0000345 * sellAmount, n: 3); double sellGST = round(num: 0.18 * _sellTxnCharge, n: 3); double sellSebiCharge = round(num: 0.0000001 * sellAmount, n: 3); double dpCharge = round(num: 1.18 * 13.5, n: 2); double totalSellCharge = sellSTT + sellTxnCharge + sellGST + sellSebiCharge + dpCharge; return round(num: totalSellCharge, n: 3); } }
0
mirrored_repositories/brokerage_calculator
mirrored_repositories/brokerage_calculator/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:brokerage_calculator/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/MovieListApp
mirrored_repositories/MovieListApp/lib/movie.dart
class Movie { static List<Movie> getMovies()=> [ Movie("Avatar", "2009", "18 Dec 2009", "Action, Adventure, Fantasy", "James Cameron", "Sam Worthington, Zoe Saldana, Sigourney Weaver, Stephen Lang", "USA, UK", [ "https://images-na.ssl-images-amazon.com/images/M/MV5BMjEyOTYyMzUxNl5BMl5BanBnXkFtZTcwNTg0MTUzNA@@._V1_SX1500_CR0,0,1500,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BNzM2MDk3MTcyMV5BMl5BanBnXkFtZTcwNjg0MTUzNA@@._V1_SX1777_CR0,0,1777,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTY2ODQ3NjMyMl5BMl5BanBnXkFtZTcwODg0MTUzNA@@._V1_SX1777_CR0,0,1777,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTMxOTEwNDcxN15BMl5BanBnXkFtZTcwOTg0MTUzNA@@._V1_SX1777_CR0,0,1777,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTYxMDg1Nzk1MV5BMl5BanBnXkFtZTcwMDk0MTUzNA@@._V1_SX1500_CR0,0,1500,999_AL_.jpg" ]), Movie("I Am Legend", "2007", "14 Dec 2007", "Drama, Horror, Sci-Fi", "Francis Lawrence", "Will Smith, Alice Braga, Charlie Tahan, Salli Richardson-Whitfield", "USA", [ "https://images-na.ssl-images-amazon.com/images/M/MV5BMTI0NTI4NjE3NV5BMl5BanBnXkFtZTYwMDA0Nzc4._V1_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTIwMDg2MDU4M15BMl5BanBnXkFtZTYwMTA0Nzc4._V1_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTc5MDM1OTU5OV5BMl5BanBnXkFtZTYwMjA0Nzc4._V1_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTA0MTI2NjMzMzFeQTJeQWpwZ15BbWU2MDMwNDc3OA@@._V1_.jpg" ]), Movie("300", "2006", "09 Mar 2007", "Action, Drama, Fantasy", "Zack Snyder", "Gerard Butler, Lena Headey, Dominic West, David Wenham", "USA", [ "https://images-na.ssl-images-amazon.com/images/M/MV5BMTMwNTg5MzMwMV5BMl5BanBnXkFtZTcwMzA2NTIyMw@@._V1_SX1777_CR0,0,1777,937_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTQwNTgyNTMzNF5BMl5BanBnXkFtZTcwNDA2NTIyMw@@._V1_SX1777_CR0,0,1777,935_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTc0MjQzOTEwMV5BMl5BanBnXkFtZTcwMzE2NTIyMw@@._V1_SX1777_CR0,0,1777,947_AL_.jpg", ]), Movie("The Avengers", "2012", "04 May 2012", "Action, Thriller, Fantasy", "Joss Whedon", "Robert Downey Jr., Chris Evans, Mark Ruffalo, Chris Hemsworth", "USA", [ "https://images-na.ssl-images-amazon.com/images/M/MV5BMTA0NjY0NzE4OTReQTJeQWpwZ15BbWU3MDczODg2Nzc@._V1_SX1777_CR0,0,1777,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMjE1MzEzMjcyM15BMl5BanBnXkFtZTcwNDM4ODY3Nw@@._V1_SX1777_CR0,0,1777,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMjMwMzM2MTg1M15BMl5BanBnXkFtZTcwNjM4ODY3Nw@@._V1_SX1777_CR0,0,1777,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTQ4NzM2Mjc5MV5BMl5BanBnXkFtZTcwMTkwOTY3Nw@@._V1_SX1777_CR0,0,1777,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTc3MzQ3NjA5N15BMl5BanBnXkFtZTcwMzY5OTY3Nw@@._V1_SX1777_CR0,0,1777,999_AL_.jpg", ]), Movie("The Wolf of Wall Street", "2013", "25 Dec 2013", "Biography, Comedy, Crime", "Martin Scorsese", "Leonardo DiCaprio, Jonah Hill, Margot Robbie, Matthew McConaughey", "USA", [ "https://images-na.ssl-images-amazon.com/images/M/MV5BNDIwMDIxNzk3Ml5BMl5BanBnXkFtZTgwMTg0MzQ4MDE@._V1_SX1500_CR0,0,1500,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTc0NzAxODAyMl5BMl5BanBnXkFtZTgwMDg0MzQ4MDE@._V1_SX1500_CR0,0,1500,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTExMDk1MDE4NzVeQTJeQWpwZ15BbWU4MDM4NDM0ODAx._V1_SX1500_CR0,0,1500,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTg3MTY4NDk4Nl5BMl5BanBnXkFtZTgwNjc0MzQ4MDE@._V1_SX1500_CR0,0,1500,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTgzMTg4MDI0Ml5BMl5BanBnXkFtZTgwOTY0MzQ4MDE@._V1_SY1000_CR0,0,1553,1000_AL_.jpg", ]), Movie("Interstellar", "2014", "07 Nov 2014", "Adventure, Drama, Sci-Fi", "Christopher Nolan", "Ellen Burstyn, Matthew McConaughey, Mackenzie Foy, John Lithgow", "USA", [ "https://images-na.ssl-images-amazon.com/images/M/MV5BMjA3NTEwOTMxMV5BMl5BanBnXkFtZTgwMjMyODgxMzE@._V1_SX1500_CR0,0,1500,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMzQ5ODE2MzEwM15BMl5BanBnXkFtZTgwMTMyODgxMzE@._V1_SX1500_CR0,0,1500,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTg4Njk4MzY0Nl5BMl5BanBnXkFtZTgwMzIyODgxMzE@._V1_SX1500_CR0,0,1500,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMzE3MTM0MTc3Ml5BMl5BanBnXkFtZTgwMDIyODgxMzE@._V1_SX1500_CR0,0,1500,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BNjYzNjE2NDk3N15BMl5BanBnXkFtZTgwNzEyODgxMzE@._V1_SX1500_CR0,0,1500,999_AL_.jpg", ]), Movie("Game of Thrones", "2011", "17 Apr 2011", "Adventure, Drama, Fantasy", "N/A", "Peter Dinklage, Lena Headey, Emilia Clarke, Kit Harington", "USA", [ "https://images-na.ssl-images-amazon.com/images/M/MV5BNDc1MGUyNzItNWRkOC00MjM1LWJjNjMtZTZlYWIxMGRmYzVlXkEyXkFqcGdeQXVyMzU3MDEyNjk@._V1_SX1777_CR0,0,1777,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BZjZkN2M5ODgtMjQ2OC00ZjAxLWE1MjMtZDE0OTNmNGM0NWEwXkEyXkFqcGdeQXVyNjUxNzgwNTE@._V1_SX1777_CR0,0,1777,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMDk4Y2Y1MDAtNGVmMC00ZTlhLTlmMmQtYjcyN2VkNzUzZjg2XkEyXkFqcGdeQXVyNjUxNzgwNTE@._V1_SX1777_CR0,0,1777,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BNjZjNWIzMzQtZWZjYy00ZTkwLWJiMTYtOWRkZDBhNWJhY2JmXkEyXkFqcGdeQXVyMjk3NTUyOTc@._V1_SX1777_CR0,0,1777,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BNTMyMTRjZWEtM2UxMS00ZjU5LWIxMTYtZDA5YmJhZmRjYTc4XkEyXkFqcGdeQXVyMjk3NTUyOTc@._V1_SX1777_CR0,0,1777,999_AL_.jpg", ]), Movie("Vikings", "2013", "03 Mar 2013", "Action, Drama, History", "Michael Hirst", "Travis Fimmel, Clive Standen, Gustaf Skarsgård, Katheryn Winnick", "USA", [ "https://images-na.ssl-images-amazon.com/images/M/MV5BMjM5MTM1ODUxNV5BMl5BanBnXkFtZTgwNTAzOTI2ODE@._V1_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BNzU2NDcxODMyOF5BMl5BanBnXkFtZTgwNDAzOTI2ODE@._V1_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMjMzMzIzOTU2M15BMl5BanBnXkFtZTgwODMzMTkyODE@._V1_SY1000_SX1500_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTQ2NTQ2MDA3NF5BMl5BanBnXkFtZTgwODkxMDUxODE@._V1_SY1000_SX1500_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTcxOTQ3NTA5N15BMl5BanBnXkFtZTgwMzExMDUxODE@._V1_SY1000_SX1500_AL_.jpg", ]), Movie("Gotham", "2014", "01 Aug 2014", "Action, Crime, Drama", "N/A", "Ben McKenzie, Donal Logue, David Mazouz, Sean Pertwee", "USA", [ "https://images-na.ssl-images-amazon.com/images/M/MV5BNDI3ODYyODY4OV5BMl5BanBnXkFtZTgwNjE5NDMwMDI@._V1_SY1000_SX1500_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMjA5OTExMTIwNF5BMl5BanBnXkFtZTgwMjI5NDMwMDI@._V1_SY1000_SX1500_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMTA3MDY2NjA3MzBeQTJeQWpwZ15BbWU4MDU0MDkzODgx._V1_SX1499_CR0,0,1499,999_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMjM3MzYzNDgzOV5BMl5BanBnXkFtZTgwMjQwOTM4ODE@._V1_SY1000_CR0,0,1498,1000_AL_.jpg", "https://images-na.ssl-images-amazon.com/images/M/MV5BMjQwODAyNjk0NF5BMl5BanBnXkFtZTgwODU4MzMyODE@._V1_SY1000_CR0,0,1500,1000_AL_.jpg", ]), ]; String title; String year; String released; String genre; String director; String actors; String country; List<String> images; Movie(this.title, this.year, this.released, this.genre, this.director, this.actors, this.country, this.images); }
0
mirrored_repositories/MovieListApp
mirrored_repositories/MovieListApp/lib/movie_ui.dart
import 'package:flutter/material.dart'; import 'package:listitem/movie.dart'; class MovieDetails extends StatelessWidget { final String movieName; final Movie movie; const MovieDetails({Key key, this.movieName, this.movie}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Details'), backgroundColor: Colors.blueGrey, ), backgroundColor: Colors.blueGrey.shade600, body: ListView( children: <Widget>[ MovieDetailsThums(thumbnail: movie.images[0]), Line(), MoviePoster(poster: movie.images[1]), SizedBox(height: 30.0,), MovieActor(actors: movie.actors,), MovieExtraPosters(poster: movie.images,) ], ), ); } } class MovieDetailsThums extends StatelessWidget { final String thumbnail; const MovieDetailsThums({Key key, this.thumbnail}) : super(key: key); @override Widget build(BuildContext context) { return Stack( alignment: Alignment.bottomCenter, children: <Widget>[ Stack( alignment: Alignment.center, children: <Widget>[ Container( height: 190.0, width: MediaQuery.of(context).size.width, decoration: BoxDecoration( image: DecorationImage( image: NetworkImage(thumbnail), fit: BoxFit.cover, )), ), Icon( Icons.play_circle_outline, color: Colors.white, size: 100.0, ) ], ), Container( decoration: BoxDecoration( gradient: LinearGradient(colors: [Color(0x00f5f5f5), Color(0xfff5f5f5)], begin: Alignment.topCenter, end: Alignment.bottomCenter), ), height: 60.0, ) ], ); } } class MovieDetailsPoster extends StatelessWidget { final Movie movie; const MovieDetailsPoster({Key key, this.movie}) : super(key: key); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[ MoviePoster(poster: movie.images[0].toString()), SizedBox( height: 50.0, ), MovieActor(actors: movie.actors,), ], ), ); } } class MovieActor extends StatelessWidget { final String actors; const MovieActor({Key key, this.actors}) : super(key: key); @override Widget build(BuildContext context) { return Container( child: Padding( padding: const EdgeInsets.all(20.0), child: Center( child: Text("Actor : $actors",style: TextStyle( color: Colors.grey, fontSize: 20.0, ),), ), ), ); } } class MoviePoster extends StatelessWidget { final String poster; const MoviePoster({Key key, this.poster}) : super(key: key); @override Widget build(BuildContext context) { var borderRadius= BorderRadius.all(Radius.circular(10.0)); return ClipRRect( borderRadius: borderRadius, child: Container( width: 100, height: 160, decoration: BoxDecoration( image: DecorationImage( image: NetworkImage(poster), // fit: BoxFit.cover, ), ), ), ); } } class Line extends StatelessWidget { @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 20,vertical: 20), child: Container( height: 10.0, color: Colors.black, ), ); } } class MovieExtraPosters extends StatelessWidget { final List<String>poster; const MovieExtraPosters({Key key, this.poster}) : super(key: key); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Center( child: Text('More movies poster'.toUpperCase(), style: TextStyle( fontSize: 14.0, color: Colors.black87, ),), ), SizedBox( height: 20.0, ), Container( height: 200, child: ListView.separated( itemBuilder: (context,index)=>ClipRRect( borderRadius: BorderRadius.all(Radius.circular(10)), child: Container( width: MediaQuery.of(context).size.width / 4, height: 160, decoration: BoxDecoration( image: DecorationImage( image: NetworkImage(poster[index]), fit: BoxFit.cover ) ), ), ), scrollDirection: Axis.horizontal, separatorBuilder: (context, index)=>SizedBox(width: 10,), itemCount: poster.length), ), ], ), ); } }
0
mirrored_repositories/MovieListApp
mirrored_repositories/MovieListApp/lib/main.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:listitem/movie_ui.dart'; import 'movie.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: MovieListView(), ); } } class MovieListView extends StatelessWidget { final List<Movie> movieList = Movie.getMovies(); // final List movies = [ // 'The GodFather', // 'Citizen Cane', // 'The dark knight', // 'Pulp Fiction', // 'Dear john', // 'Gone girl', // 'Shutter Island', // 'The Gift', // 'Interseller', // 'The Notebook', // 'The vinci Code' // ]; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Center(child: Text('Movies')), backgroundColor: Colors.blueGrey, ), backgroundColor: Colors.blueGrey.shade900, body: ListView.builder( itemCount: movieList.length, itemBuilder: (BuildContext context, int index) { return Stack(children: <Widget>[ movieCard(movieList[index], context), Positioned( top: 10, child: movieImage(movieList[index].images[0])), ]); // return Card( // elevation: 5.0, // // color: Colors.white, // child: ListTile( // title: Text(movieList[index].title), // subtitle: Text("${movieList.elementAt(index).title}"), // leading: CircleAvatar( // child: Container( // height: 200, // width: 200, // decoration: BoxDecoration( // image: DecorationImage( // image: NetworkImage(movieList[index].images[0]), // fit: BoxFit.cover, // ), // color: Colors.blue, // borderRadius: BorderRadius.circular(10.0) // ), // child: null, // ), // ), // trailing: Text('...'), // onTap: (){ // debugPrint('Movies Name : ${movieList.elementAt(index).title}'); // Navigator.push(context, MaterialPageRoute(builder: (context){ // return MovieDetails(movieName: movieList.elementAt(index).title, // movie: movieList[index],); // })); // }, // ), // ); }), ); } Widget movieCard(Movie movie, BuildContext context) { return InkWell( child: Container( margin: EdgeInsets.only(left: 60.0), height: 120, width: MediaQuery.of(context).size.width, child: Card( color: Colors.black12, child: Padding( padding: const EdgeInsets.only( top: 8.0, bottom: 8.0, left: 40.0, right: 20.0), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text( movie.title, style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, color: Colors.white, ), ), Text( "Country: ${movie.country}", style: mainTextStyle(), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ Text("Released: ${movie.released}", style: mainTextStyle()), Text( "Year: ${movie.year}", style: mainTextStyle(), ), // Text("Genre: ${movie.genre}"), ], ), ], ), ), ), ), ), onTap: () { debugPrint('Movies Name : ${movie.title}'); Navigator.push( context, MaterialPageRoute(builder: (context) { return MovieDetails( movieName: movie.title, movie: movie, ); }), ); }); } TextStyle mainTextStyle() { return TextStyle( color: Colors.grey, fontSize: 15.0, ); } Widget movieImage(String imageUrl) { return Container( width: 100, height: 100, decoration: BoxDecoration( shape: BoxShape.circle, image: DecorationImage( image: NetworkImage(imageUrl ?? ' data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxMTEhUSEhIVFhUVFRUXFRUXFRUVFRUXFRUXFhUVFRUYHSggGBolHRUVITEhJSkrLi4uFx8zODMtNygtLisBCgoKDg0OGhAQGy0lHyUtLS0tLS0tLS0tLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLf/AABEIAMIBAwMBIgACEQEDEQH/xAAcAAABBQEBAQAAAAAAAAAAAAACAAEDBAUGBwj/xABBEAABAgMFAwkFBgUEAwAAAAABAAIDBBEFEiExQVFhcQYTIjKBkaGx0RRCUpLBByNDU+HwFTNigrJyosLSJCVE/8QAGgEAAwEBAQEAAAAAAAAAAAAAAAECAwQFBv/EACoRAAICAQMEAQQCAwEAAAAAAAABAhEDEzFRBBIhQWEUMnGhgZEi4fBC/9oADAMBAAIRAxEAPwDUbFUzIiz2vU7Ii+nPnS6CnLAq7IisMiBIpFaZmIbHNY97WufgwE0LjhgNuY71I6Cua5VvBnJIbH173s9F1tVMZW2jVxSSfJRdCQ82VcLErioiijzaV1XSxA6GgCqQhLVO5iBwQMgonRlMkANUk5TIAVUkyVUAJIpqpVSAYhMnqkgBgEi1ElVMCItQFqs0QOalQFYhAVYcFGWqaGRJJ3NQlACRtUV5A6YaM3NHaErFRbqkqPt8P8xnzN9U6fcg7WaIKNrlCEYV2RRZa9TNiKo0qQFOwo57lCA+elWnEdE/76/RdcHrjrTdW0IG5rfNy6xrllj3l+Taf2x/BOHIg9QVTXloZljnEr6gvJi5A7JnEISAqr5tgze0doUT7SYMak8GuP0StDplt0JRuhqsbS2Md/tH1Uf8RcSQGDDa70CO5BTLZagKpxpuJQmrBQfCT9UL3PP4h7A0fRLuCi4SnCyXjpCr3UofeI1Gym9A+JBHWc3+51fMqe8faaz3gZkDiQojNQ/jb2EHyWXDm4Lbxq0Y4UG4bEnW1BBpeJ4NKnUXJWm+GaPtjNKng1x8aJe17GPPYB5kLJh21DAydroNTXagdb7dGHtICWrHkelLgtWjbLoZhtEI1e6mLgMMAThXarhjxPgb85/6rk7WtPnHwnXaXDXOtcQdm5XX8oH6Mb4lRrK35NHhdKkb4jRP6B2OP1CGFGiOaCXNFQDgzbxK5825F2N7j6qD+LxQAA7IAdUaI14/ItCXwdOWuP4juwM/6qCOw0/mPzaMwM3AaDeubfa0X8zwb6KB9qPOcU6e9TLFS+oiUsEvg6t0sNr/AJ3+qjdKN2V4knzK5N1pu1jH5z6qB9oDWL/v/VS+ojwPQlydXMyrAOo3rM90fG1FdYNGjuC4x06zV470BnYfxBT9SuCtB8nbCM34m94SXEe3w/i8Ckj6pB9Mz1BrVK0Ko6dHutccSK0oMMNcfBRNtJxFbrW55ku17F2d6OLsZp3EfNrnzawp0o1NzaDXdiq38XhAY3nmpzFdTTFxUvNFFrFIGfit/iMM1BAaKkY6O2cV0JtFlaAOPZTzpsXCTE//AOTzrQBSmBOFLtMVNG5S4k32NwAwxyrx2rBZ1G/ydEsLlVcHZPtJ2FGDE0xduJyA3bUMSciUPSaODfUlcDH5SV/EeeAI9FTiW6D7rzxKl9XEa6VnoJnBQX42g94DwbRVfb4IredexOdXea4F1tO0YBxJKida0U5EDgPVZvq0aLpfk751rww4EA5EZAaj0UUa2qggMOIzJXAunopzeeyg8lE6K85vd8xUPq5FrponexrcfoGDjU/VVn26R+KwVz6q4ct3pUCh9TMpYII6+JygBzjd36BV328w5xHn5lzOCIEKHmkytKKN023D2OPYPVQRLYafcPeAsi8nv7lLyS5K7UajrbOkPx/RRG2Hk1ut8Vn3k15LvfI+1F82vF/pHZ+qiNqRfiHcFTL1LLSznnDAbSl3SY6SLsrMvdeLnE0GGWGaqOmYnxu71chSroYdU1qPIFZF87VUm0lYopWywYrz77vmKA12nvKivb0r29Z2VRIWpXFHe3pXt6LQElxNdQXt6aoSsA7qVEFU1UDDSQJIA6aJymdkHvIxwGGaoxbaJyb3mqyXVGYp2K7K2RMxac3Lxng5FsN5B7QKLV5ZszWOKHdacU6gcB6qF8285vd308luy3IC0X//ACuaNr3Mb4F1fBasv9lc4eu+Cz+5zz4CnihQyS9MLijmHH7jHHAf5LOBGQC7aS5KX5kyLonVqC9rfhAfgD3Lei/ZpLwob4hiRXFjHOFS0CrQSMANy1eCcvKI1Io8viMc3NtFHzi13MvPAK9a5IWHLmUhPdAhXiDV3Ntqbri0E4Z0AUwwd73KlOkeHtcTljwxViHIxndWFFPCG8+QX0OyQhjqta3gAPJOZUaFbro17l+jJ9Q+DwSFybnHZS0Xtbd/yorkHkTPO/Au/wCp7B5Fe3ex71G+XIWi6PH7bIfUT4R5BD+z6cOfNN4vJ8mq2z7OI+saGOxx9F6gYaa4rXSYjN9RkPNWfZu73plvZDP/AGVhv2ds96Yd2MA8yV6AYaB0JWumxcEvPk5OHb9n0DWNFPyD/ipW8hJUZmIf7gPILr3y5UZgFVoY+ES82Tk5dvIuUHuOPF7vVSt5Kyg/BB4uefqugME7FG+EdielBf8Alf0TqT5Z5/yss2FDcxkOExoIvEgdI40pU6LMgMoui5Ws++b/AKB/kViFtFw5UlN0duNtwVhSlHRWAioL2g1yNSMF3IsaX/IhfI30XE2e086w0NA9tTTLEZrvhFrkVv09V5MOou1RD/CoH5MP5G+icWbCGUJnyN9FLziXOLp8HNbAEmwfhs+Vvoi5hvwN+UIg9NeT8C8kT4DfhHcFGYI+EdwVhz1EYiQEBhDYO5A5o2DuUr3qB7khg0GxJBfToKPPJOapQGjhqHCoXvPJa0YcSWhCC5hDYbGljXVuENHRpmKb186McQtGRmqEEEhwyoaHsK8vDlrwz0pwvY+lBFOrSjERuoPcvKbC5cRGgMjuJ2P1/uGvELsJe3i4AtcHA5EEEd67YpS2Od5HDcwrBLXW3HJyrF8GgLubegM9ljkOGEGKc/6CvNOT05/7OM/aY3i5dhbtpVlo4pnCeO9pChQbVpmmrFeGjx2Az70dvkvcOSMi4yUE7Wk97nLxKCPvO/yXvXI21ILZOA1xIIhgHvKwUpRVxVm0Ywl9wcWVcNFWc0hdPDnoB98dp/RRTMOC4Gj25HUJrrGvuixvpYy+1nOXynBqteXsUuY01rVrSTUYkgJ28noh2Barq8T9mEulmuP7MgQWnN1EDpRvxeC05mxIjMcKcVTiSjwKnLcQrjnhLaQngml9pTfLbCoXQyp4cStc8HOHyuI+ieq2UjBxKbhTNc1OctJdjyzpOdWlACezAZ7l0NvxbkvFcNIbvEU+q8ZsUF05AO2agjtMVqxy5nGki4YU7bPQonLSC3rMiN/1NiN/4IWcupM5xKdjj9AvU5q1oTP5sVjMD1ntGVNp3rIm+U8lj982JuY0xP8AEFLVn7MU4vZfv/R5Pb1ry8eIHsjwwA0DpG6agk7N6zbw/DfCiO0AiMJ7ASF6Pa3KyVdDiXJWM+jX9ISxo0hp6xI6NN68SlJF7wLsMuHSxFM6CnYDQ9q5s0v5vg7Ond/FcnQR5qO3Bwodl5vqgg2rFYauqNmzvGCll4pENojwiXBscFxbUkvggQana2ICSScjhveM6WdQ3aU9lvNHOUeOaPtNKnCkQCmOtQs9NbpnTrS2aNKS5RmoBxXUyMwyIKtOOo1XAWvZjIR52XfzkA6+9DJ914zpsd2Z5yWbahaQQVcM88cql5Rlk6eGVXHwz0MtCjdRVbOtVsUAOIDvA/qrT4S9GM1JWjzZwcHTI3FROcjewqFzSnZBG9QuUzmKJzUWUiIhJOWJJWM8uupBh0R0T3V4h6xalJwjB1ePqteStN0I3oURor1mEi47iNDvCwHEjA6d6d0QZEVWscjRDimddYlosbHdFiODA69nUgFxrTBbloW/CfDexsVjrzaAAnGumK4GcfRg4jyUMlE6YW31EovtMXhUv8jahGj68V6NYU63mYYBGDQKVFe5eZQndJUph/TdxKazafmhyh3qj3FkxsIRR5g3HYjqu8ivEIVoRG9WI8cHH1V2BykmWggRnEEEEHHPDVV9XF7ojSktme0StpRGMh3YhAuitNgYT9Ffba8Yj+aacV49L8r5kgNowgCgN0jS7nXYVsSlvx2t6QZid/RqqWnLzX6Kcsi9/s9LdbMSoBfXjQ5dihbaTntaXAHAHZpuXm8zylmIeIgg4HGpcMdcMVlO5ZzQ6ILW0FMGbOKl6UHt+ilkytbnqchMAgm43+ZF20/mO3q06K34G9lcPFeNt5VTQFBE1J6ozcST4kpjypmvzT3BJ5Y/ILu+P+/g9G5YPHscamHQ/wCQXiTI1Dhh0ga8FvzNvR4jSx8QlrhQjaCsYQQHXgTWtdPIhZZMik1RUFV2d3yM5Tuh820ycCIWuvc5cbDe7Aj7x4bV3W639IXodoct3NbSHKseQAS0Rrufw1ZQjTTgvEYFrRmCjXgb7jSTxOqJ1uTBcHc4Kg1HQHaDjiCr78bXm7M+yV+qOutLla8QZ1ns1OfhxHvcX05rnbsGg6PTIMRuyq4+ybXcWCHXqgUbXQNa0kcbor2KxEtKZiQojCYZZFbdd0MaXg7CrsDVoWDEk3swrpuHvXtu1Z5ZW7Rthj27I6yHOjEmmynqijNbFhuY0Ma4lpvXRXotutbezDabFyDJpwwNVrSM5vUKbNmkwTFfBddNWu8CNu8KN/XvgNxNcAAOwDALfZEZFbciAEeI3g6KOXshrDVrrw0rmPVLtfoffyKTJbpSvfxXTWdaAc033AEGmJAJwWLDhAKrOzMGFR0WGXVwBArTWmY/YXRhfYzlzrvR1Tpxnxt+YKF89D/MZ8wXJm2ZL8o/L+qibacnUkwjQnDDIUGGe2q6HmXKOXRfDOrdPw/zGfMFE6eh/mM+YLnf4hJH3D3H1Q+2SXw+DvVPWXKDR+GdD7bD/MZ8wTLlI0eDU3G9HTPZvSRq/grRRgpqp0l5R2iqmJTp0AXZ7qdo8lTlzRwVyc6vaqbYZOQWmR/5Ex2NWCTezVOI7pHiVPKSsTs2nTtVhsOGzHruPY2vDMq3FyQivBlS7HIbTkO3RXJSUaTdaL51PVYPVTQ5Z0SheaN2ZDsGi0oMJrRQCg2K4YkJsKVlmtpUgny4BWXsF2pINTSm7eocUUUdED97V0bGZFLT3Nu5t+Veic+yqtTEtCfmBXxWbNwA9u8DBRSE17jzSmAJ03FTdeGDj7RJMWKPccsuPIPbpXgugLCkW7aeKiWOLGm0cs4EZ4ISV0kWUB2fTuWfHsvZ4ehWTxP0WpGUSgc9WY0k4frgfRU4rHNzBHFZNNDNaTxhgba+ahiSRPv94RyXUbw+qsBq2UU0rBSa2MWLLOaK4FNDiq9OdU8CqMkytWniFnOPbsaRne5el5srYkZorEbDpmrkudiUbKZvONRULIt+HWEf6SD9D4Eq1AjqSZaHtLdoI71pdoiqOISRubQkHMYdyEjisBjVTI7mFajhqmLaIAaqSV07EkAFROAk1pOSmhypOaEmxEKlhy7jotCWkt1FYL2NGGJ8FosftkuRAyATm3D+rJSMaxlddmzuUMSYLslLKyZcan98Fru/BIrz34DL95K5LSYbic1PDhhuSkatFHkViDalTA70NUTFYgnORPOlUzcwiedd6YiOFnQ5VxWfPS9017/VXr9CmigFvfVTJWh+yGz5z3HHgdm4rQcxYMaEWGh7CtCz56nQecND9CpT9MUl7RcomIUxHBB2KiUyJ8MHNV3yDTkSPEdyuUTUSKsyYkg4ZCu8YeCrxQ7IZ7xkt2m9C+GDmKqe0dnOCWeAbwOOZoT3FQl4YcG04710RladVxHkq0eVJ6zQ4bvRTKHgaZlkVxGzzTQ41FYMINwFeB0VWZGqwppm92rL0OYBVnncFhQ4i0pSJXBOwRl2m0CITTB2Pr4gqrfW9asnVl6mLcezVc/UaKWIR4pJBqIsOqkACkjpuSRQGtCljwG/0U19jcsT4KlEmr2xAwErotLYyrknjzZO/cMkDIZdn3KSBL1+pWnLQQPVNRcgbohl5Qa93qVdGCEu2J2rVKtiRBShBgnqEwDClwUTQEWCYBsKTm4JoYSdT9lAEUQIxTvQPI3pg5AATLAWka5grMbhgteI3IqlPQ6UcNcCs5oaLNnztOi/LQ7NxWoQuZBWhZ87SjHZe6dm7gnGREo+0apagJRlROIVEoFyCqdzkJckaBBKiEO3FIRNoKBDRIQOYqsGcgFjqHqnqnbu4roL+4qCZbfaW3c+GB0KmcVJFxlRzrmURwYtEEQEEg6KJ76YrlNjaE4LtDsXLRQA43cq4I48yThooFLdgWoMbClBVSXwesO5UmlXYMFzhVpB2jUJptksFqSPm3/CknQrLENgCtwYFc8E8GFRXGLojEybDhsoETnIC9NVaCJAjUbUSYBApwMUCNqBkgTOTApJgGMkxTAYJVQMYoaJ6oSkIkYcKIDsOSBgocyiiYpbobpbGXF6LiMfOo0oU4NVejQS4YYEZbCs5rjlszCy2Ga1nWgB0H5aHZuK1HN1C5daNmWjd6Dzhodm47lal6ZEo+0aLmoCp4p2KBzVVCTEkhSLkFDOw1UbphoBNRgCTQg5LmrfjOdFLScG0oNMQDVZSxlmp1RahZdiT16rnZkk9+XoqkSISgTLnbs1HTJJJAOFPKRbrt2qgSCE6A6AX9/gUljMmngUDiANKpLXvRn2M6NtAjqoaowV0mIaJqEIkDCqiqgqkgCQFGComoqp2MkqnaVGSnqnYElUJKYlAShgHVCU1UxKQBEolHWiJpQATTjRVJ+X98dqsOUzTUKZIEzGBTlHMwrrs8Dko1BRo2daF2jXnDQ7NxWs81xXMFXZGfu0a7q6buO5WpckuPs1HBAVKUDgqEjnOU8DFsQZdU8cx9VgrupmA17S1wqD+6rkbSs50I44tOTvodhXNlj5s2hL0Ukk6ZYliSSSQA6SZJADpJJIA6cImqJpUgK7jlJAU4KjBRBABpwgLkQQMkqmvJkNUAHeTtKjRNQMkLk1VG12CeqACqmKZMSkATk9VHVOCnYEtULX0KZpTOQAc3CvimG0LGD6GhzGe7sWpmRj44dyhn5Udcf3Z96zZSKockkPHwTEoAuyE+W0Y7q6HZ+i1S5c24K7Z09d6DurodicZciaNYqtOQBEY5m0YbjoVaoOwoHBW0JM4SIwgkEUINCEK2uUctRwiDI4HiMvDyWKuKUadG6doSSSSQxJJJIASdMkgDpGo0kl3ejlDCcJJJAJqkakkmN7iKYJJJAOnH0SSQgBZkERSSQMRTFJJADJgkkl7AdqJJJMGCM+1WH5HgkkpYIxmnopN1SSUlMYpzkmSSGbMgehwOCsOSSWsdjMzLcH3Lv7f8guWSSXPm3NobDJJJLEsSSSSAHSSSTA/9k='), fit: BoxFit.cover, )), ); } }
0
mirrored_repositories/MovieListApp
mirrored_repositories/MovieListApp/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:listitem/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0