Some components of flutter contact demo

Some components of flutter contact demo

flutter_demo .Some components of flutter contact demo

Flutter in action

routing

Routing table

static Map<String, WidgetBuilder> configRoutes = {
  TipRoute.rName: (context) => TipRoute(text: ModalRoute.of(context).settings.arguments,)
};

Pass parameters to named routes

Navigator.of(context).pushNamed("new_page", arguments: "hi");

Register routing table

MaterialApp(
  title: 'Flutter Demo',
  theme: ThemeData(
    primarySwatch: Colors.blue,
  ),
  //注册路由表
  routes: configRoutes,
  home: MyHomePage(title: 'Flutter Demo Home Page'),
);

Exception catch

  /// [ 异常捕获 ]
  FlutterError.onError = (FlutterErrorDetails details) {
    LogUtil.e("[ FlutterError.onError ] = ", details.library, details);
  };

  runZoned(() {
    runApp(MyApp());
  }, onError: (Object obj, StackTrace stack) {
    LogUtil.e("[ runZoned onError ] = ", obj, stack);
  });

State life cycle

initState

It will be called when the Widget is inserted into the Widget tree for the first time. For each State object, the Flutter framework will only call this callback once. Therefore, some one-time operations are usually performed in this callback, such as state initialization and sub-tree subscription. Event notifications, etc. You cannot call BuildContext.inheritFromWidgetOfExactType in this callback (this method is used to get the nearest parent InheritFromWidget on the Widget tree to the current widget. We will introduce InheritedWidget in a later chapter), because after the initialization is completed, the InheritFromWidget may also change, so the correct approach should be to call it in the build() method or didChangeDependencies(). didChangeDependencies(): It will be called when the dependency of the State object changes; for example: an InheritedWidget is included in the previous build(), and then the InheritedWidget changes in the subsequent build(), then the child widget of the InheritedWidget The didChangeDependencies() callback will be called. A typical scenario is that when the system language Locale or application theme changes, the Flutter framework will notify the widget to call this callback.

build()

Readers of this callback should be quite familiar by now. It is mainly used to build Widget subtrees and will be called in the following scenarios:

  • After calling initState().
  • After calling didUpdateWidget().
  • After calling setState().
  • After calling didChangeDependencies().
  • After the State object is removed from one position in the tree (deactivate is called), it is reinserted into another position in the tree.

reassemble()

This callback is specifically provided for development and debugging, and will be called during hot reload. This callback will never be called in Release mode.

didUpdateWidget()

When the widget is rebuilt, the Flutter framework will call Widget.canUpdate to detect the new and old nodes in the same position in the Widget tree, and then determine whether it needs to be updated. If Widget.canUpdate returns true, this callback will be called. As mentioned before, Widget.canUpdate will return true when the key and runtimeType of the old and new widgets are equal at the same time, which means didUpdateWidget() will be called when the key and runtimeType of the old and new widgets are equal at the same time.

deactivate()

This callback is called when the State object is removed from the tree. In some scenarios, the Flutter framework will reinsert the State object into the tree, such as when the subtree containing this State object moves from one position of the tree to another (which can be implemented through GlobalKey). If it is not reinserted into the tree after removal, the dispose() method will be called immediately.

dispose()

Called when the State object is permanently removed from the tree; resources are usually released in this callback.

Download Details:

Author: wuweijian1997

Source Code: https://github.com/wuweijian1997/flutter_demo

flutter dart mobile-apps

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Google's Flutter 1.20 stable announced with new features - Navoki

Google has announced new flutter 1.20 stable with many improvements, and features, enabling flutter for Desktop and Web

Top 25 Flutter Mobile App Templates in 2020

Flutter has been booming worldwide from the past few years. While there are many popular mobile app development technologies out there, Flutter has managed to leave its mark in the mobile application development world. In this article, we’ve curated the best Flutter app templates available on the market as of July 2020.

Flutter App Development Trends 2020

As the new decade dawns upon us, a slew of technologies has been making a lot of noise to grab the developers’ attention. While native app development is going strong, the trade winds are now blowing towards going cross-platform.

How To Succeed In Mobile App Wireframe Design?

This article covers everything about mobile app wireframe design: what to do and what not, tools used in designing a mobile or web app wireframe, and more.

Top 10 Mobile App Development Companies in India

The mobile application scenario has been continually changing over the years. In recent years India has become a center for mobile app development companies. The increase of smartphones has instantly increased the requirements for these apps. Every year new technological trends occur due to contin