first
This commit is contained in:
96
example/lib/main.dart
Normal file
96
example/lib/main.dart
Normal file
@ -0,0 +1,96 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:iflytek_speech_demo/iflytek_speech_demo.dart';
|
||||
|
||||
//插件的示例代码,调用插件dart中
|
||||
|
||||
void main() => runApp(MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'Flutter_ScreenUtil',
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.blue,
|
||||
),
|
||||
home: HomePage(title: 'FlutterScreenUtil Demo'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({Key? key, required this.title}) : super(key: key);
|
||||
|
||||
final String title;
|
||||
|
||||
@override
|
||||
_HomePageState createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//设置尺寸(填写设计中设备的屏幕尺寸)如果设计基于360dp * 690dp的屏幕
|
||||
ScreenUtil.init(
|
||||
BoxConstraints(
|
||||
maxWidth: MediaQuery.of(context).size.width,
|
||||
maxHeight: MediaQuery.of(context).size.height),
|
||||
designSize: Size(360, 690),
|
||||
context: context,
|
||||
minTextAdapt: true,
|
||||
orientation: Orientation.portrait);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('测试'),
|
||||
),
|
||||
body: Content(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Content extends StatefulWidget {
|
||||
const Content({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ContentState createState() => _ContentState();
|
||||
}
|
||||
|
||||
class _ContentState extends State<Content> {
|
||||
String appID = 'da2aaf9b';
|
||||
|
||||
IflytekSpeechDemo iflytekSpeechDemo = IflytekSpeechDemo();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 1.sh - 90,
|
||||
width: 1.sw,
|
||||
child: ListView(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
child: Text("test"),
|
||||
onPressed: () {
|
||||
print('我被点击了');
|
||||
iflytekSpeechDemo.init(appID);
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
child: Text("start"),
|
||||
onPressed: () {
|
||||
print('我被点击了');
|
||||
iflytekSpeechDemo.start((Map<String, dynamic> event) async {
|
||||
print("flutter onOpenNotification: $event");
|
||||
});
|
||||
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user