A wrapper based on SplitWise
- Feel free to open a PR or Issue
- Uses OAuth 1
- Currently, Data Classes are not included in the Package
- Get the consumerKey and consumerSecret from Splitwise Register App
- Check the example.dart located in example/example.dart
|-- .gitignore |-- .metadata |-- CHANGELOG.md |-- LICENSE |-- README.md |-- example | '-- example.dart |-- lib | '-- splitwise_api.dart '-- pubspec.yaml - Import the package
dependencies: splitwise_api: ^1.0.0- Import in the file
import 'package:splitwise_api/splitwise_api.dart';- Setup SharedPreferences or any other system to save the token and tokenSecret to keep user logged in.
- For Example :-
import 'package:shared_preferences/shared_preferences.dart'; class SplitWiseHelper { saveTokens(String text) async { final prefs = await SharedPreferences.getInstance(); prefs.setString('tokens', text); } getTokens() async { final prefs = await SharedPreferences.getInstance(); prefs.getString('tokens'); } }- Now Use the Wrapper and save the tokens.
- ForExample :-
void main() async { SplitWiseService splitWiseService = SplitWiseService.initialize(_consumerKey, _consumerSecret); SplitWiseHelper splitWiseHelper = SplitWiseHelper(); if (splitWiseHelper.getTokens() == null) { var authURL = splitWiseService.validateClient(); print(authURL); var tokens = await splitWiseService.validateClient(verifier: 'theTokenYouGetAfterAuthorization'); //This Will print the token and also return them save them to Shared Prefs splitWiseHelper.saveTokens(tokens); splitWiseService.validateClient(token: 'tokenYouGet', tokenSecret: 'tokenSecretYouGet'); } else { splitWiseService.validateClient(token: 'FromSaved', tokenSecret: 'FromSaved'); //Example splitWiseService.getCurrentUser(); } }Hit like if it helped