Showing
1 changed file
with
93 additions
and
84 deletions
@@ -634,7 +634,8 @@ List get list => _list.value; | @@ -634,7 +634,8 @@ List get list => _list.value; | ||
634 | ``` | 634 | ``` |
635 | ```dart | 635 | ```dart |
636 | ListView.builder ( | 636 | ListView.builder ( |
637 | -itemCount: list.lenght | 637 | + itemCount: list.lenght |
638 | +) | ||
638 | ``` | 639 | ``` |
639 | You could add an existing list of another type to the observable list using a list.assign (oldList); or the assignAll method, which differs from add, and addAll, which must be of the same type. All existing methods in a list are also available on GetX. | 640 | You could add an existing list of another type to the observable list using a list.assign (oldList); or the assignAll method, which differs from add, and addAll, which must be of the same type. All existing methods in a list are also available on GetX. |
640 | 641 | ||
@@ -700,14 +701,16 @@ To define routes, use GetMaterialApp: | @@ -700,14 +701,16 @@ To define routes, use GetMaterialApp: | ||
700 | 701 | ||
701 | ```dart | 702 | ```dart |
702 | void main() { | 703 | void main() { |
703 | - runApp(GetMaterialApp( | ||
704 | - initialRoute: '/', | ||
705 | - namedRoutes: { | ||
706 | - '/': GetRoute(page: MyHomePage()), | ||
707 | - '/second': GetRoute(page: Second()), | ||
708 | - '/third': GetRoute(page: Third(),transition: Transition.cupertino); | ||
709 | - }, | ||
710 | - )); | 704 | + runApp( |
705 | + GetMaterialApp( | ||
706 | + initialRoute: '/', | ||
707 | + namedRoutes: { | ||
708 | + '/': GetRoute(page: MyHomePage()), | ||
709 | + '/second': GetRoute(page: Second()), | ||
710 | + '/third': GetRoute(page: Third(),transition: Transition.cupertino); | ||
711 | + }, | ||
712 | + ) | ||
713 | + ); | ||
711 | } | 714 | } |
712 | ``` | 715 | ``` |
713 | 716 | ||
@@ -743,18 +746,20 @@ You can also receive NamedParameters with Get easily: | @@ -743,18 +746,20 @@ You can also receive NamedParameters with Get easily: | ||
743 | 746 | ||
744 | ```dart | 747 | ```dart |
745 | void main() { | 748 | void main() { |
746 | - runApp(GetMaterialApp( | ||
747 | - initialRoute: '/', | ||
748 | - namedRoutes: { | ||
749 | - '/': GetRoute(page: MyHomePage()), | ||
750 | - /// Important! :user is not a new route, it is just a parameter | ||
751 | - /// specification. Do not use '/second/:user' and '/second' | ||
752 | - /// if you need new route to user, use '/second/user/:user' | ||
753 | - /// if '/second' is a route. | ||
754 | - '/second/:user': GetRoute(page: Second()), // receive ID | ||
755 | - '/third': GetRoute(page: Third(),transition: Transition.cupertino); | ||
756 | - }, | ||
757 | - )); | 749 | + runApp( |
750 | + GetMaterialApp( | ||
751 | + initialRoute: '/', | ||
752 | + namedRoutes: { | ||
753 | + '/': GetRoute(page: MyHomePage()), | ||
754 | + /// Important! :user is not a new route, it is just a parameter | ||
755 | + /// specification. Do not use '/second/:user' and '/second' | ||
756 | + /// if you need new route to user, use '/second/user/:user' | ||
757 | + /// if '/second' is a route. | ||
758 | + '/second/:user': GetRoute(page: Second()), // receive ID | ||
759 | + '/third': GetRoute(page: Third(),transition: Transition.cupertino); | ||
760 | + }, | ||
761 | + ) | ||
762 | + ); | ||
758 | } | 763 | } |
759 | ``` | 764 | ``` |
760 | Send data on route name | 765 | Send data on route name |
@@ -776,25 +781,27 @@ And now, all you need to do is use Get.toNamed() to navigate your named routes, | @@ -776,25 +781,27 @@ And now, all you need to do is use Get.toNamed() to navigate your named routes, | ||
776 | If you want listen Get events to trigger actions, you can to use routingCallback to it | 781 | If you want listen Get events to trigger actions, you can to use routingCallback to it |
777 | ```dart | 782 | ```dart |
778 | GetMaterialApp( | 783 | GetMaterialApp( |
779 | - routingCallback: (route){ | 784 | + routingCallback: (route) { |
780 | if(routing.current == '/second'){ | 785 | if(routing.current == '/second'){ |
781 | openAds(); | 786 | openAds(); |
782 | } | 787 | } |
783 | } | 788 | } |
784 | - ``` | 789 | +) |
790 | +``` | ||
785 | If you are not using GetMaterialApp, you can use the manual API to attach Middleware observer. | 791 | If you are not using GetMaterialApp, you can use the manual API to attach Middleware observer. |
786 | 792 | ||
787 | - | ||
788 | ```dart | 793 | ```dart |
789 | void main() { | 794 | void main() { |
790 | - runApp(MaterialApp( | ||
791 | - onGenerateRoute: Router.generateRoute, | ||
792 | - initialRoute: "/", | ||
793 | - navigatorKey: Get.key, | ||
794 | - navigatorObservers: [ | 795 | + runApp( |
796 | + MaterialApp( | ||
797 | + onGenerateRoute: Router.generateRoute, | ||
798 | + initialRoute: "/", | ||
799 | + navigatorKey: Get.key, | ||
800 | + navigatorObservers: [ | ||
795 | GetObserver(MiddleWare.observer), // HERE !!! | 801 | GetObserver(MiddleWare.observer), // HERE !!! |
796 | - ], | ||
797 | - )); | 802 | + ], |
803 | + ), | ||
804 | + ); | ||
798 | } | 805 | } |
799 | ``` | 806 | ``` |
800 | Create a MiddleWare class | 807 | Create a MiddleWare class |
@@ -915,20 +922,20 @@ If you want to know in depth how to change the theme, you can follow this tutori | @@ -915,20 +922,20 @@ If you want to know in depth how to change the theme, you can follow this tutori | ||
915 | You can create Global settings for Get. Just add Get.config to your code before pushing any route or do it directly in your GetMaterialApp | 922 | You can create Global settings for Get. Just add Get.config to your code before pushing any route or do it directly in your GetMaterialApp |
916 | 923 | ||
917 | ```dart | 924 | ```dart |
918 | - | ||
919 | -GetMaterialApp( | ||
920 | - enableLog: true, | ||
921 | - defaultTransition: Transition.fade, | ||
922 | - opaqueRoute: Get.isOpaqueRouteDefault, | ||
923 | - popGesture: Get.isPopGestureEnable, | ||
924 | - transitionDuration: Get.defaultDurationTransition, | ||
925 | - defaultGlobalState: Get.defaultGlobalState, | ||
926 | - ); | 925 | +GetMaterialApp( |
926 | + enableLog: true, | ||
927 | + defaultTransition: Transition.fade, | ||
928 | + opaqueRoute: Get.isOpaqueRouteDefault, | ||
929 | + popGesture: Get.isPopGestureEnable, | ||
930 | + transitionDuration: Get.defaultDurationTransition, | ||
931 | + defaultGlobalState: Get.defaultGlobalState, | ||
932 | +); | ||
927 | 933 | ||
928 | Get.config( | 934 | Get.config( |
929 | - enableLog = true, | ||
930 | - defaultPopGesture = true, | ||
931 | - defaultTransition = Transitions.cupertino} | 935 | + enableLog = true, |
936 | + defaultPopGesture = true, | ||
937 | + defaultTransition = Transitions.cupertino | ||
938 | +) | ||
932 | ``` | 939 | ``` |
933 | 940 | ||
934 | 941 | ||
@@ -937,18 +944,18 @@ GetMaterialApp configures everything for you, but if you want to configure Get M | @@ -937,18 +944,18 @@ GetMaterialApp configures everything for you, but if you want to configure Get M | ||
937 | 944 | ||
938 | ```dart | 945 | ```dart |
939 | MaterialApp( | 946 | MaterialApp( |
940 | - navigatorKey: Get.key, | ||
941 | - navigatorObservers: [GetObserver()], | ||
942 | - ); | 947 | + navigatorKey: Get.key, |
948 | + navigatorObservers: [GetObserver()], | ||
949 | +); | ||
943 | ``` | 950 | ``` |
944 | 951 | ||
945 | You will also be able to use your own Middleware within GetObserver, this will not influence anything. | 952 | You will also be able to use your own Middleware within GetObserver, this will not influence anything. |
946 | 953 | ||
947 | ```dart | 954 | ```dart |
948 | MaterialApp( | 955 | MaterialApp( |
949 | - navigatorKey: Get.key, | ||
950 | - navigatorObservers: [GetObserver(MiddleWare.observer)], // Here | ||
951 | - ); | 956 | + navigatorKey: Get.key, |
957 | + navigatorObservers: [GetObserver(MiddleWare.observer)], // Here | ||
958 | +); | ||
952 | ``` | 959 | ``` |
953 | 960 | ||
954 | ```dart | 961 | ```dart |
@@ -995,41 +1002,43 @@ You don't need the context, and you will find your navigation stack by Id. | @@ -995,41 +1002,43 @@ You don't need the context, and you will find your navigation stack by Id. | ||
995 | 1002 | ||
996 | See how simple it is: | 1003 | See how simple it is: |
997 | ```dart | 1004 | ```dart |
998 | - Navigator( | ||
999 | - key: nestedKey(1), // create a key by index | ||
1000 | - initialRoute: '/', | ||
1001 | - onGenerateRoute: (settings) { | ||
1002 | - if (settings.name == '/') { | ||
1003 | - return GetRouteBase( | ||
1004 | - page: Scaffold( | ||
1005 | - appBar: AppBar( | ||
1006 | - title: Text("Main"), | ||
1007 | - ), | ||
1008 | - body: Center( | ||
1009 | - child: FlatButton( | ||
1010 | - color: Colors.blue, | ||
1011 | - onPressed: () { | ||
1012 | - Get.toNamed('/second', id:1); // navigate by your nested route by index | ||
1013 | - }, | ||
1014 | - child: Text("Go to second")), | ||
1015 | - ), | ||
1016 | - ), | ||
1017 | - ); | ||
1018 | - } else if (settings.name == '/second') { | ||
1019 | - return GetRouteBase( | ||
1020 | - page: Center( | ||
1021 | - child: Scaffold( | ||
1022 | - appBar: AppBar( | ||
1023 | - title: Text("Main"), | ||
1024 | - ), | ||
1025 | - body: Center( | ||
1026 | - child: Text("second") | ||
1027 | - ), | ||
1028 | - ), | ||
1029 | - ), | ||
1030 | - ); | ||
1031 | - } | ||
1032 | - }), | 1005 | +Navigator( |
1006 | + key: nestedKey(1), // create a key by index | ||
1007 | + initialRoute: '/', | ||
1008 | + onGenerateRoute: (settings) { | ||
1009 | + if (settings.name == '/') { | ||
1010 | + return GetRouteBase( | ||
1011 | + page: Scaffold( | ||
1012 | + appBar: AppBar( | ||
1013 | + title: Text("Main"), | ||
1014 | + ), | ||
1015 | + body: Center( | ||
1016 | + child: FlatButton( | ||
1017 | + color: Colors.blue, | ||
1018 | + onPressed: () { | ||
1019 | + Get.toNamed('/second', id:1); // navigate by your nested route by index | ||
1020 | + }, | ||
1021 | + child: Text("Go to second"), | ||
1022 | + ), | ||
1023 | + ), | ||
1024 | + ), | ||
1025 | + ); | ||
1026 | + } else if (settings.name == '/second') { | ||
1027 | + return GetRouteBase( | ||
1028 | + page: Center( | ||
1029 | + child: Scaffold( | ||
1030 | + appBar: AppBar( | ||
1031 | + title: Text("Main"), | ||
1032 | + ), | ||
1033 | + body: Center( | ||
1034 | + child: Text("second") | ||
1035 | + ), | ||
1036 | + ), | ||
1037 | + ), | ||
1038 | + ); | ||
1039 | + } | ||
1040 | + } | ||
1041 | +), | ||
1033 | ``` | 1042 | ``` |
1034 | 1043 | ||
1035 | 1044 |
-
Please register or login to post a comment