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
val result = recognizer.processImage(image) | |
.addOnSuccessListener { result -> | |
// Task completed successfully | |
// Text recognition results | |
val resultText = result.text | |
// `FirebaseVisionText` is made of `TextBlock`s... | |
for (block in result.textBlocks) { | |
// ...and each `TextBlock` has | |
// text, confidence level, list of recognized languages and corner points and frame in which the text was detected... | |
val blockText = block.text |
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
recognizer.process(visionImage) { result, error in | |
guard error == nil, let result = result else { | |
// ... | |
return | |
} | |
// Text recognition results | |
let resultText = result.text | |
// `VisionText` is made of `VisionTextBlock`s... | |
for block in resultText.blocks { |
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 'package:flutter/material.dart'; | |
import 'dart:async'; | |
import 'dart:convert'; | |
import 'dart:math'; | |
import 'package:http/http.dart' as http; | |
import 'about_screen.dart'; | |
import 'quote.dart'; | |
void main() => runApp(KutInApp()); |
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
Future<void> getQuote() async { | |
String baseUrl = 'http://api.kanye.rest/'; | |
try { | |
http.Response response = await http.get(baseUrl); | |
var myQuote = Quote.fromJson(jsonDecode(response.body)); | |
setState(() { | |
_quote = myQuote.quote; | |
_gradientColors.shuffle(_random); | |
_colorOne = _gradientColors[0]; | |
_colorTwo = _gradientColors[1]; |
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
List<Color> _gradientColors = [ | |
const Color(0xfff44336), | |
const Color(0xffba000d), | |
const Color(0xff9c27b0), | |
const Color(0xff6a0080), | |
const Color(0xff2196f3), | |
const Color(0xff0069c0), | |
const Color(0xfffdd835), | |
const Color(0xffc6a700) | |
]; |
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 Quote { | |
final String quote; | |
final String id; | |
Quote.fromJson(Map<String, dynamic> json) | |
: quote = json['quote'], | |
id = json['id']; | |
} |
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
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<!--reds--> | |
<color name="md_red_50">#FFEBEE</color> | |
<color name="md_red_100">#FFCDD2</color> | |
<color name="md_red_200">#EF9A9A</color> | |
<color name="md_red_300">#E57373</color> | |
<color name="md_red_400">#EF5350</color> | |
<color name="md_red_500">#F44336</color> |
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
private fun createActivityAction(): SliceAction? { | |
// (1) Create a SliceAction as follows. | |
return SliceAction.create( | |
/* (2) | |
** Pass in a PendingIntent, | |
** icon to display on the slice, | |
** size of the icon, and | |
** and the title of the action, | |
** to handle the on-click action for a Slice. | |
*/ |
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
override fun onBindSlice(sliceUri: Uri): Slice? { | |
// (1) Create a Context variable. | |
val context = context ?: return null | |
// (2) Create the SliceAction to handle clicks on the Slice. | |
val activityAction = createActivityAction() ?: return null | |
// (3) Handle the Uris for returning the Slices here. | |
return if (sliceUri.path == "/hello") { | |
// Uri's path is recognized as "hello". | |
// Note: ANR and StrictMode are enforced here so don't do any heavy operations. |
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
<provider | |
android:name=".MySliceProvider" | |
android:authorities="com.bapspatil.slicesplayground" | |
android:exported="true"> | |
<intent-filter> | |
<action android:name="android.intent.action.VIEW" /> | |
<category android:name="android.app.slice.category.SLICE" /> | |
<data | |
android:host="bapspatil.com" | |
android:pathPrefix="/hello" |
NewerOlder