A, integration,
1, in a pub. Dev/packages/ge… 2. Add the following code to pubspec.yaml in the root directory of the project
dependencies:
get: ^ 4.1.4
Copy the code
3. Open the terminal and execute flutter pub get
Two, basic configuration
Change the code in main.dart to (that is, replace the default MaterialApp with GetMaterialApp)
GetMaterialApp(
navigatorKey: Get.key,
debugShowCheckedModeBanner: false,
defaultTransition: Transition.cupertino,
theme: ThemeData(
primaryColor: Colors.white,
highlightColor: Color.fromRGBO(0.0.0.0),
splashColor: Color.fromRGBO(0.0.0.0)),
initialRoute: RouteManager.splashPage,
getPages: AppPages.getPages(),
),
);
Copy the code
Iii. Basic use (Routing, Dialog, BottomSheet)
- routing
Create a new page, FirstPage
import 'package:flutter/material.dart';
class FirstPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('FirstPage')),
body: Container(
color: Colors.green,
child:ElevatedButton(
style: ElevatedButton.styleFrom(
primary: CustomColors.appBarBgColor,
),
onPressed: () async {
/ / jump
Get.to(SecondPage();
},
child: Container(
alignment: Alignment.center,
margin: EdgeInsets.symmetric(horizontal: 16),
width: 260,
child: Text('to second page'(), ((), ((), ((), ((), (() }}Copy the code