Skip to content

Instantly share code, notes, and snippets.

@abhaysood
abhaysood / main.dart
Created October 4, 2021 02:57
semantic_announcement_tester sample tests
testWidgets('One announcement', (WidgetTester tester) async {
final mock = MockSemanticAnnouncements(tester);
const expectedAnnouncement = AnnounceSemanticsEvent(
"Announcement made",
TextDirection.ltr,
);
await tester.pumpWidget(const MyApp());
// Tap to trigger an announcement
await tester.tap(find.byType(ElevatedButton));
expect(
@abhaysood
abhaysood / main.dart
Last active October 4, 2021 04:56
Trigger semantics action in widget tests (medium_blog)
import 'package:flutter/material.dart';
class MyApp extends StatelessWidget {
static const String label = "Hello World!";
void _showSnackbar(BuildContext context, String message) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(message),
duration: const Duration(milliseconds: 1500),
@abhaysood
abhaysood / draggable_scrollable_sheet.dart
Created February 11, 2022 06:11
Draggable scrollable sheet with static content on bottom
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
static const String _title = 'Flutter Code Sample';
@override
@abhaysood
abhaysood / inner_shadow_custom_paint.dart
Created March 7, 2022 07:17
Drawing a inner shadow using custom paint along a path
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
static const String _title = 'Flutter Code Sample';
@override