Last active
March 20, 2020 21:02
-
-
Save loicgeek/e313b762e1e089a13bcc5227debe6b99 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:adoration_divine/bloc/bloc.dart'; | |
import 'package:adoration_divine/repositories/news_repository.dart'; | |
import 'package:adoration_divine/ui/home_page.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_bloc/flutter_bloc.dart'; | |
import 'package:http/http.dart' as http; | |
import 'package:uni_links/uni_links.dart'; // we import unilinks_plugin | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
http.Client client = new http.Client(); | |
NewsRepository newsRepository = NewsRepository(client: client); | |
return MultiBlocProvider( | |
providers: [ | |
BlocProvider<NewsBloc>( | |
builder: (context) { | |
return new NewsBloc(newsRepository: newsRepository) | |
..dispatch(StartLoading()); | |
}, | |
), | |
BlocProvider<NewsFilterBloc>( | |
builder: (context) { | |
return new NewsFilterBloc(newsRepository: newsRepository); | |
}, | |
), | |
], | |
child: MaterialApp( | |
debugShowCheckedModeBanner: false, | |
title: 'Adoration Divine', | |
theme: ThemeData( | |
primaryColor: Colors.red[100], | |
primarySwatch: Colors.red, | |
), | |
//We are building our home according to how our app have started | |
home: StreamBuilder( | |
stream: getLinksStream(), | |
builder: (context , snapshot){ | |
if( snapshot.hasData ) { // our app started by configured links | |
var uri = Uri.parse(snapshot.data); | |
var list =uri.queryParametersAll.entries.toList(); // we retrieve all query parameters , tzd://genius-team.com?product_id=1 | |
return Text(list.map((f)=>f.toString()).join('-')); | |
// we just print all //parameters but you can now do whatever you want, for example open //product details page. | |
}else { // our app started normally | |
return HomePage(); | |
} | |
} , | |
) | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment