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_test/flutter_test.dart'; | |
typedef FinderSelector = Finder Function(Finder); | |
FinderSelector firstChild = (Finder finder) => finder.first; | |
FinderSelector lastChild = (Finder finder) => finder.last; | |
FinderSelector childAt(int index) => (Finder finder) => finder.at(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
import 'dart:math' show Random; | |
import 'package:riverpod/riverpod.dart'; | |
/// Function signature to compute a new state value for [TransitionalStateNotifier] | |
typedef StateComputation<T> = Future<T> Function(); | |
/// A [StateNotifier] that safely handles transitions between states | |
/// Especially useful when state computation is a costly async operation, | |
/// and there may be more frequent requests to update the state than | |
/// the previous states |
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 UiState { | |
final int originalValue; | |
final int? computedValue; | |
UiState({required this.originalValue, this.computedValue}); | |
UiState.empty() | |
: originalValue = 0, | |
computedValue = null; |
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 'package:flutter_riverpod/flutter_riverpod.dart'; | |
final counter = StateProvider<int>((ref) => 0); | |
void main() { | |
runApp(ProviderScope(child: MyApp())); | |
} | |
class MyApp extends StatelessWidget { |
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 'package:flutter_riverpod/flutter_riverpod.dart'; | |
final counter = StateProvider<int>((ref) => 0); | |
void main() { | |
runApp(ProviderScope(child: MyApp())); | |
} | |
class MyApp extends StatelessWidget { |
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 'package:flutter_riverpod/flutter_riverpod.dart'; | |
import 'dart:async' show Timer; | |
import 'dart:math' show Random; | |
class ExpensiveNotifier extends StateNotifier<int> { | |
final rnd = Random(); | |
ExpensiveNotifier() : super(0); | |
Future<void> update(int updateCount) async { |
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 'package:flutter_riverpod/flutter_riverpod.dart'; | |
final counter = StateProvider<int>((_) => 0); | |
void main() { | |
runApp(ProviderScope(child: MyApp())); | |
} | |
class MyApp extends StatelessWidget { |
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
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | |
// for details. All rights reserved. Use of this source code is governed by a | |
// BSD-style license that can be found in the LICENSE file. | |
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override |
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
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | |
// for details. All rights reserved. Use of this source code is governed by a | |
// BSD-style license that can be found in the LICENSE file. | |
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override |
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
local function verbatim(s) | |
s = string.gsub(s, "%%", "%%%%") | |
return s | |
end | |
local function set_custom_prompt() | |
-- get_cwd() is differently encoded than the clink.prompt.value, so everything other than | |
-- pure ASCII will get garbled. So try to parse the current directory from the original prompt | |
-- and only if that doesn't work, use get_cwd() directly. | |
-- The matching relies on the default prompt which ends in X:\PATH\PATH> |
NewerOlder