text_span_field_plus 1.0.8 copy "text_span_field_plus: ^1.0.8" to clipboard
text_span_field_plus: ^1.0.8 copied to clipboard

Flutter自定义文本样式输入框,可以让你在TextField中显示不同样式的文本,例如

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:text_span_field_plus/get_text_span.dart';
import 'package:text_span_field_plus/text_span_display.dart';
import 'package:text_span_field_plus/text_span_field_plus.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.pink,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);


  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String text = '';
  String tapString = '';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        
        title: Text('text_span_field_plus演示'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            TextSpanFieldPlus(
              maxLines: null,
              onChanged: (value){
                  setState(() {
                    text = value;
                  });
              },
              rangeStyles: GetTextSpan(text,toUserColor: Colors.pinkAccent,topicColor: Colors.blue).getTextFieldStyle()
            ),
            Container(height:20),
            Text('文本显示:'),
            TextSpanDisplay(
              text: text,
              style: TextStyle(fontSize: 20),
              toUserColor: Colors.pinkAccent,
              topicColor: Colors.blue,
              onTap: (Map value){
                setState(() {
                  tapString = value.toString();
                });
              },
            ),
            Container(height:20),
            Text('你点击了:',style: TextStyle(fontSize: 20),),
            Text(tapString,style: TextStyle(fontSize: 20))
          ],
        ),
      ), 
    );
  }
}
2
likes
25
pub points
0%
popularity

Publisher

verified publisherbanai.com.cn

Flutter自定义文本样式输入框,可以让你在TextField中显示不同样式的文本,例如

Repository (GitHub)
View/report issues

License

BSD-2-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on text_span_field_plus