getme() async {
final response = await Dio().get(
"https://oauth.reddit.com/api/v1/me",
options: Options(headers: <String, dynamic>{
'Authorization': 'Bearer $accessToken',
'content-Type': 'application/x-www-form-urlencoded',
}),
);
Map<dynamic, dynamic> result = response.data;
Map<String, dynamic> data = Map<String, dynamic>();
for (dynamic type in result.keys)
data[type.toString()] = result[type];
}
Widget build(BuildContext context) {
return Container(
child:
WebView(
initialUrl: 'https://www.reddit.com/api/v1/authorize.compact?client_id=$client_id&response_type=code&state=test&redirect_uri=$redirect_url&duration=permanent&scope=identity,edit,flair,history,modconfig,modflair,modlog,modposts,modwiki,mysubreddits,privatemessages,read,report,save,submit,subscribe,vote,wikiedit,wikiread',
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (controller) {
controller = controller;
},
navigationDelegate: (NavigationRequest request) {
if (request.url.startsWith("https://")) {
var pos = request.url.lastIndexOf('=');
var code = (pos != -1)
? request.url.substring(pos + 1, request.url.length - 2)
: request.url;
postCode(code);
return NavigationDecision.prevent;
}
return NavigationDecision.navigate;
},
)
);
}
BottomNavigationBar(
backgroundColor: Colors.red[900],
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.list_alt),
label: 'New',
),
BottomNavigationBarItem(
icon: Icon(Icons.people),
label: 'Popular',
),
BottomNavigationBarItem(
icon: Icon(Icons.all_out),
label: 'All',
),
BottomNavigationBarItem(
icon: Icon(Icons.portrait),
label: 'Profile',
),
],
currentIndex: _selectedIndex,
selectedItemColor: Colors.white,
unselectedItemColor: Colors.grey[500],
onTap: _onItemTapped,
),
static ProfileViewPicture(src) { ## Example : Function to display the user's picture
return Container(
child: ClipOval(
child: Image.network(
src,
fit: BoxFit.fill,
width: 256,
height: 256,
),
)
);
}
static ProfileViewRender(name, subscriber, src, hidedowns, over_18, lang, videoAutoplay, hideAds, enableFollowers) { ## Main function to display in window
return Scaffold(
backgroundColor: Colors.white,
body: Center(
child: Column(
children: [
SizedBox(height: 70.0),
ProfileViewPicture(src), ## Call the function
## Call other functions
],
)
)
);
}