v_base_framework 2.3.1
v_base_framework: ^2.3.1 copied to clipboard
一个牛逼的基础库,欢迎使用
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:v_base_framework/common/VFBaseTextDelete.dart';
import 'package:v_base_framework/http/config/http_config.dart';
import 'package:v_base_framework/http/config/response_config.dart';
import 'package:v_base_framework/http/http.dart';
import 'package:v_base_framework/page/base_page.dart';
import 'package:v_base_framework/utils/logger/loggger.dart';
import 'package:v_base_framework/utils/toast.dart';
import 'package:v_base_framework/v_base_framework.dart';
void main() {
// runApp(const MyApp());
runApp(ToastUtils.init(const MyApp()));
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.red,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends BasePage {
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
@override
CommonBasePageState<BasePage> createBaseState() => _MyHomePageState();
}
class _MyHomePageState extends CommonBasePageState<MyHomePage> {
String _platformVersion = 'Unknown';
final _vBaseFrameworkPlugin = VBaseFramework();
// @override
// void initState() {
// super.initState();
// initPlatformState();
//
// logger.e("这是一个牛逼的基础库");
// ToastUtils.toast("测试成功");
// }
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try {
platformVersion =
await _vBaseFrameworkPlugin.getPlatformVersion() ?? 'Unknown platform version';
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_platformVersion = platformVersion;
});
}
void dev2test() async{
Http().init( HttpDioConfig(
successCode: 3000,
tokenInvalidCode: 401,
errorMessage: "请求失败,请稍后再试!",
connectTimeout: 10*60*1000,//下载的时候尤其要用
isNeedProxy: true,
proxyHost: "192.168.3.54:10086",
));
ReponseConfigUtils.setResponseConfig(ReponseConfig(
responseCodeName: "code", responseMessageName: "message"));
try {
// dynamic re = await request2Get(
// "https://mock.mengxuegu.com/mock/6254f1d7560e3d1eabd76be9/supplier/3",
// context);
dynamic re = await request2Get(
"https://mock.mengxuegu.com/mock/6254f1d7560e3d1eabd76be9/user/pwd",
context);
debugPrint("========能不能拦截住=页面2=============");
debugPrint
("页面==>" + re.toString());
} catch (e) {
debugPrint("页面= -异常- =>$e" );
}
}
@override
Widget buildPageWidget(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Plugin example VBaseFramework'),
),
body: Center(
child: Text('Running on: $_platformVersion\n'),
),
);
}
@override
void initBaseParams() {
// TODO: implement initBaseParams
}
@override
void initPageData() {
initPlatformState();
ToastUtils.toast("测试成功");
logger.e("这是一个牛逼的基础库");
// ToastUtils.toast("测试成功");
VFTextDelegateHelper.getErrorMsg();//正常需要自己在初始化完成后调用这个
dev2test();
}
}