autel_base_plugins 0.0.1
autel_base_plugins: ^0.0.1 copied to clipboard
基础组件
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:autel_base_plugins/base_plugins.dart';
import './routers/main.dart';
import 'package:autel_base_plugins/store/providers/user_provider.dart';
import 'package:provider/provider.dart';
import 'package:autel_base_plugins/utils/http.dart';
import 'pages/home/home_page.dart';
import 'pages/mine/mine_page.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// runApp(const MyApp());
runApp(
MultiProvider(
providers: [
// 添加自己的Provider
ChangeNotifierProvider(create: (_) => BasePluginsUserStore()),
],
child: const MyApp(),
),
);
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
// 信息变化监听
}
@override
Widget build(BuildContext context) {
final basePluginsUserStore = context.watch<BasePluginsUserStore>();
// 应用打开时候重新设置下domain
String? domain = basePluginsUserStore.user.domain ?? HttpUtils.default_url;
HttpUtils.resetBaseUrl(domain);
return MaterialApp(
initialRoute: '/',
routes: {
...BasePluginRoutes.routes, // 将插件中的routes合并到主程序的routes中
...ExampleRoutes.routes, // 将主程序的routes合并到插件的routes中
},
home: DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
title: null,
bottom: const PreferredSize(
preferredSize: Size.fromHeight(60.0), //设置高度
child: TabBar(
tabs: [
Tab(icon: Icon(Icons.home), text: '首页'),
Tab(icon: Icon(Icons.account_circle_sharp), text: '我的'),
],
),
),
),
body: const TabBarView(
children: <Widget>[
Center(child: HomePage()),
Center(child: MinePage()),
],
),
),
));
}
}