This file contains 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
class HomeScreen extends StatefulWidget { | |
HomeScreen(); | |
@override | |
_HomeScreenState createState() { | |
return _HomeScreenState(); | |
} | |
} | |
class _HomeScreenState extends State<HomeScreen> { |
This file contains 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
enum PostBlocAction {FetchPosts} | |
class PostBloc{ | |
//This StreamController is used to update the state of widgets | |
PublishSubject<PostResponse> _stateStreamController = new PublishSubject(); | |
StreamSink<PostResponse> get _postSink => _stateStreamController.sink; | |
Stream<PostResponse> get postStream => _stateStreamController.stream; | |
//user input event StreamController |
This file contains 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
static Future<FacebookModel> getFbUserData(String fbtoken) async { | |
//String url1 = "https://graph.facebook.com/${user_id}?fields=name,first_name,last_name,email,&access_token=${fbtoken}"; | |
String url = | |
'https://graph.facebook.com/v8.0/me?fields=name,first_name,last_name,email&access_token=${fbtoken}'; | |
var request = new http.MultipartRequest("GET", Uri.parse(url)); | |
try { | |
final response = await request.send().timeout(Duration(seconds: timeout)); | |
final respStr = await response.stream.bytesToString(); |
This file contains 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
// To parse this JSON data, do | |
// | |
// final postResponse = postResponseFromJson(jsonString); | |
import 'dart:convert'; | |
PostResponse postResponseFromJson(String str) => PostResponse.fromJson(json.decode(str)); | |
String postResponseToJson(PostResponse data) => json.encode(data.toJson()); |
This file contains 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 'dart:convert'; | |
StoreData storeDataFromJson(String str) => StoreData.fromJson(json.decode(str)); | |
String storeDataToJson(StoreData data) => json.encode(data.toJson()); | |
class StoreData { | |
bool success; | |
Store store; |
This file contains 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
{ | |
"success": true, | |
"store": { | |
"id": "1", | |
"store_name": "Restro App", | |
"location": "1906 Van Ness Ave", | |
"city": "San Francisco", | |
"state": "California", | |
"country": "United States", | |
"timezone": "America/Adak", |
This file contains 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
//Why don't you keep the created typface object in memory so that you don't create every time the text view is getting created. | |
//Following is a sample class that creates and cache the typeface object: | |
public class TypeFaceProvider { | |
public static final String TYPEFACE_FOLDER = "fonts"; | |
public static final String TYPEFACE_EXTENSION = ".ttf"; | |
private static Hashtable<String, Typeface> sTypeFaces = new Hashtable<String, Typeface>( |
This file contains 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
// called in a standard activity, use ContextCompat.checkSelfPermission for AppCompActivity | |
int permissionCheck = checkSelfPermission(this, Manifest.permission.WRITE_CALENDAR); | |
if (!permissionCheck == PackageManager.PERMISSION_GRANTED) { | |
// User may have declined earlier, ask Android if we should show him a reason | |
if (shouldShowRequestPermissionRationale(thisActivity, Manifest.permission.WRITE_CALENDAR)) { | |
// show an explanation to the user | |
// Good practise: don't block thread after the user sees the explanation, try again to request the permission. | |
} else { | |
// request the permission. |
This file contains 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
public class PolarChartActivity extends AppCompatActivity { | |
private ChartsPolar polar; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_chart_common); | |
AnyChartView anyChartView = findViewById(R.id.any_chart_view); |
This file contains 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
// Note that a shortcut is created automagically if the app is installed via Play store. | |
// Change "APP_NAME" by your app name. *MrObvious* | |
/*Manifest file - add this */ | |
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> | |
/* MainActivity.java */ | |
public class MainActivity ... { | |
... | |
private SharedPreferences appSettings; |
NewerOlder