Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
dfd42444
Unverified
Commit
dfd42444
authored
Feb 15, 2022
by
Taha Tesser
Committed by
GitHub
Feb 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update `CupertinoTextField` example (#93738)
parent
60f039cb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
28 deletions
+77
-28
cupertino_text_field.0.dart
.../api/lib/cupertino/text_field/cupertino_text_field.0.dart
+57
-0
cupertino_text_field.0.dart
...api/test/cupertino/text_field/cupertino_text_field.0.dart
+16
-0
text_field.dart
packages/flutter/lib/src/cupertino/text_field.dart
+4
-28
No files found.
examples/api/lib/cupertino/text_field/cupertino_text_field.0.dart
0 → 100644
View file @
dfd42444
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flutter code sample for CupertinoTextField
import
'package:flutter/cupertino.dart'
;
void
main
(
)
=>
runApp
(
const
MyApp
());
class
MyApp
extends
StatelessWidget
{
const
MyApp
({
Key
?
key
})
:
super
(
key:
key
);
static
const
String
_title
=
'Flutter Code Sample'
;
@override
Widget
build
(
BuildContext
context
)
{
return
const
CupertinoApp
(
title:
_title
,
home:
MyStatefulWidget
(),
);
}
}
class
MyStatefulWidget
extends
StatefulWidget
{
const
MyStatefulWidget
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
MyStatefulWidget
>
createState
()
=>
_MyStatefulWidgetState
();
}
class
_MyStatefulWidgetState
extends
State
<
MyStatefulWidget
>
{
late
TextEditingController
_textController
;
@override
void
initState
()
{
super
.
initState
();
_textController
=
TextEditingController
(
text:
'initial text'
);
}
@override
void
dispose
()
{
_textController
.
dispose
();
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
CupertinoPageScaffold
(
child:
Center
(
child:
CupertinoTextField
(
controller:
_textController
,
)
),
);
}
}
examples/api/test/cupertino/text_field/cupertino_text_field.0.dart
0 → 100644
View file @
dfd42444
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_api_samples/cupertino/text_field/cupertino_text_field.0.dart'
as
example
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'CupertinoTextField has initial text'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
example
.
MyApp
(),
);
expect
(
find
.
text
(
'initial text'
),
findsOneWidget
);
});
}
packages/flutter/lib/src/cupertino/text_field.dart
View file @
dfd42444
...
...
@@ -139,35 +139,11 @@ class _CupertinoTextFieldSelectionGestureDetectorBuilder extends TextSelectionGe
///
/// {@macro flutter.widgets.EditableText.onChanged}
///
///
To control the text that is displayed in the text field, use the
///
[controller]. For example, to set the initial value of the text field, use
/// a [controller] that already contains some text
such as:
///
{@tool dartpad}
///
This example shows how to set the initial value of the `CupertinoTextField` using
/// a [controller] that already contains some text
.
///
/// {@tool snippet}
///
/// ```dart
/// class MyPrefilledText extends StatefulWidget {
/// const MyPrefilledText({Key? key}) : super(key: key);
///
/// @override
/// State<MyPrefilledText> createState() => _MyPrefilledTextState();
/// }
///
/// class _MyPrefilledTextState extends State<MyPrefilledText> {
/// late TextEditingController _textController;
///
/// @override
/// void initState() {
/// super.initState();
/// _textController = TextEditingController(text: 'initial text');
/// }
///
/// @override
/// Widget build(BuildContext context) {
/// return CupertinoTextField(controller: _textController);
/// }
/// }
/// ```
/// ** See code in examples/api/lib/cupertino/text_field/cupertino_text_field.0.dart **
/// {@end-tool}
///
/// The [controller] can also control the selection and composing region (and to
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment