|
|
@ -6,6 +6,7 @@ import 'dart:io';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import 'package:window_size/window_size.dart';
|
|
|
|
import 'package:window_size/window_size.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import 'src/autofill.dart';
|
|
|
|
import 'src/autofill.dart';
|
|
|
@ -41,7 +42,7 @@ void setupWindow() {
|
|
|
|
final demos = [
|
|
|
|
final demos = [
|
|
|
|
Demo(
|
|
|
|
Demo(
|
|
|
|
name: 'Sign in with HTTP',
|
|
|
|
name: 'Sign in with HTTP',
|
|
|
|
route: '/signin_http',
|
|
|
|
route: 'signin_http',
|
|
|
|
builder: (context) => SignInHttpDemo(
|
|
|
|
builder: (context) => SignInHttpDemo(
|
|
|
|
// This sample uses a mock HTTP client.
|
|
|
|
// This sample uses a mock HTTP client.
|
|
|
|
httpClient: mockClient,
|
|
|
|
httpClient: mockClient,
|
|
|
@ -49,37 +50,53 @@ final demos = [
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Demo(
|
|
|
|
Demo(
|
|
|
|
name: 'Autofill',
|
|
|
|
name: 'Autofill',
|
|
|
|
route: '/autofill',
|
|
|
|
route: 'autofill',
|
|
|
|
builder: (context) => const AutofillDemo(),
|
|
|
|
builder: (context) => const AutofillDemo(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Demo(
|
|
|
|
Demo(
|
|
|
|
name: 'Form widgets',
|
|
|
|
name: 'Form widgets',
|
|
|
|
route: '/form_widgets',
|
|
|
|
route: 'form_widgets',
|
|
|
|
builder: (context) => const FormWidgetsDemo(),
|
|
|
|
builder: (context) => const FormWidgetsDemo(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Demo(
|
|
|
|
Demo(
|
|
|
|
name: 'Validation',
|
|
|
|
name: 'Validation',
|
|
|
|
route: '/validation',
|
|
|
|
route: 'validation',
|
|
|
|
builder: (context) => const FormValidationDemo(),
|
|
|
|
builder: (context) => const FormValidationDemo(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final router = GoRouter(
|
|
|
|
|
|
|
|
routes: [
|
|
|
|
|
|
|
|
GoRoute(
|
|
|
|
|
|
|
|
path: '/',
|
|
|
|
|
|
|
|
builder: (context, state) => const HomePage(),
|
|
|
|
|
|
|
|
routes: [
|
|
|
|
|
|
|
|
for (final demo in demos)
|
|
|
|
|
|
|
|
GoRoute(
|
|
|
|
|
|
|
|
path: demo.route,
|
|
|
|
|
|
|
|
builder: (context, state) => demo.builder(context),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
class FormApp extends StatelessWidget {
|
|
|
|
class FormApp extends StatelessWidget {
|
|
|
|
const FormApp({super.key});
|
|
|
|
const FormApp({super.key});
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MaterialApp(
|
|
|
|
return MaterialApp.router(
|
|
|
|
title: 'Form Samples',
|
|
|
|
title: 'Form Samples',
|
|
|
|
theme: ThemeData(primarySwatch: Colors.teal),
|
|
|
|
theme: ThemeData(primarySwatch: Colors.teal),
|
|
|
|
routes: Map.fromEntries(demos.map((d) => MapEntry(d.route, d.builder))),
|
|
|
|
routerConfig: router,
|
|
|
|
home: const HomePage(),
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class HomePage extends StatelessWidget {
|
|
|
|
class HomePage extends StatelessWidget {
|
|
|
|
const HomePage({super.key});
|
|
|
|
const HomePage({super.key});
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
return Scaffold(
|
|
|
@ -103,7 +120,7 @@ class DemoTile extends StatelessWidget {
|
|
|
|
return ListTile(
|
|
|
|
return ListTile(
|
|
|
|
title: Text(demo!.name),
|
|
|
|
title: Text(demo!.name),
|
|
|
|
onTap: () {
|
|
|
|
onTap: () {
|
|
|
|
Navigator.pushNamed(context, demo!.route);
|
|
|
|
context.go('/${demo!.route}');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|