This file contains hidden or 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 React, {useState, useEffect} from 'react'; | |
| const FlashCardGame = () => { | |
| const [score, setScore] = useState(0); | |
| const [quesNum, setQuesNum] = useState(0); | |
| const [questions, setQuestions] = useState([]); | |
| useEffect(() => { | |
| generateQuestions(); |
This file contains hidden or 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
| // Controller | |
| class TodoController { | |
| constructor(api) { | |
| this.api = api; | |
| } | |
| async getAllTodos() { | |
| const todos = await this.api.getAllTodos(); | |
| return todos; | |
| } |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| #!/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/ |
This file contains hidden or 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 '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()); | |
| } |
This file contains hidden or 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'; | |
| 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. |
This file contains hidden or 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
| /// 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 |
This file contains hidden or 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 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; |
This file contains hidden or 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
| /// Example usage | |
| /// | |
| /// One shot: | |
| // GTweener.fade(from: .9, to: 1, child: const FlutterLogo()), | |
| /// | |
| /// Or use a key for future control | |
| // final _tweenKey = GlobalKey<GTweenerState>(); | |
| // ... | |
| // return GTweener.fade(key: _tweenKey, child: const FlutterLogo()), |
This file contains hidden or 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 UrlRouter extends RouterDelegate<String> with ChangeNotifier, PopNavigatorRouterDelegateMixin { | |
| UrlRouter({String url = '/', this.onGeneratePages, this.builder, this.onPopPage, this.onChanging}) { | |
| _initialUrl = url; | |
| assert(onGeneratePages != null || builder != null, | |
| 'UrlRouter expects you to implement `builder` or `onGeneratePages` (or both)'); | |
| } | |
| /// This delegat analagous to MaterialApp.routes / onGenerateRoute | |
| final List<Page<dynamic>> Function(UrlRouter router)? onGeneratePages; |