import 'package:flutter/material.dart';
void main() { runApp(SomeWidget()); }
class SomeWidget extends StatefulWidget { @override State createState() => SomeWidgetState(); }
import 'package:flutter/material.dart';
void main() { runApp(SomeWidget()); }
class SomeWidget extends StatefulWidget { @override State createState() => SomeWidgetState(); }
mport 'package:flutter/material.dart'; | |
void main() { runApp(SomeWidget()); } | |
class SomeWidget extends StatefulWidget { @override State createState() => SomeWidgetState(); } | |
class SomeWidgetState extends State { int count = 0; | |
void incrementCount() => setState(() => count++); |
import React, {useState, useEffect} from 'react'; | |
const FlashCardGame = () => { | |
const [score, setScore] = useState(0); | |
const [quesNum, setQuesNum] = useState(0); | |
const [questions, setQuestions] = useState([]); | |
useEffect(() => { | |
generateQuestions(); |
// Controller | |
class TodoController { | |
constructor(api) { | |
this.api = api; | |
} | |
async getAllTodos() { | |
const todos = await this.api.getAllTodos(); | |
return todos; | |
} |
Write a TODO app in FLutter using a Rest API to read and write data. Encapsulate business logic in a dedicated controller class. | |
//Imports | |
import 'package:flutter/material.dart'; | |
import 'package:http/http.dart' as http; | |
import 'dart:convert'; | |
//Todo Controller class | |
class TodoController { | |
//Get all todos |
#!/bin/bash | |
flutter clean | |
rm -rf $FLUTTER_ROOT/.pub-cache | |
rm -rf $HOME/Library/Caches/CocoaPods | |
rm -rf ios/Pods | |
rm -rf ios/build | |
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache" | |
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache" | |
rm -rf ~/Library/Developer/Xcode/DerivedData/ | |
rm -rf ~/Library/Caches/com.apple.dt.Xcode/ |
import 'package:flutter/material.dart'; | |
import 'package:flutter/rendering.dart'; | |
/// Click the content to expand / constact the card. | |
/// These overflow warnings are not helpful, and impact developer efficiency and joy. | |
// It would be nice to turn them off for this specific widget. | |
void main() { | |
runApp(MyApp()); | |
} |
import 'dart:math'; | |
import 'package:flutter/material.dart'; | |
int _seed = DateTime.now().millisecondsSinceEpoch; | |
/// Globally accessible instance of `Random`. | |
/// Makes using random values as easy as `rnd(20)` or `rnd.getBool()`. | |
Random rnd = Random(_seed); | |
/// Sets the seed of the `rnd` global `Random` instance. |
/// 1. The public facing widget, configuration options live here | |
class MyWidget extends StatefulWidget { | |
@override | |
_MyWidgetState createState() => _MyWidgetState(); | |
} | |
/// 2. The state / controller / bloc / view controller | |
/// event handlers and helper methods can live here | |
class _MyWidgetState extends State<MyWidget> { | |
void _handlePressed() => print('todo'); | |
@override |
class Benchmark extends StatefulWidget { | |
const Benchmark({Key? key}) : super(key: key); | |
@override | |
_BenchmarkState createState() => _BenchmarkState(); | |
} | |
class _BenchmarkState extends State<Benchmark> { | |
double _tweenSliderValue = .2; | |
bool _enableRendering = false; | |
bool _useGTween = false; |