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 _MyHomePageState extends State<MyHomePage> { | |
final GlobalKey sliderKey = GlobalKey(); | |
// ... | |
static const platform = const MethodChannel('sample/gesture'); | |
@override | |
void initState() { | |
super.initState(); |
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:convert'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/services.dart'; | |
void main() { | |
runApp(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
class MainActivity : FlutterActivity() { | |
companion object { | |
private const val CHANNEL = "sample/gesture"; | |
} | |
override fun configureFlutterEngine(flutterEngine: FlutterEngine) { | |
super.configureFlutterEngine(flutterEngine) | |
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL) | |
.setMethodCallHandler { call, result -> |
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
private void setSystemGestureExclusionRects(ArrayList<Rect> rects) { | |
if (Build.VERSION.SDK_INT < 29) { | |
return; | |
} | |
Window window = activity.getWindow(); | |
View view = window.getDecorView(); | |
view.setSystemGestureExclusionRects(rects); | |
} |
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 MyTextPainter extends CustomPainter { | |
final TextSpan text; | |
final int maxLines; | |
final String ellipsis; | |
MyTextPainter({this.text, this.ellipsis, this.maxLines}) : super(); | |
@override | |
bool shouldRepaint(CustomPainter oldDelegate) => false; |
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 _ExpandableTextState extends State<ExpandableText> { | |
static const String _ellipsis = "\u2026\u0020"; | |
String get _lineEnding => "$_ellipsis${widget.moreSpan.text}"; | |
// ... | |
@override | |
Widget build(BuildContext context) => LayoutBuilder( | |
builder: (context, constraints) { | |
final maxLines = widget.maxLines; |
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
extension _TextMeasurer on RichText { | |
List<TextBox> measure(BuildContext context, Constraints constraints) { | |
final renderObject = createRenderObject(context)..layout(constraints); | |
return renderObject.getBoxesForSelection( | |
TextSelection( | |
baseOffset: 0, | |
extentOffset: text.toPlainText().length, | |
), | |
); | |
} |
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 ExpandableText extends StatefulWidget { | |
final TextSpan textSpan; | |
final TextSpan moreSpan; | |
final int maxLines; | |
const ExpandableText({ | |
Key key, | |
this.textSpan, | |
this.maxLines, | |
this.moreSpan, |
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 ExpandableText extends StatefulWidget { | |
final String text; | |
final int maxLines; | |
const ExpandableText({Key key, this.maxLines, this.text}) : super(key: key); | |
@override | |
_ExpandableTextState createState() => _ExpandableTextState(); | |
} |
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 MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val list = findViewById<RecyclerView>(R.id.list) | |
val adapter = MultiTypeAdapter() | |
list.layoutManager = LinearLayoutManager(this) |