TextSpan
snippet.packages.flutter.lib.src.painting.text_span.126.
// ignore_for_file: directives_ordering
// ignore_for_file: unnecessary_import
// ignore_for_file: unused_import
// ignore_for_file: unused_element
// ignore_for_file: unused_local_variable
import 'dart:async';
import 'dart:convert';
import 'dart:math' as math;
import 'dart:typed_data';
import 'dart:ui' as ui;
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/painting.dart';
import 'package:flutter/physics.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/semantics.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/animation.dart';
import 'package:flutter/services.dart';
// From: packages/flutter/lib/src/painting/text_span.dart:126
class BuzzingText extends StatefulWidget {
const BuzzingText({Key? key}) : super(key: key);
@override
State createState() => _BuzzingTextState();
}
class _BuzzingTextState extends State {
late LongPressGestureRecognizer _longPressRecognizer;
@override
void initState() {
super.initState();
_longPressRecognizer = LongPressGestureRecognizer()
..onLongPress = _handlePress;
}
@override
void dispose() {
_longPressRecognizer.dispose();
super.dispose();
}
void _handlePress() {
HapticFeedback.vibrate();
}
@override
Widget build(BuildContext context) {
return Text.rich(
TextSpan(
text: 'Can you ',
style: const TextStyle(color: Colors.black),
children: [
TextSpan(
text: 'find the',
style: const TextStyle(
color: Colors.green,
decoration: TextDecoration.underline,
decorationStyle: TextDecorationStyle.wavy,
),
recognizer: _longPressRecognizer,
mouseCursor: SystemMouseCursors.precise,
),
const TextSpan(
text: ' secret?',
),
],
),
);
}
}
SHARE: