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
// ignore: avoid_web_libraries_in_flutter | |
import 'dart:html'; | |
import 'dart:ui' as ui; | |
import 'package:flutter/material.dart'; | |
void main() => runApp(WebcamApp()); | |
class WebcamApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) => MaterialApp( |
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:math' as math; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/rendering.dart'; | |
import 'package:flutter/gestures.dart'; | |
import 'package:flutter_issues/custom_scrollable.dart' as custom_scrollable; | |
/// A widget that scrolls. | |
/// | |
/// Scrollable widgets consist of three pieces: |
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:math'; | |
import 'package:flutter/material.dart'; | |
import 'dart:async'; | |
import 'dart:math' as math; | |
import 'dart:ui'; | |
import 'package:flutter/gestures.dart'; | |
import 'package:flutter/rendering.dart'; | |
import 'package:flutter/scheduler.dart'; | |
import 'package:flutter/painting.dart'; |
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:math' as math; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/rendering.dart'; | |
import 'package:flutter/gestures.dart'; | |
import 'package:flutter_issues/custom_scrollable.dart' as custom_scrollable; | |
/// A widget that scrolls. | |
/// | |
/// Scrollable widgets consist of three pieces: |
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:async'; | |
import 'dart:math' as math; | |
import 'dart:ui'; | |
import 'package:flutter/gestures.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/rendering.dart'; | |
import 'package:flutter/scheduler.dart'; | |
import 'package:flutter/painting.dart'; |
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
// Data holders | |
val temperatureData = mutableListOf<Float>() | |
val pressureData = mutableListOf<Float>() | |
val timeData = mutableListOf<Float>() | |
// Convert data from BigQuery JsonTable to data arrays | |
fun processData(tableData: JsonTable) { | |
tableData.rows.forEach { | |
it.f.forEachIndexed { index, element -> | |
when (index) { |
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
// Data classes for JSON deserialization | |
data class JsonTable(@SerializedName("rows") val rows: List<Row>) { | |
data class Row(@SerializedName("f") val f: List<F>) { | |
data class F(@SerializedName("v") val v: String) | |
} | |
} |
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
// Get table | |
fun pullData() { | |
when (token) { | |
"Empty" -> { | |
authenticateAndAuthorize() | |
} | |
else -> { | |
doAsync { | |
val apiCall = gcpService.getTable("Bearer $token", 15).execute() | |
Log.d("JSON", apiCall.body().toString()) |
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
// Retrofit interface | |
interface GCPService { | |
@GET("/bigquery/v2/projects/weather-231121/datasets/WeatherDataSet/tables/WeatherDataTable/data") | |
fun getTable(@Header("Authorization") token: String, @Query("startIndex") startIndex: Int): Call<JsonObject> | |
} | |
// Retrofit builder | |
private val retrofitBuilder = Retrofit.Builder() | |
.baseUrl("https://content.googleapis.com") | |
.addConverterFactory(GsonConverterFactory.create()) |
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
// Access scopes | |
private val accessScope = listOf("https://www.googleapis.com/auth/cloud-platform.read-only") | |
private var token = "Empty" | |
// Receive Google OAuth 2 token for API access | |
private fun authenticateAndAuthorize() { | |
doAsync { | |
val googleCredential = GoogleCredential | |
.fromStream(ctx.assets.open("service-account.json")) | |
.createScoped(accessScope) |
NewerOlder