@@ -2,34 +2,31 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [EditableText.onChanged].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [EditableText.onChanged].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const OnChangedExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class OnChangedExampleApp extends StatelessWidget {
|
||||
const OnChangedExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: OnChangedExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class OnChangedExample extends StatefulWidget {
|
||||
const OnChangedExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<OnChangedExample> createState() => _OnChangedExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _OnChangedExampleState extends State<OnChangedExample> {
|
||||
final TextEditingController _controller = TextEditingController();
|
||||
|
||||
@override
|
||||
|
||||
@@ -2,23 +2,20 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for EditableText.onContentInserted
|
||||
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [EditableText.onContentInserted].
|
||||
|
||||
void main() => runApp(const KeyboardInsertedContentApp());
|
||||
|
||||
class KeyboardInsertedContentApp extends StatelessWidget {
|
||||
const KeyboardInsertedContentApp({super.key});
|
||||
|
||||
static const String _title = 'Keyboard Inserted Content Sample';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: KeyboardInsertedContentDemo(),
|
||||
);
|
||||
}
|
||||
@@ -62,10 +59,8 @@ class _KeyboardInsertedContentDemoState extends State<KeyboardInsertedContentDem
|
||||
},
|
||||
),
|
||||
),
|
||||
if (bytes != null)
|
||||
const Text("Here's the most recently inserted content:"),
|
||||
if (bytes != null)
|
||||
Image.memory(bytes!),
|
||||
if (bytes != null) const Text("Here's the most recently inserted content:"),
|
||||
if (bytes != null) Image.memory(bytes!),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -2,34 +2,31 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flutter code sample for [TextEditingController].
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() => runApp(const MyApp());
|
||||
/// Flutter code sample for [TextEditingController].
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
void main() => runApp(const TextEditingControllerExampleApp());
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
class TextEditingControllerExampleApp extends StatelessWidget {
|
||||
const TextEditingControllerExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
home: TextEditingControllerExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyStatefulWidget extends StatefulWidget {
|
||||
const MyStatefulWidget({super.key});
|
||||
class TextEditingControllerExample extends StatefulWidget {
|
||||
const TextEditingControllerExample({super.key});
|
||||
|
||||
@override
|
||||
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
|
||||
State<TextEditingControllerExample> createState() => _TextEditingControllerExampleState();
|
||||
}
|
||||
|
||||
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
class _TextEditingControllerExampleState extends State<TextEditingControllerExample> {
|
||||
final TextEditingController _controller = TextEditingController();
|
||||
|
||||
@override
|
||||
@@ -39,8 +36,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
|
||||
final String text = _controller.text.toLowerCase();
|
||||
_controller.value = _controller.value.copyWith(
|
||||
text: text,
|
||||
selection:
|
||||
TextSelection(baseOffset: text.length, extentOffset: text.length),
|
||||
selection: TextSelection(baseOffset: text.length, extentOffset: text.length),
|
||||
composing: TextRange.empty,
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user