void main() {
var a = method();
print (a);
}
Widget method() {
Widget a1 = Builder(
builder: (context) => RichText(
text: TextSpan(
text: 'Some text ',
style: DefaultTextStyle.of(context).style,
children: <TextSpan>[
TextSpan(
text: 'red text',
style: TextStyle(
fontWeight: FontWeight.bold,
backgroundColor:
Colors.red,
),
),
TextSpan(text: ' world!'),
],
),
),
);
return a1
}
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: a1(),
),
);
}
}
Widget a1() {
return RichText(
text: TextSpan(
children: <TextSpan>[
TextSpan(
text: 'red text',
style: TextStyle(
fontWeight: FontWeight.bold,
backgroundColor:
Colors.red,
),
),
TextSpan(text: ' world!'),
],
),
);
}