main.dart 939 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. void main() => runApp(GetMaterialApp(home: Gmus()));
  4. class Controller extends GetxController {
  5. var name = ''.obs;
  6. setName(String newName) {
  7. name.value = newName;
  8. }
  9. }
  10. class Gmus extends StatelessWidget {
  11. @override
  12. Widget build(BuildContext context) {
  13. final Controller controller = Get.put(Controller());
  14. return Scaffold(
  15. appBar: AppBar(
  16. title: Text('gmus'),
  17. ),
  18. body: Container(
  19. child: Column(
  20. children: [
  21. Obx(() => Text("Name: ${controller.name}")),
  22. TextField(
  23. onChanged: controller.setName,
  24. decoration: InputDecoration(
  25. border: InputBorder.none,
  26. hintText: 'Set name',
  27. ),
  28. ),
  29. ],
  30. ),
  31. ),
  32. );
  33. }
  34. }