स्निपेट·मुफ़्त
Dart और Flutter स्निपेट
20 Dart और Flutter स्निपेट: initState और dispose, Scaffold, FutureBuilder और StreamBuilder, ListView.builder, नेविगेशन, डायलॉग और SnackBar, copyWith वाला JSON मॉडल, और यूनिट व विजेट टेस्ट।
मुफ़्त में इंस्टॉल करें।
अगर आपके Android डिवाइस पर PocketCode इंस्टॉल है, तो यह पेज ऐप में खुलेगा।
प्रीव्यू
20 में से 5
initStateinitst
Set up a State object once, before the first build
@override
void initState() {
super.initState();
$0
}disposedisp
Release controllers when the widget leaves the tree
@override
void dispose() {
${1:_controller}.dispose();
super.dispose();
}Scaffold with an app barscaff
Screen skeleton with a title bar and a body
Scaffold(
appBar: AppBar(title: const Text('${1:Title}')),
body: ${2:const Placeholder()},
)FutureBuilderfutbuild
Show a spinner, the error or the result of a Future
FutureBuilder<${1:String}>(
future: ${2:_future},
builder: (context, snapshot) {
if (snapshot.connectionState != ConnectionState.done) {
return const CircularProgressIndicator();
}
if (snapshot.hasError) {
return Text(snapshot.error.toString());
}
return Text(${3:snapshot.data ?? ''});
},
)StreamBuilderstreambld
Rebuild every time a Stream emits a value
StreamBuilder<${1:int}>(
stream: ${2:_counter},
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const CircularProgressIndicator();
}
return Text(${3:snapshot.data.toString()});
},
)1.0.0 में बदलाव
पहला संस्करण।