Farmers in yards world, beautiful application experience, from the programmer for the processing of detail, and self requirements state, agriculture in the yard a member of the young people is busy, every day, every week, can leave some footprints, is the creation of content, there is a persistent, is I don’t know why, if you lost, might as well to Chou Chou code track of farmers.
- Beautiful musical beats take you through the coding process of this effect
- Insist on every day, is the pursuit of every ideal youth
- Follow in the footsteps of young people, and maybe your answer is right here
- Take a look here if you’re confused
In 2020, I summarized the use of Bloc, Provider and Stream cross-component communication. If you are interested, you can take a look
-
The Flutter Provider communicates asynchronously and manages the Provider status
-
BLoC asynchronous communication, basic use of BlocBuilder, preliminary study of BlocProvider
-
A countdown feature implemented by Flutter StreamBuilder
-
The Flutter StreamBuilder updates data asynchronously
-
The Flutter StreamController communicates asynchronously and the Streamr stream communicates asynchronously
-
Flutter ValueNotifier communicates asynchronously and ValueListenableBuilder updates data asynchronously
In 2021, the Provider will be expanded to 5.0, making it more convenient to use, so I re-recorded a tutorial, you can click here to see [netease Cloud Video Courses]; Of course, you can also pay attention to the public account (Biglead), video tutorials are first broadcast in the public account for free, there will be technical content released every day.
In Flutter development, cross-component communication and data updates are often referred to as state management. GetX is a lightweight framework for state management. This section describes the basic use of GetX.
In early April 2021, we used GetX extensively in application development. So far, it seems that the results are good, so I recently published a set of GetX from the beginning to the source principle analysis tutorial, welcome everyone to pay attention to the update.
The first step uses GetMaterialApp
// Program entry
void main(a) {
runApp(RootApp());
}
class RootApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Use GetX first step
return GetMaterialApp(
theme: ThemeData(
primarySwatch: Colors.blue,
),
// The default home page is displayedhome: MyHomePage(), ); }}Copy the code
GetMaterialApp is important for routing, snackbar, internationalization, bottomSheet, dialogs, and high-level apis related to routing and without context. It is just a Widget, Its child component is the default MaterialApp.
The second step defines the Controller
import 'package:get/get.dart';
// the first step is to define the Controller
class CountController extends GetxController{
int _count=0;
int get count=>_count;
void add(a){ _count++; update(); }}Copy the code
The third step is to manipulate data and display data
You don’t even need to use the StatefulWidget. Here’s the code:
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Counter"),
),
backgroundColor: Colors.white,
body: Center(
// Use GetBuilder to get data
child: GetBuilder<CountController>(
/ / bind Controller
init: CountController(),
builder: (CountController controller) {
return Text(${controller.count});
},
),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {
// The third step is to use the find call method to communicateGet.find<CountController>().addCount2(); },),); }}Copy the code
The completion of
Not limited to thinking, not limited to language restrictions, is the highest realm of programming.
With xiaobian character, must be to record a set of video, and then upload
If you are interested, you can follow the public account Biglead to get the latest sharing