text
stringlengths 1
474
|
|---|
}
|
bool isEmail(String em) {
|
const String emailRegexp =
|
r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|'
|
r'(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|'
|
r'(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
|
final RegExp regExp = RegExp(emailRegexp);
|
return regExp.hasMatch(em);
|
}
|
@override
|
Widget build(BuildContext context) {
|
return Scaffold(
|
appBar: AppBar(title: const Text('Sample App')),
|
body: Center(
|
child: TextField(
|
onSubmitted: (text) {
|
setState(() {
|
if (!isEmail(text)) {
|
_errorText = 'Error: This is not an email';
|
} else {
|
_errorText = null;
|
}
|
});
|
},
|
decoration: InputDecoration(
|
hintText: 'This is a hint',
|
errorText: _getErrorText(),
|
),
|
),
|
),
|
);
|
}
|
}<code_end>
|
<topic_end>
|
<topic_start>
|
Flutter plugins
|
<topic_end>
|
<topic_start>
|
Interacting with hardware, third party services, and the platform
|
<topic_end>
|
<topic_start>
|
How do I interact with the platform, and with platform native code?
|
Flutter doesn’t run code directly on the underlying platform;
|
rather, the Dart code that makes up a Flutter app is run natively
|
on the device, “sidestepping” the SDK provided by the platform.
|
That means, for example, when you perform a network request in Dart,
|
it runs directly in the Dart context.
|
You don’t use the Android or iOS APIs
|
you normally take advantage of when writing native apps.
|
Your Flutter app is still hosted in a native app’s
|
ViewController or Activity as a view,
|
but you don’t have direct access to this, or the native framework.This doesn’t mean Flutter apps can’t interact with those native APIs,
|
or with any native code you have. Flutter provides platform channels
|
that communicate and exchange data with the
|
ViewController or Activity that hosts your Flutter view.
|
Platform channels are essentially an asynchronous messaging mechanism
|
that bridges the Dart code with the host ViewController
|
or Activity and the iOS or Android framework it runs on.
|
You can use platform channels to execute a method on the native side,
|
or to retrieve some data from the device’s sensors, for example.In addition to directly using platform channels,
|
you can use a variety of pre-made plugins
|
that encapsulate the native and Dart code for a specific goal.
|
For example, you can use a plugin to access
|
the camera roll and the device camera directly from Flutter,
|
without having to write your own integration.
|
Plugins are found on pub.dev,
|
Dart and Flutter’s open source package repository.
|
Some packages might support native integrations on iOS,
|
or Android, or both.If you can’t find a plugin on pub.dev that fits your needs,
|
you can write your own, and publish it on pub.dev.<topic_end>
|
<topic_start>
|
How do I access the GPS sensor?
|
Use the geolocator community plugin.<topic_end>
|
<topic_start>
|
How do I access the camera?
|
The camera plugin is popular for accessing the camera.<topic_end>
|
<topic_start>
|
How do I log in with Facebook?
|
To log in with Facebook, use the
|
flutter_facebook_login community plugin.<topic_end>
|
<topic_start>
|
How do I use Firebase features?
|
Most Firebase functions are covered by first party plugins.
|
These plugins are first-party integrations, maintained by the Flutter team:You can also find some third-party Firebase plugins on pub.dev
|
that cover areas not directly covered by the first-party plugins.<topic_end>
|
<topic_start>
|
How do I build my own custom native integrations?
|
If there is platform-specific functionality that Flutter
|
or its community plugins are missing,
|
you can build your own following the
|
developing packages and plugins page.Flutter’s plugin architecture, in a nutshell,
|
is much like using an Event bus in Android:
|
you fire off a message and let the receiver process and emit a result
|
back to you. In this case, the receiver is code running on the native side
|
on Android or iOS.<topic_end>
|
<topic_start>
|
Themes (Styles)
|
<topic_end>
|
<topic_start>
|
How do I theme my app?
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.