1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
import 'package:flutter/material.dart';
void main() {
var url = Uri.base.toString();
var uri = Uri.parse(url.replaceFirst('#/', ''));
var uuid = uri.queryParameters['uuid'];
var token = uri.queryParameters['token'];
runApp(MyApp(
url: url,
uuid: uuid,
token: token,
));
}
class MyApp extends StatelessWidget {
final String url;
final String? uuid;
final String? token;
const MyApp({super.key, required this.url, this.uuid, this.token});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Web Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
appBar: AppBar(
title: const Text('获取Url参数'),
),
body: Container(
padding: const EdgeInsets.all(20),
alignment: Alignment.center,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text('url:$url'),
Text('uuid:$uuid'),
Text('token:$token')
],
),
),
),
);
}
}
|